/* Боковая панель действий и общее окно заявки (G1).
   Три действия: наверх, поделиться, связаться. Панель не перекрывает ни
   полосу согласия, ни кнопки формы: когда полоса согласия видна, панель
   поднимается над ней. */
.trd-rail {
  position: fixed; right: 16px; z-index: 880;
  bottom: calc(16px + var(--trd-rail-lift, 0px) + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 10px; align-items: center;
  transition: bottom .2s ease;
}
.trd-rail__btn {
  width: 48px; height: 48px; padding: 0; border: 1px solid #e0ddd6; border-radius: 50%;
  background: #fff; color: #222; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
}
.trd-rail__btn:hover, .trd-rail__btn:focus-visible { border-color: #004d32; color: #004d32; }
.trd-rail__btn svg { width: 20px; height: 20px; display: block; }
.trd-rail__btn--contact {
  width: 56px; height: 56px; background: #004d32; color: #fff; border-color: #004d32;
}
.trd-rail__btn--contact:hover, .trd-rail__btn--contact:focus-visible { color: #fff; opacity: .92; }
.trd-rail__btn--top[hidden] { display: none; }

/* Панель выбора способа связи. На широком экране встаёт слева от кнопок,
   а не над ними: иначе она накрывала собой «поделиться» и «наверх». */
.trd-rail__panel {
  position: fixed; right: 76px; z-index: 881;
  bottom: calc(16px + var(--trd-rail-lift, 0px) + env(safe-area-inset-bottom, 0px));
  width: 264px; max-width: calc(100vw - 108px);
  background: #fff; border: 1px solid #e0ddd6; border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .16);
  padding: 16px;
}
.trd-rail__panel[hidden] { display: none; }
.trd-rail__title { margin: 0 0 12px; font-size: 15px; font-weight: 600; color: #222; }
.trd-rail__choice {
  display: flex; align-items: center; gap: 10px;
  width: 100%; box-sizing: border-box;
  padding: 11px 14px; margin-bottom: 8px; border: 1px solid #e0ddd6; border-radius: 8px;
  background: #fff; color: #222; font: inherit; font-size: 15px; text-align: left;
  text-decoration: none; cursor: pointer;
}
.trd-rail__choice:last-child { margin-bottom: 0; }
.trd-rail__choice:hover, .trd-rail__choice:focus-visible { border-color: #004d32; color: #004d32; }
.trd-rail__choice svg { width: 18px; height: 18px; flex: 0 0 auto; }

/* Всплывающая подпись о скопированной ссылке */
.trd-toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + var(--trd-rail-lift, 0px) + env(safe-area-inset-bottom, 0px));
  z-index: 900; padding: 10px 18px; border-radius: 8px;
  background: #222; color: #fff; font-size: 14px;
}
.trd-toast[hidden] { display: none; }

/* Общее окно заявки */
.trd-modal { position: fixed; inset: 0; z-index: 950; display: flex; align-items: center; justify-content: center; }
.trd-modal[hidden] { display: none; }
.trd-modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); }
.trd-modal__box {
  position: relative; z-index: 1;
  width: 640px; max-width: calc(100vw - 32px); max-height: calc(100vh - 48px);
  overflow-y: auto; box-sizing: border-box;
  background: #fff; border-radius: 12px; padding: 28px 28px 24px;
}
.trd-modal__title { margin: 0 0 20px; font-size: 24px; font-weight: 600; color: #222; }
.trd-modal__close {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px;
  border: 0; background: none; cursor: pointer;
}
.trd-modal__close::before, .trd-modal__close::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 18px; height: 2px;
  background: #222; transform-origin: center;
}
.trd-modal__close::before { transform: translate(-50%, -50%) rotate(45deg); }
.trd-modal__close::after { transform: translate(-50%, -50%) rotate(-45deg); }

@media screen and (max-width: 640px) {
  .trd-rail { right: 12px; bottom: calc(12px + var(--trd-rail-lift, 0px) + env(safe-area-inset-bottom, 0px)); }
  .trd-rail__btn { width: 44px; height: 44px; }
  .trd-rail__btn--contact { width: 52px; height: 52px; }
  .trd-rail__panel { right: 12px; left: 12px; width: auto; max-width: none;
    bottom: calc(76px + var(--trd-rail-lift, 0px) + env(safe-area-inset-bottom, 0px)); }
  /* На узком экране панель шире кнопок и встаёт над ними: пока она открыта,
     «наверх» и «поделиться» прячем, иначе она их накрывает. Кнопка связи
     остаётся — ею панель и закрывают. */
  .trd-rail-open .trd-rail__btn--share,
  .trd-rail-open .trd-rail__btn--top { display: none; }
  .trd-modal__box { padding: 24px 18px 18px; max-height: calc(100vh - 24px); }
  .trd-modal__title { font-size: 20px; }
}
