
/* THEME — replace this file to change look & feel quickly */
:root{
  --bg:#ffffff;
  --ink:#0f172a;
  --muted:#64748b;
  --panel:#f8fafc;
  --visit-strip-height: 64px;

  /* soft light tints */
  --t-blue:#dbeafe;
  --t-violet:#ede9fe;
  --t-green:#dcfce7;
  --t-red:#fee2e2;

  --accent:#3b82f6;
  --accent-2:#6366f1;
  --accent-3:#10b981;
  --accent-4:#ef4444;

  --grid-major:#e5e7eb;
  --grid-minor:#f3f4f6;

  --radius:14px;
  --radius-sm:10px;
  --radius-xs:6px;

  --shadow:0 10px 30px rgba(0,0,0,.08);
}

.workspace,
.viewport {
  overscroll-behavior: none;
}

*{ box-sizing:border-box; }
html,body,#app{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font-family: "Google Sans Code", "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  line-height:1.4;
}

/* Workspace with graph paper grid */
.workspace{
  position:relative;
  height:100%;
  overflow:hidden;
  background:
    linear-gradient(to right, var(--grid-minor) 1px, transparent 1px) 0 0/20px 20px,
    linear-gradient(to bottom, var(--grid-minor) 1px, transparent 1px) 0 0/20px 20px,
    linear-gradient(to right, var(--grid-major) 1px, transparent 1px) 0 0/100px 100px,
    linear-gradient(to bottom, var(--grid-major) 1px, transparent 1px) 0 0/100px 100px;
}

.viewport{
  position:absolute;
  inset:0;
  touch-action:none; /* we'll handle pan/zoom */
}

.content{
  position:absolute;
  transform-origin: 0 0;
  min-width:100%;
  min-height:100%;
}

/* Visitors strip */
.visit-strip{
  position: sticky; /* se mantiene adherida a la parte superior dentro de la página */
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .5rem .75rem;
  background: var(--panel);
  border-bottom: 1px solid #e5e7eb;
  box-shadow: var(--shadow);
}

.visit-strip .visit-left{
  display: flex; align-items: center; gap: .5rem;
}
.visit-strip .visit-label{
  color: var(--muted);
  font-size: .9rem;
}

.visit-strip .visit-list{
  display: flex; flex-wrap: wrap; gap: .4rem;
  max-width: 70vw;
}

.badge-visitor{
  display: inline-flex; align-items: center;
  padding: .25rem .55rem;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: .85rem;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.badge-visitor:hover{ transform: translateY(-1px); }
.badge-visitor.share-alert{
  border-color: var(--accent-4);
  background: #fee2e2;
  color: #991b1b;
  box-shadow: 0 0 0 2px rgba(239,68,68,.20), 0 6px 18px rgba(239,68,68,.30);
  animation: share-pulse 1.1s ease-in-out infinite;
  cursor: pointer;
}
.badge-visitor.share-alert:hover{
  transform: translateY(-2px);
}
@keyframes share-pulse{
  0%, 100% { transform: translateY(0); }
  50% {
    transform: translateY(-3px);
  box-shadow: 0 0 0 4px rgba(239,68,68,.12), 0 10px 24px rgba(239,68,68,.32);
  }
}
.badge-visitor.share-alert.self{
  background: #fee2e2;
  color: #991b1b;
  border-color: var(--accent-4);
}

.badge-visitor.self{
  border-color: var(--accent-2);
  background: var(--t-violet);
  color: #312e81; /* texto violeta oscuro para contraste */
  font-weight: 600;
}

/* animaciones de entrada y salida */
.badge-visitor.entering{ animation: v-enter .20s ease-out both; }
.badge-visitor.leaving { animation: v-leave .20s ease-in both; }
@keyframes v-enter {
  from { opacity: 0; transform: scale(.95); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes v-leave {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(.95); }
}

.visit-strip .visit-right{
  margin-left: auto;
  color: var(--muted);
  font-size: .9rem;
}
.visit-strip .visit-total{
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: .2rem .5rem;
  color: var(--accent);
  font-weight: 600;
}

/* durante la exportación fijamos todo para que html2canvas renderice de forma estable */
.exporting *{ transition:none !important; animation:none !important; }
.exporting .modal-root{ display:none }
.modal-root.active{ display:flex !important; }

/* al exportar ocultamos los botones superiores de la tarjeta y el botón flotante */
.exporting .card-actions,
.exporting .card .icon-btn,
.exporting .fab-open{
  display: none !important;
}

/* Card */
.card-header { cursor: grab; }

.card-title{
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;                 /* вместо width:100% */
  text-align: center;
  cursor:pointer;
}

.card.dragging .card-header { cursor: grabbing; }

.card{
  position:absolute;
  background:#f4f5f7;
  border:1.5px solid #000000;
  border-radius:var(--radius);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  min-width: 320px;
  user-select:none;
  transition: background 0.2s, box-shadow 0.2s;
}

.card:hover{
  background:#eef0f2;              /* ligero aclarado al pasar el cursor */
  box-shadow: 0 6px 14px rgba(0,0,0,0.15);
}

.card-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:.5rem .6rem;
  border-bottom:1px solid #e5e7eb;
  position:relative;
}

.card-title{
  font-weight:600;
  outline:none;
  padding:.2rem .35rem;
  border-radius: var(--radius-xs);
  user-select:none;
}
.card-title:hover{
  background:#f8fafc;
}
.card-title:focus-visible{
  outline:2px solid #3b82f6;
  outline-offset:2px;
}

.card-info-marker{
  position:absolute;
  top:6px;
  right:6px;
  width:20px;
  height:20px;
  border-radius:50%;
  background:#10b981;
  color:#f0fdf4;
  font-size:0.8rem;
  font-weight:700;
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:0;
  transform:scale(0.6);
  pointer-events:none;
  transition:opacity .16s ease, transform .16s ease;
  text-transform:uppercase;
  box-shadow:0 4px 12px rgba(16,185,129,.25);
}
.card-info-marker.visible{
  opacity:1;
  transform:scale(1);
}

.card-actions{
  display:flex;
  gap:.35rem;
}
.icon-btn{
  width:28px;height:28px;
  display:grid;place-items:center;
  border-radius:50%;
  border:1px solid transparent;
  background:#fff;
  cursor:pointer;
}
.icon-btn.red{ border-color: var(--accent-4); color:var(--accent-4); }
.icon-btn.blue{ border-color: var(--accent); color:var(--accent); }
.icon-btn.green { border-color: var(--accent-3); color: var(--accent-3); }
.icon-btn.yellow{ border-color: #facc15; color:#eab308; }
.icon-btn.yellow.active{
  background:#eab308;
  border-color:#eab308;
  color:#fff;
}
.icon-btn.active{
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}
.icon-btn:hover{ filter: brightness(0.95); }

.pairs{
  display:flex;
  flex-direction:column;
  gap:.5rem;
  padding:.6rem;
}

/* Pair row */
.pair{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
}

.pair.dragging{
  opacity: 0.6;
}

.pair.placeholder {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  background: transparent;
  margin: 4px 0;
}

.drag-ghost {
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
  border-radius: 8px;
  opacity: .95;
  pointer-events:none;
}

.icon-btn.violet{ border-color: var(--accent-2); color: var(--accent-2); }

/* Celdas */
.cell{
  display:grid;
  grid-template-columns: 15% 85%;
  min-height:64px;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius: var(--radius-sm);
  overflow:visible;
  cursor:pointer;
  position: relative;
}
.cell.cell-inverted-b{
  box-shadow:
    0 0 0 2px var(--invert-glow-strong, rgba(255,255,255,0.4)),
    0 0 18px 6px var(--invert-glow-soft, rgba(255,255,255,0.18));
  z-index: 1;
}

body.free-pair-mode .pair .cell[data-kind="A"]:not(.outline-only){
  cursor: grab;
  touch-action: none;
}
body.free-pair-mode .pair.dragging .cell[data-kind="A"]{
  cursor: grabbing;
}

.cell.outline-only{
  display:flex !important;
  align-items:center;
  justify-content:center;
  background:transparent;
  border:2px dashed #94a3b8;
}
.cell.outline-only .sub{ display:none !important; }
.cell.outline-only .cell-labels{ display:none !important; }
.cell.local-link-empty{
  background:transparent;
  border-color:#94a3b8;
  border-width:2px;
  border-style:dashed;
}
.cell.local-link-empty .sub{
  visibility:hidden;
}
.cell.local-link-empty .cell-labels{
  display:none;
}

.signal-sticker{
  position:absolute;
  bottom:-8px;
  left:50%;
  transform:translateX(-50%);
  display:flex;
  align-items:center;
  gap:6px;
  padding:2px 12px;
  font-size:11px;
  line-height:1.2;
  border-radius:999px;
  background:#ffffff;
  color:#0f172a;
  border:1px solid rgba(15,23,42,0.2);
  box-shadow:0 4px 10px rgba(15,23,42,0.15);
  cursor:pointer;
  user-select:none;
  z-index:40;
  white-space:nowrap;
}
.signal-sticker .sig-value{
  min-width:54px;
  text-align:center;
  font-variant-numeric:tabular-nums;
}
.signal-sticker.low-signal{
  background:#fee2e2;
  border-color:#f87171;
}
.signal-frequency-row .signal-frequency-value{
  font-size:13px;
  color:#0f172a;
  margin-left:auto;
  text-align:right;
  white-space:nowrap;
}
.signal-unit-toggle{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:13px;
  color:#0f172a;
  cursor:pointer;
}
.signal-unit-toggle input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}
.signal-unit-toggle .toggle-track{
  position:relative;
  width:40px;
  height:22px;
  background:#cbd5f5;
  border-radius:999px;
  transition:background .2s ease;
  flex:0 0 auto;
}
.signal-unit-toggle .toggle-thumb{
  position:absolute;
  top:3px;
  left:3px;
  width:16px;
  height:16px;
  border-radius:50%;
  background:#fff;
  box-shadow:0 2px 4px rgba(15,23,42,.25);
  transition:transform .2s ease;
}
.signal-unit-toggle input:checked + .toggle-track{
  background:#0ea5e9;
}
.signal-unit-toggle input:checked + .toggle-track .toggle-thumb{
  transform:translateX(18px);
}
.signal-unit-toggle .toggle-text{
  font-size:.85rem;
  color:#0f172a;
  white-space:nowrap;
}
.signal-unit-toggle input:focus-visible + .toggle-track{
  outline:2px solid #0ea5e9;
  outline-offset:2px;
}
.signal-config-target{
  margin:0 0 12px;
  font-size:.9rem;
  color:var(--muted);
}
.signal-config .cell-menu-inline{
  justify-content:space-between;
  gap:.75rem;
}
.signal-config .cell-menu-inline .badge{
  flex:1 1 auto;
  min-width:100px;
  text-align:left;
}
.signal-config .cell-menu-inline > :not(.badge){
  margin-left:auto;
}
.signal-config .cell-menu-inline select,
.signal-config .cell-menu-inline input,
.signal-config .cell-menu-inline .signal-power-control,
.signal-config .cell-menu-inline .signal-unit-toggle,
.signal-config .cell-menu-inline .signal-frequency-value{
  flex:0 0 auto;
  width:auto;
  min-width:140px;
  max-width:210px;
  min-height:32px;
  margin-left:auto;
}
.signal-config .cell-menu-inline input[type="number"],
.signal-config .cell-menu-inline input[type="text"]{
  text-align:right;
}
.signal-config select,
.signal-config input[type="number"],
.signal-config input[type="text"]{
  height:32px;
  line-height:30px;
  padding:0 .5rem;
}
.signal-config .signal-power-control{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:.5rem;
}
.signal-config .signal-power-control input[type="range"]{
  width:130px;
  min-height:32px;
}
.signal-config .signal-power-value{
  min-width:64px;
  text-align:right;
}
.signal-config .signal-unit-toggle{
  justify-content:flex-end;
  gap:.4rem;
}

/* objetivo para conectarse */
.cell.connect-target { outline: 2px dashed #60a5fa; outline-offset: 2px; }

/* capa común de etiquetas */
.cell-labels{
  position:absolute; inset:6px;
  display:flex; flex-direction:column; gap:4px;
  justify-content:center;
  pointer-events:none;
}

.cell-labels .line1{
  font-weight:700;
  font-size:16px;
  line-height:1.1;
  color:#000;
  text-shadow:
    0 0 3px #fff,
    0 0 6px #fff,
    0 0 9px rgba(255,255,255,.85),
    0 0 12px rgba(255,255,255,.75);
}
.cell-labels .line2{
  font-style:italic;
  font-size:12px;
  line-height:1.1;
  color:#000;
  text-shadow:
    0 0 3px #fff,
    0 0 6px #fff,
    0 0 9px rgba(255,255,255,.85),
    0 0 12px rgba(255,255,255,.75);
}

/* двухколоночные строки: левая/правая части для обеих линий */
.cell-labels .line1,
.cell-labels .line2{
  display:flex;
  align-items:center;
  gap:0;
  white-space:nowrap;
}
.cell-labels .line1.split-line,
.cell-labels .line2.split-line{
  gap:8px;
}
.cell-labels .line1 .l,
.cell-labels .line2 .l{
  text-align:left;
}
.cell-labels .line1 .r,
.cell-labels .line2 .r{
  margin-left:auto;
  text-align:right;
}
.cell-labels .line1 .l.empty,
.cell-labels .line1 .r.empty,
.cell-labels .line2 .l.empty,
.cell-labels .line2 .r.empty{
  display:none;
}

/* alineación a los lados */
.cell-labels .align-left  { text-align:left;  }
.cell-labels .align-right { text-align:right; }

.cell.B{ grid-template-columns: 85% 15%; }

/* A (sin .B): por defecto pequeño | grande => en espejo grande | pequeño */
.cell:not(.B).mirror { 
  grid-template-columns: 85% 15% !important;
}
.cell:not(.B).mirror .sub.small{
  border-left: 1px dashed #e5e7eb !important;
  border-right: none !important;
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  border-top-right-radius: var(--radius-sm) !important;
  border-bottom-right-radius: var(--radius-sm) !important;
}

/* B: por defecto grande | pequeño => en espejo pequeño | grande */
.cell.B.mirror{
  grid-template-columns: 15% 85% !important;
}
.cell.B.mirror .sub.small{
  border-right: 1px dashed #e5e7eb !important;
  border-left: none !important;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  border-top-left-radius: var(--radius-sm) !important;
  border-bottom-left-radius: var(--radius-sm) !important;
}
.cell:not(.B).mirror .sub.large{
  border-top-left-radius: var(--radius-sm) !important;
  border-bottom-left-radius: var(--radius-sm) !important;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}
.cell.B.mirror .sub.large{
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  border-top-right-radius: var(--radius-sm) !important;
  border-bottom-right-radius: var(--radius-sm) !important;
}

/* Выравнивание, если класс стоит на .cell-labels ИЛИ на внутреннем элементе */
.cell-labels.align-left,
.cell-labels .align-left  { text-align: left; }

.cell-labels.align-right,
.cell-labels .align-right { text-align: right; }

/* Фикс для flex-строк: двигаем контент всей строки */
.cell-labels.align-left  .line1,
.cell-labels.align-left  .line2,
.cell-labels .align-left  .line1,
.cell-labels .align-left  .line2 { justify-content: flex-start; }

.cell-labels.align-right .line1,
.cell-labels.align-right .line2,
.cell-labels .align-right .line1,
.cell-labels .align-right .line2 { justify-content: flex-end; }

/* Точное выравнивание для flex-строк с классами на самих .line1/.line2 */
.cell-labels .line1.align-left,
.cell-labels .line2.align-left { 
  justify-content: flex-start; 
  text-align: left;
}

.cell-labels .line1.align-right,
.cell-labels .line2.align-right { 
  justify-content: flex-end; 
  text-align: right;
}

.sub.small{
  min-height:64px;
  background: var(--t-blue);
  border-right:1px dashed #e5e7eb;
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}
.cell.B .sub.small{
  border-right:none;
  border-left:1px dashed #e5e7eb;
  border-top-left-radius:0;
  border-bottom-left-radius:0;
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}
.sub.large{
  min-height:64px;
  background:#fff;
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}
.cell.B .sub.large{
  border-top-right-radius:0;
  border-bottom-right-radius:0;
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}

/* Modal centrada — tamaño según el contenido */
.modal-root{
  position:fixed; inset:0; display:none;
  align-items:center; justify-content:center;
  backdrop-filter: blur(2px);
  background: rgba(0,0,0,0.08);
  pointer-events:auto; z-index:1000;
}
.modal-root.active{ display:flex; }

/* Ancho automático según contenido + límite por pantalla */
.modal{
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:var(--radius);
  box-shadow: var(--shadow);
  width: fit-content;
  max-width: 92vw;
  max-height: 88vh;
  overflow:auto;
  padding: 12px 14px;
}

/* Dentro de la modal todo va en VERTICAL */
.modal .row{
  display:flex;
  flex-direction: column;   /* antes: row */
  gap:.5rem;
  margin:.5rem 0;
  align-items: stretch;     /* botones/campos a todo el ancho */
}

.modal .global-menu-grid{
  display:grid;
  grid-template-columns: minmax(180px, 1fr) minmax(200px, 1fr);
  gap:1rem;
  margin:.5rem 0;
}
.modal .cell-menu-grid{
  display:grid;
  grid-template-columns: minmax(160px, 1fr) minmax(140px, 1fr);
  gap:.75rem;
  margin-top:.75rem;
}
.modal .cell-menu-col{
  display:flex;
  flex-direction:column;
  gap:.5rem;
}
.modal .cell-menu-colors{
  display:grid;
  grid-template-columns:auto 1fr;
  gap:.4rem .6rem;
  align-items:center;
}
.cell-menu-colors .badge{
  justify-content:flex-start;
}
.cell-menu-select{
  display:flex;
  flex-direction:column;
  gap:.35rem;
}
.cell-menu-buttons{
  display:flex;
  flex-direction:column;
  gap:.5rem;
}
.cell-menu-stack{
  display:flex;
  flex-direction:column;
  gap:.6rem;
}
.modal .row.quick-pair-buttons{
  flex-direction:row;
  flex-wrap:wrap;
  gap:.5rem;
}
.modal .row.quick-pair-buttons .btn{
  flex:1 1 calc(50% - .5rem);
}
.modal .row.quick-pair-buttons-compact{
  gap:.35rem;
}
.modal .row.quick-pair-buttons-compact .btn{
  flex:1 1 calc(50% - .35rem);
  font-size:.85rem;
  padding:6px 8px;
}
.quick-pair-btn{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:.45rem;
}
.quick-pair-badge{
  min-width:22px;
  height:22px;
  padding:0 6px;
  border-radius:999px;
  background:var(--accent);
  color:#fff;
  font-size:.78rem;
  font-weight:600;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  box-shadow:0 2px 6px rgba(59,130,246,.35);
}
.quick-pair-badge.is-ghost{
  background:#e2e8f0;
  color:#0f172a;
  box-shadow:0 2px 6px rgba(15,23,42,.15);
}
.quick-pair-buttons-compact .quick-pair-btn{
  gap:.35rem;
}
.quick-pair-buttons-compact .quick-pair-badge{
  height:20px;
  min-width:20px;
  font-size:.7rem;
  padding:0 5px;
}
.modal .cell-menu-inline{
  display:flex;
  align-items:center;
  gap:.5rem;
  margin:.5rem 0;
}
.modal .cell-menu-inline .badge{
  flex:0 0 auto;
  min-width:90px;
}
.modal .cell-menu-inline select,
.modal .cell-menu-inline input{
  flex:1 1 auto;
  max-width:180px;
}
.modal .cell-menu-inline .suffix{
  flex:0 0 auto;
}

.quick-color-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(96px, 1fr));
  gap:10px;
  margin:16px 0;
}
.quick-color{
  border:none;
  border-radius:12px;
  padding:10px;
  font-size:.85rem;
  cursor:pointer;
  transition:transform .12s ease, box-shadow .12s ease;
  box-shadow:0 4px 12px rgba(15,23,42,.14);
}
.quick-color:hover{
  transform:translateY(-1px);
  box-shadow:0 6px 16px rgba(15,23,42,.2);
}

/* Подсказываем Chromium, что по этим элементам ожидаются быстрые «тапы» без жестов панорамы */
.cell, .pair, .card, .qa-btn {
  touch-action: manipulation;
}

/* #qbSyncsel[data-mode="1"] { background: #10b981; }
#qbSyncsel[data-mode="2"] { background: #3b82f6; }
#qbSyncsel[data-mode="3"] { background: #8b5cf6; } */

.modal .cell-menu-inline .cell-menu-value{
  flex:1 1 auto;
  font-weight:500;
  color:#111827;
  word-break:break-all;
}
.modal .cell-menu-inline .suffix{
  color:var(--muted);
  font-size:.85rem;
}
.modal .cell-menu-sync{
  gap:.6rem;
}
.modal .cell-menu-sync input[type="checkbox"]{
  flex:0 0 auto;
  width:18px;
  height:18px;
  margin:0;
}
.modal .cell-menu-sync .checkbox-label{
  flex:1 1 auto;
  display:flex;
  align-items:center;
  gap:.4rem;
}

.link-menu input[type="number"] {
  width: 100px;            /* ширина поля */
  padding: 4px 6px;
  text-align: right;
  font: 14px/1.3 system-ui, sans-serif;
}
.link-menu .suffix {
  margin-left: 4px;
  font-weight: 600;
  color: #111827;
}

.modal.link-menu,
.modal.link-menu{
  max-width: 260px;
}
.global-menu-grid .gm-col{
  display:flex;
  flex-direction:column;
  gap:.5rem;
}
.global-menu-grid .share-col .badge{
  align-self:flex-start;
}
@media (max-width: 640px){
  .modal .global-menu-grid{
    grid-template-columns: 1fr;
  }
  .modal .cell-menu-grid{
    grid-template-columns:1fr;
  }
}

.modal select{
  width:100%;
  height:36px;
  border:1px solid #e5e7eb;
  border-radius:10px;
  background:#fff;
  padding: 0 10px;
}
.modal select[multiple]{
  height:auto;
  min-height:120px;
}

.title-menu .title-input-wrap{
  position:relative;
  display:flex;
  align-items:center;
}
.title-menu input[type="text"]{
  width:100%;
  height:38px;
  padding: 0 38px 0 12px;
  border:1px solid #e5e7eb;
  border-radius:10px;
  font-size:1rem;
}
.title-menu .title-input-clear{
  position:absolute;
  right:6px;
  width:28px;
  height:28px;
  border:none;
  background:transparent;
  border-radius:50%;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  color:#9ca3af;
  transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}
.title-menu .title-input-clear:hover{
  background:#f3f4f6;
  color:#111827;
  box-shadow:0 1px 4px rgba(15,23,42,.1);
}
.title-menu-actions{
  display:flex;
  gap:.5rem;
  flex-direction:row;
  margin-top:.25rem;
}
.title-menu-actions .btn{
  flex:1 1 0;
}

/* Botones y campos ocupan todo el ancho */
.modal .btn{ width:100%; }
.modal select,
.modal input[type="color"]{ width:100%; height:36px; }

.modal h3{ margin:.25rem 0 .5rem; font-size:1.05rem; }
.btn{
  border:1px solid #e5e7eb;
  background:#fff;
  border-radius:10px;
  padding:.55rem .8rem;
  cursor:pointer;
}
.btn.primary{ border-color:var(--accent); color:var(--accent); }
.btn.danger{ border-color:var(--accent-4); color:var(--accent-4); }
.btn.ghost{ border-color:transparent; background:transparent; color:var(--muted);}
.btn.block{ width:100%; text-align:center; }
.btn:disabled{ opacity:.5; cursor:not-allowed; }

/* Etiquetas pequeñas */
.badge{
  display:inline-flex; align-items:center; gap:.35rem;
  border:1px solid #e5e7eb; border-radius: 999px; padding:.2rem .5rem; font-size:.8rem; color:#334155;
  background: #fdfdfd;
}
.color-swatch{ width:14px; height:14px; border-radius:50%; border:1px solid #e5e7eb; }

/* Ayudas (arrastre) */
.card.dragging{ opacity:.85; outline:2px dashed var(--accent); }

/* Botón flotante para abrir el menú */
.fab-open{
  position:fixed;
  right:16px;
  top: calc(var(--visit-strip-height, 0px) + 12px);
  width:54px; height:54px;
  border-radius:50%;
  display:grid; place-items:center;
  background:#93c5fd;
  color:#fff;
  border:none;
  box-shadow: var(--shadow);
  font-size:28px;
  cursor:pointer;
  z-index:999;
}
.fab-open:active{ transform: scale(0.98); }
.signal-controls{
  position:fixed;
  right:16px;
  top: calc(var(--visit-strip-height, 64px) + 16px);
  display:flex;
  align-items:center;
  gap:12px;
}
.signal-menu-btn{
  position:relative;
  padding:.5rem 1.25rem;
  border:none;
  border-radius:999px;
  background:#16a34a;
  color:#fff;
  font-weight:600;
  box-shadow: var(--shadow);
  cursor:pointer;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
  flex-shrink:0;
  z-index:1200;
}
.signal-menu-btn:hover{
  filter:brightness(1.05);
}
.signal-menu-btn:active{
  transform:scale(0.97);
  filter:brightness(0.95);
}
.signal-menu-btn.signal-mode-on{
  box-shadow: 0 0 0 2px rgba(248,113,113,0.35),
    0 0 18px rgba(248,113,113,0.65),
    0 10px 20px rgba(0,0,0,0.25);
  animation: pulse-red 1.2s ease-in-out infinite;
}
@keyframes pulse-red{
  0%{ box-shadow: 0 0 0 0 rgba(239,68,68,0.5), 0 10px 20px rgba(0,0,0,0.25); }
  60%{ box-shadow: 0 0 0 8px rgba(239,68,68,0), 0 10px 22px rgba(0,0,0,0.3); }
  100%{ box-shadow: 0 0 0 0 rgba(239,68,68,0), 0 10px 20px rgba(0,0,0,0.25); }
}
.signal-ont-info{
  position:relative;
  padding:.35rem .9rem;
  border-radius:999px;
  background:#0f172a;
  color:#f8fafc;
  font-size:.85rem;
  font-weight:600;
  letter-spacing:.02em;
  box-shadow:var(--shadow);
  z-index:1190;
  display:none;
}
.signal-ont-info.visible{
  display:flex;
}
body.menu-open .signal-ont-info{
  z-index:900;
}
@media (max-width: 640px){
  .signal-controls{
    flex-wrap:wrap;
    justify-content:flex-end;
    align-items:center;
    gap:8px;
  }
  .signal-ont-info{
    order:1;
    flex:0 1 auto;
    justify-content:flex-start;
  }
  .signal-menu-btn{
    order:2;
  }
}

.quick-actions{
  position:fixed;
  top: calc(var(--visit-strip-height, 64px) + 16px);
  left:16px;
  right:auto;
  display:flex;
  flex-direction:column;
  gap:6px;
  background:transparent;
  border:none;
  box-shadow:none;
  z-index:960;
  align-items:flex-start;
  padding:0;
  width:max-content;
}
.qa-toggle{
  display:none;
}
.qa-row{
  display:flex;
  flex-wrap:nowrap;
  align-items:flex-start;
  gap:10px;
  overflow:visible;          /* важное: никаких внутренних скроллов */
  padding:6px 8px;           /* запас для hover-анимации */
  border-radius:12px;        /* аккуратная капсула под ряд */
  background:transparent;

  /* overflow-x:auto;
  padding-bottom:4px; */
}
.qa-row::-webkit-scrollbar{
  height:6px;
}

/* на десктопе полосы прокрутки не нужны вовсе */
.qa-row::-webkit-scrollbar{ display:none; }

.qa-row::-webkit-scrollbar-thumb{
  background:#cbd5f5;
  border-radius:999px;
}
.qa-counter{
  position:relative;
  width:48px;
  height:48px;
}
.qa-counter-value{
  position:absolute;
  bottom:-12px;
  left:50%;
  transform:translateX(-50%);
  width:40px;
  height:40px;
  border-radius:50%;
  background:#1e293b;
  color:#f8fafc;
  display:grid;
  place-items:center;
  font-weight:700;
  letter-spacing:0.03em;
  box-shadow:0 8px 18px rgba(15,23,42,.25);
  border:2px solid rgba(255,255,255,.9);
}
.qa-btn{
  position:relative;
  width:46px;
  height:46px;
  border-radius:50%;
  border:2px solid rgba(15,23,42,.12);
  background:#eff6ff;
  color:#0f172a;
  font-size:0.9rem;
  cursor:pointer;
  --qa-ring-outer: 0 0 0 0 rgba(0,0,0,0);
  --qa-ring-glow: 0 0 0 0 rgba(0,0,0,0);
  box-shadow: var(--qa-ring-outer), var(--qa-ring-glow), 0 6px 16px rgba(59,130,246,.24);
  transition:transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
  display:grid;
  place-items:center;
  flex:0 0 auto;
  z-index:0;
}
.qa-btn-has-counter{
  position:relative;
}
.qa-btn-counter{
  position:absolute;
  bottom:-8px;
  left:50%;
  transform:translateX(-50%);
  width:22px;
  height:22px;
  border-radius:50%;
  background:#0f172a;
  color:#f8fafc;
  font-size:0.75rem;
  font-weight:700;
  display:grid;
  place-items:center;
  box-shadow:0 6px 14px rgba(15,23,42,.22);
  border:2px solid #ffffffee;
}
.qa-color-green{ background:#dcfce7; border-color:#16a34a33; color:#166534; }
.qa-color-blue{ background:#dbeafe; border-color:#2563eb33; color:#1e3a8a; }
.qa-color-yellow{ background:#fef9c3; border-color:#ca8a0433; color:#92400e; }
.qa-color-teal{ background:#ccfbf1; border-color:#0d948833; color:#115e59; }
.qa-color-purple{ background:#ede9fe; border-color:#7c3aed33; color:#4c1d95; }
.qa-color-pink{ background:#ffe4e6; border-color:#db277733; color:#9d174d; }
.qa-color-black{ background:#e5e7eb; border-color:#11182755; color:#111827; }
.qa-color-tube{ background:linear-gradient(135deg,#eaf604 0%,#03f96e 50%,#03d6f6 100%); border-color:#0586f7e8; color:#8e05f7; }
.qa-color-fiber{ background:linear-gradient(135deg,#ff0101 0%,#fa8f02 50%,hsl(51, 98%, 49%) 100%); border-color:#0586f7e8; color:#04e2f7; }
.qa-color-orange{ background:#ffedd5; border-color:#ea580c33; color:#9a3412; }
.qa-color-sky{ background:#e0f2fe; border-color:#0284c733; color:#075985; }
.qa-color-red{ background:#fee2e2; border-color:#ef444433; color:#991b1b; }
.qa-btn:hover{
  transform:translateY(-1px);
  box-shadow:var(--qa-ring-outer), var(--qa-ring-glow), 0 8px 18px rgba(59,130,246,.30);
}
.qa-btn.active{
  border-color:rgba(239,68,68,0.6);
  --qa-ring-outer: 0 0 0 2px rgba(239,68,68,0.75);
  --qa-ring-glow: 0 0 12px rgba(239,68,68,0.55);
}

.qa-btn[data-action="syncsel"]{
  position:relative;
  overflow:visible;
  transition:transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}
.qa-btn[data-action="syncsel"].sync-mode-off{
  --qa-ring-outer: 0 0 0 0 rgba(0,0,0,0);
  --qa-ring-glow: 0 0 0 0 rgba(0,0,0,0);
}
.qa-btn[data-action="syncsel"].sync-mode-zones{
  --qa-ring-outer: 0 0 0 2px rgba(34,197,94,0.68);
  --qa-ring-glow: 0 0 14px rgba(34,197,94,0.5);
}
.qa-btn[data-action="syncsel"].sync-mode-links{
  --qa-ring-outer: 0 0 0 2px rgba(234,179,8,0.7);
  --qa-ring-glow: 0 0 14px rgba(234,179,8,0.52);
}
.qa-btn[data-action="syncsel"].sync-mode-hybrid{
  --qa-ring-outer: 0 0 0 2px rgba(34,197,94,0.65), 0 0 0 6px rgba(234,179,8,0.45);
  --qa-ring-glow: 0 0 18px rgba(251,191,36,0.45);
}
.qa-hint{
  font-size:0.78rem;
  color:#1e293b;
  min-height:1.1em;
  opacity:0;
  transition:opacity .12s ease;
  background:rgba(255,255,255,0.85);
  padding:4px 10px;
  border-radius:12px;
  box-shadow:0 6px 18px rgba(15,23,42,.12);
}
.qa-hint.visible{
  opacity:1;
}

/* курсор и подсветки в режиме удаления */
.delete-mode { cursor: crosshair; }

.delete-mode .card .pair:hover { outline: 2px dashed #ef4444; }

.invert-mode { cursor: alias; }
.invert-mode .pair:hover { outline: 2px dashed #0ea5e9; }
.delete-mode { cursor: crosshair; }
.delete-mode .pair:hover { outline: 2px dashed #ef4444; }

/* делаем линии кликабельными только в delete-режиме */
#connLayer path[data-link] { pointer-events: none; }
.cell, .pair, .card { pointer-events: auto; }
.delete-mode #connLayer path[data-link] { pointer-events: stroke; cursor: crosshair; }

#connLayer circle {
  pointer-events: auto;   /* включаем клики */
  cursor: pointer;
}

/* @media (max-width: 720px){
  .quick-actions{
    left:12px;
    right:12px;
    gap:10px;
  }
  .qa-row{
    flex-direction:column;
    align-items:stretch;
    overflow-x:hidden;
    overflow-y:auto;
    max-height:60vh;
    padding: 0.8rem 1rem;
    padding-bottom:0;
    gap:12px;
  }
  .qa-row::-webkit-scrollbar{ width:6px; height:6px; }
  .qa-row::-webkit-scrollbar-thumb{ background:#cbd5f5; border-radius:999px; }
  .qa-btn,
  .qa-counter{
    width:48px;
    height:48px;
  }
  .qa-btn-counter{
    bottom:-6px;
  }
  .qa-hint{ display:none; }
} */

/* === Мобильная версия: компактная боковая панель Quick-action === */
@media (max-width: 768px) {
  /* отключаем всплывающие браузерные title */
  .qa-btn[title]::after { display: none !important; }

  .quick-actions {
    position: fixed;
    top: calc(var(--visit-strip-height, 64px) + 20px);
    left: 16px;
    right: auto;
    bottom: auto;
    width: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: transparent;
    border: none;
    border-radius: 16px;
    padding: 4px;
    box-shadow: none;
    backdrop-filter: none;
    z-index: 999;
    transform: none;
    touch-action: manipulation;
  }

  .quick-actions.collapsed {
    width: auto;
    padding: 4px;
  }

  .qa-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid #cbd5f5;
    background: #f8fafc;
    color: #0f172a;
    font-size: 0;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(15,23,42,.10);
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
    position: relative;
  }
  .qa-toggle::after{
    content:'✕';
    font-size: 1.2rem;
    line-height: 1;
    color:#0f172a;
  }
  .quick-actions.collapsed .qa-toggle::after{
    content:'☰';
  }

  .qa-toggle:active {
    transform: scale(0.97);
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
  }

  .qa-row {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px 0;
    margin: 0;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    width: calc(46px + 12px);
  }

  .quick-actions[data-orientation="landscape"] {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 6px;
    border-radius: 20px;
  }

  .quick-actions[data-orientation="landscape"] .qa-row {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    max-height: none;
    max-width: calc(100vw - 120px);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 8px;
    margin: 0;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    width: auto;
  }

  .quick-actions[data-orientation="landscape"] .qa-row::-webkit-scrollbar {
    width: auto;
    height: 6px;
  }

  .quick-actions[data-orientation="landscape"] .qa-row::-webkit-scrollbar-thumb {
    background:#cbd5f5;
  }

  .qa-row::-webkit-scrollbar{ width:6px; }
  .qa-row::-webkit-scrollbar-thumb{
    background:#cbd5f5;
    border-radius:999px;
  }

  /* ВАЖНО: на мобайле не трогаем фон/цвет бордера —
      чтобы работали qa-color-* классы. Только размеры/форма. */
  .qa-btn {
    position:relative;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: var(--qa-ring-outer), var(--qa-ring-glow), 0 2px 6px rgba(15,23,42,.12);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .qa-btn:focus,
  .qa-btn:focus-visible { outline: none !important; box-shadow: none !important; }

  .qa-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--qa-ring-outer), var(--qa-ring-glow), 0 4px 10px rgba(0,0,0,.12);
  }

  .qa-btn:active {
    transform: scale(0.95);
    box-shadow: var(--qa-ring-outer), var(--qa-ring-glow), 0 2px 6px rgba(0,0,0,.08);
  }

  /* подсказки не показываем на мобильных */
  .qa-hint { display:none !important; }

  .quick-actions.collapsed {
    padding: 10px;
  }
  .quick-actions.collapsed .qa-row,
  .quick-actions.collapsed .qa-hint{
    display: none !important;
  }
  .quick-actions.collapsed .qa-toggle{
    justify-content: center;
    width: 46px;
  }
}

.fab-counter-wrap{
  position:fixed;
  right:16px;
  bottom:16px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
  z-index:1205;
}
body.menu-open .fab-counter-wrap{
  z-index:900;
}
body.menu-cell-open .fab-counter-wrap{
  z-index:1305;
}
.fab-counter-btn{
  width:54px;
  height:54px;
  border-radius:50%;
  border:none;
  background:#3b82f6;
  color:#fff;
  font-size:28px;
  cursor:pointer;
  box-shadow: var(--shadow);
  display:grid;
  place-items:center;
  transition:transform .12s ease;
}
.fab-counter-btn:active{
  transform:scale(0.94);
}
.fab-counter-display{
  width:48px;
  height:48px;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:#ffffff;
  color:#0f172a;
  font-weight:600;
  font-size:1rem;
  border:1px solid #cbd5f5;
  box-shadow:0 6px 16px rgba(15,23,42,.18);
}

.card-free-move{
  outline:2px dashed #fbbf24;
  outline-offset:4px;
}
.user-list{ display:grid; gap:.5rem; max-height:40vh; overflow:auto; margin:.5rem 0 1rem; }
.user-row{ display:flex; gap:.5rem; align-items:center; }
.user-name{ font-weight:600; }

/* ===== Круговое меню у карточки ===== */
.card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* контейнер кольца */
.card-ring {
  position: absolute;
  inset: 0;             /* пусть занимает всю карточку (для кликов внутри) */
  pointer-events: none; /* клики проходят только по кнопкам */
}
.card-header { position: relative; }

.card-ring-inner {
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 0;
  transform: translate(var(--ring-cx, 0px), var(--ring-cy, 0px));
}

/* скрытое состояние */
.card-ring .ring-item {
  position: absolute;
  left: 0; top: 0;
  transform: translate(0,0) scale(0.5);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
  pointer-events: none; /* пока закрыто — не кликается */
  z-index: 5;
}

/* открыто */
.card-ring.open .ring-item {
  opacity: 1;
  pointer-events: auto;
}

/* подчёркиваем кнопку меню */
.icon-btn.menu-toggle {
  font-weight: 600;
}

/* белая кнопка в общем стиле, с обводкой */
.icon-btn.white,
.icon-btn.menu-toggle {
  background: #fff;
  color: #111827;
  border: 1px solid #11182733;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.icon-btn.menu-toggle:hover {
  border-color: #11182766;
  box-shadow: 0 2px 6px rgba(0,0,0,.10);
}

/* уточняем позиционирование кольца: в пределах header */
.card-header { position: relative; }
.card-ring { position: absolute; inset: 0; pointer-events: none; }
.card-ring-inner {
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 0;
  transform: translate(var(--ring-cx, 0px), var(--ring-cy, 0px));
  z-index: 10; /* над шапкой */
}
