<style>


#schemeModal,
#schemeModal * {
  font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif !important;
  font-weight: 500;
  color: #111827;
}



/* ===== модальное окно схемы связей ===== */
#schemeModal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: none; /* скрыто по умолчанию */
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#schemeModal.active {
  display: flex !important; /* показать как flex-контейнер */
}

#schemeModal .modal-content {
  background: #fff;
  border-radius: 4px;
  padding: 16px 24px;
  width: auto;
  min-width: 400px;
  max-width: 90vw;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  display: inline-block;
}

#schemeModal .link-btn {
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 4px;
  background: #f9f9f9;
  cursor: pointer;
  transition: all 0.2s;
}

#schemeModal .link-btn.selected {
  background: #dbeafe;
  border-color: #f1f1f1;
}

#schemeModal img {
  width: 70px;
  height: auto;
}




/* --- выравнивание кнопок фронта и зада кнопок в строку --- */
#frontLinks,
#backLinks {
  display: flex;
  flex-direction: row;      /* выстраиваем в ряд */
  justify-content: center;  /* по центру окна */
  align-items: center;
  flex-wrap: nowrap;        /* не переносить на новую строку */
  gap: 5px;                /* расстояние между кнопками */
  margin-bottom: 4px;
}

/* --- сами кнопки --- */

/* наведение и выбор */
#schemeModal .link-btn:hover {
  background: #f0f8ff;
  border-color: #60a5fa;
  transform: scale(1.02);
}

#schemeModal .link-btn.selected {
  border-color: #2563eb;
  background: #dbeafe;
  transform: scale(1.03);
}

/* === SVG внутри кнопок === */
#schemeModal .link-btn svg {
  width: 80%;               /* оставляем ~5% по краям */
  height: 80%;
  display: block;
  transform: scale(1.2);    /* базовое увеличение ×1.2 */
  transform-origin: center center;
  transition: transform 0.25s ease;
  box-sizing: border-box;
}

/* при наведении или выборе SVG немного «дышит», но остаётся в границах */
#schemeModal .link-btn:hover svg,
#schemeModal .link-btn.selected svg {
  transform: scale(1.1);
}

/* === кнопки схемы связей === */
#schemeModal .link-btn {
  width: 100px;             /* пропорция 1:3, но чуть компактнее */
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 2px solid #ccc;
  border-radius: 5px;
  padding: 0;
  cursor: pointer;
  transition: all 0.25s ease;
  box-sizing: border-box;
  overflow: hidden;         /* SVG не вылезает за рамку */
}


/* === средняя зона модального окна (мини-схема) === */
#comboLinks {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 6px 0;
  width: 100%;
  min-height: 160px;          /* 👈 фиксируем минимальную высоту */
  transition: none !important;/* чтобы не было плавных подёргиваний */
  overflow: hidden;           /* предотвращает скачки из-за перерисовки */
  box-sizing: border-box;
}

/* сама комбинация — растягивается на всю ширину ряда */
#comboLinks .combo-btn {
  flex: 1;
  max-width: 85%;              /* чтобы оставить немного "воздуха" по краям */
  aspect-ratio: 2 / 1;         /* пропорции 2:1 */
  border: 2px dashed #2563eb;
  border-radius: 12px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 8px;
  overflow: hidden;
}

/* содержимое внутри — две SVG и знак + */
#comboLinks .combo-btn > div:first-child {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#comboLinks .combo-btn img {
  height: 70px;
  width: auto;
  flex-shrink: 0;
}

#comboLinks .combo-btn span {
  font-weight: bold;
  color: #2563eb;
  font-size: 20px;
}

#comboLinks .combo-btn > div:last-child {
  text-align: center;
  font-size: 14px;
  margin-top: 4px;
  color: #1e293b;
}

/* три ряда внутри модалки — одинаковые поля по ширине */
#frontLinks,
#comboLinks,
#backLinks {
  display: flex;
  justify-content: space-between;  /* края совпадут */
  align-items: center;
  gap: 5px;
  padding: 0;                      /* без лишних внутренних отступов */
  width: 100%;
}

/* контейнер с объединённой схемой */
#comboLinks .combo-canvas {
  flex: 1;
  width: 80%;
  aspect-ratio: 3 / 1;        /* пропорции мини-схемы */
  border: 1px solid  #000;
  border-radius: 4px;
  background: #f8fafc;
  position: relative;
  overflow: hidden;
}

/* внутренняя SVG занимает почти всё, остаётся «воздух» 6px */
#comboLinks .combo-canvas svg {
  position: absolute;
  inset: 6px;                      /* по 6px отступа со всех сторон */
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  display: block;
  preserveAspectRatio: xMidYMid meet;
}

/* Мини-схема под кнопкой "Схема связей" */
#currentLinkScheme {
  margin-top: 6px;
  background: #fff;
  width: 180px;
  aspect-ratio: 3 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px;                  /* 👈 равные отступы со всех сторон */
  border-radius: 2px;            /* 👈 лёгкое скругление углов */
  box-sizing: border-box;        /* чтобы padding не влиял на общую ширину */
}

#currentLinkScheme svg {
  width: 100%;
  height: 100%;
  display: block;
}


/* ===== оформление внутренней структуры модалки ===== */

/* Центрируем заголовок */
#schemeModal .modal-title,
#schemeModal h2 {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Контейнер для всех трёх рядов (фронт, комбо, бэк) */
/* Контейнер с тремя рядами (фронт, комбо, бэк) */
#schemeModal .scheme-container {
  border: 1px solid #000;
  border-radius: 4px;
  padding: 8px 10px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 auto 20px auto;
  width: 100%;
  box-sizing: border-box;
}

/* Выравнивание кнопок под схемой */
#schemeModal .buttons-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

/* Кнопки внутри модалки */
#schemeModal .buttons-row button {
  padding: 5px 12px;
  border: 1px solid #000;
  border-radius: 4px;
  background: #f1f5f9;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

#schemeModal .buttons-row button:hover {
  background: #e2e8f0;
}

#schemeModal .buttons-row button:active {
  background: #cbd5e1;
}


/* ===== МОДАЛЬНОЕ ОКНО СХЕМЫ СВЯЗЕЙ (в стиле калькулятора) ===== */
#schemeModal {
  position: fixed;
  inset: 0;
  background: rgba(107, 142, 168, 0.35); /* полупрозрачный фон в цвет темы */
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#schemeModal.active {
  display: flex !important;
}

#schemeModal .modal-content {
  background: #f8fafc;               /* фон как у основного контейнера */
  border: 1px solid #cfd6e0;         /* стандартная рамка */
  border-radius: 8px;
  padding: 24px 28px;
  width: 480px;
  max-width: 90vw;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  position: relative;
  box-sizing: border-box;
}

/* --- крестик закрытия --- */
#schemeModal .close-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 22px;
  color: #003366;
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
  line-height: 30px;        /* 👈 теперь точно центрирует символ */
  text-align: center;       /* выравнивает по горизонтали */
}
#schemeModal .close-btn:hover {
  color: #000;
  transform: scale(1.15);
}
#schemeModal .close-btn:active {
  color: #555;
  transform: scale(0.95);
}

/* --- заголовок --- */
#schemeModal .modal-title,
#schemeModal h2 {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: #003366;
  margin: 0 0 14px;
  border-bottom: 1px solid #d1dae4;
  padding-bottom: 8px;
  text-transform: uppercase;
}

/* --- общий контейнер схем --- */
#schemeModal .scheme-container {
  background: #ffffff;
  border: 1px solid #dce3ec;
  border-radius: 6px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* --- кнопки схем (фронт, зад, комбо) --- */
#schemeModal .link-btn {
  width: 100px;
  height: 50px;
  border: 1px solid #cfd6e0;
  border-radius: 4px;
  background: #f8fafc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
#schemeModal .link-btn:hover {
  background: #e6edf7;
  border-color: #b6c4d7;
}
#schemeModal .link-btn.selected {
  background: #dbeafe;
  border-color: #2563eb;
}

/* --- SVG внутри кнопок --- */
#schemeModal .link-btn svg {
  width: 80%;
  height: 80%;
  stroke: #003366;
  transition: transform 0.25s ease;
}
#schemeModal .link-btn:hover svg,
#schemeModal .link-btn.selected svg {
  transform: scale(1.05);
  stroke: #111;
}

/* --- зона комбинации --- */
#comboLinks .combo-btn {
  border: 1px dashed #b6c4d7;
  background: #f8fafc;
  border-radius: 6px;
  padding: 10px;
}

/* --- нижний ряд кнопок --- */
#schemeModal .buttons-row {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

#schemeModal .buttons-row button {
  background: linear-gradient(to bottom, #f3f6fa, #e0e7ef);
  border: 1px solid #b6c4d7;
  border-radius: 6px;
  padding: 8px 24px;
  color: #003366;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}
#schemeModal .buttons-row button:hover {
  background: linear-gradient(to bottom, #e6edf7, #d3dfef);
  transform: translateY(-2px);
}
#schemeModal .buttons-row button:active {
  background: #cbd5e1;
  transform: translateY(1px);
}


/* === Кнопка "Закрыть" (крестик в правом верхнем углу модалки) === */
#schemeModal .close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 6px;
  display: flex;
  align-items: center;        /* центрирование по вертикали */
  justify-content: center;    /* центрирование по горизонтали */
  cursor: pointer;
  transition: all 0.25s ease;
}

/* SVG-крестик */
#schemeModal .close-btn svg {
  width: 16px;
  height: 16px;
  stroke: #003366;            /* фирменный синий */
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke 0.2s ease, transform 0.2s ease;
}

/* Наведение */
#schemeModal .close-btn:hover {
  background: #e8edf5;        /* светло-голубой фон */
  transform: scale(1.05);
}

#schemeModal .close-btn:hover svg {
  stroke: #000;
  transform: scale(1.1);
}

/* Нажатие */
#schemeModal .close-btn:active {
  background: #d0d8e4;
  transform: scale(0.95);
}

#schemeModal .close-btn:active svg {
  stroke: #222;
}

#schemeModal svg {
  display: block;
  margin: auto;
  vertical-align: middle;
  preserveAspectRatio: xMidYMid meet;
}


</style>