.modal-root {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: block;
}

.modal-root[hidden] {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(5, 33, 69, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(calc(8px * var(--scale)), var(--safe-top))
    max(calc(8px * var(--scale)), var(--safe-right))
    max(calc(8px * var(--scale)), var(--safe-bottom))
    max(calc(8px * var(--scale)), var(--safe-left));
  overflow: hidden;
  overscroll-behavior: none;
}

.modal {
  width: 100%;
  max-width: calc(512px * var(--scale));
  background: #fff;
  border-radius: var(--radius-lg);
  padding: calc(28px * var(--scale)) calc(20px * var(--scale)) calc(24px * var(--scale));
  box-shadow: var(--shadow-modal);
  position: relative;
  color: var(--color-navy);
  margin: auto;
  max-height: calc(100vh - var(--safe-top) - var(--safe-bottom) - calc(16px * var(--scale)));
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - calc(16px * var(--scale)));
  overflow: visible;
  animation: obBkIn 0.45s var(--ease-out) both;
}

.modal--sm {
  max-width: calc(440px * var(--scale));
  padding: calc(36px * var(--scale)) clamp(calc(20px * var(--scale)), 5vw, calc(32px * var(--scale))) calc(28px * var(--scale));
}

.modal__close {
  position: absolute;
  top: calc(16px * var(--scale));
  right: calc(16px * var(--scale));
  z-index: 4;
  width: calc(32px * var(--scale));
  height: calc(32px * var(--scale));
  border: 0;
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-navy);
  font-size: calc(18px * var(--scale));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__close:hover,
.modal__close:focus,
.modal__close:focus-visible {
  outline: none;
  background: var(--color-surface);
}

.modal__pill {
  display: inline-block;
  border: 1px solid var(--color-navy);
  border-radius: var(--radius-pill);
  padding: calc(5px * var(--scale)) calc(11px * var(--scale));
  font-size: calc(12px * var(--scale));
}

.modal__step {
  font-size: calc(13px * var(--scale));
  color: var(--color-text-soft);
  margin-bottom: calc(8px * var(--scale));
}

.bk-branch {
  margin-top: calc(16px * var(--scale));
}

.bk-branch__label {
  margin-top: calc(12px * var(--scale));
}

.bk-branch__select {
  width: 100%;
  height: calc(54px * var(--scale));
  padding: 0 calc(16px * var(--scale));
  border: 1px solid #eef0f3;
  border-radius: calc(8px * var(--scale));
  background: #fff;
  font-family: inherit;
  font-size: calc(19px * var(--scale));
  color: #052145;
}

.modal__title {
  margin: calc(8px * var(--scale)) 0 0;
  font-size: clamp(calc(24px * var(--scale)), 5vw, calc(28px * var(--scale)));
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: calc(-0.3px * var(--scale));
}

.modal__title .accent {
  color: var(--link);
}

.modal__lead {
  margin: calc(12px * var(--scale)) 0 0;
  color: var(--color-text-muted);
  font-size: calc(15px * var(--scale));
  line-height: 1.45;
}

.bk-modal .modal__lead {
  color: var(--color-text-soft);
  line-height: 1.5;
}

.modal__body {
  margin-top: calc(24px * var(--scale));
}

.modal__actions {
  margin-top: calc(16px * var(--scale));
}

.modal__hint {
  margin-top: calc(12px * var(--scale));
  text-align: center;
  font-size: calc(12px * var(--scale));
  color: var(--color-text-muted);
}

.modal__success {
  text-align: center;
  padding: calc(24px * var(--scale)) 0 calc(4px * var(--scale));
}

.modal__success-icon {
  width: calc(76px * var(--scale));
  height: calc(76px * var(--scale));
  margin: 0 auto;
  border-radius: 50%;
  background: var(--color-navy);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stars {
  display: flex;
  gap: calc(6px * var(--scale));
  margin-top: calc(8px * var(--scale));
}

.stars button {
  border: 0;
  background: transparent;
  padding: 0;
  line-height: 0;
  cursor: pointer;
}

.stars path {
  fill: #e8ebf0;
  stroke: #e8ebf0;
}

.stars button.is-on path {
  fill: var(--color-accent);
  stroke: var(--color-accent);
}

.fix-widget {
  position: fixed;
  right: calc(16px * var(--scale));
  bottom: calc(calc(16px * var(--scale)) + var(--safe-bottom));
  z-index: 80;
  max-width: min(calc(360px * var(--scale)), calc(100vw - calc(32px * var(--scale))));
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  padding: calc(14px * var(--scale)) calc(16px * var(--scale));
  display: none;
  animation: obFwIn 0.4s var(--ease-out) both;
}

.fix-widget.is-visible {
  display: block;
}

.bk-calc {
  margin-top: calc(24px * var(--scale));
  display: flex;
  flex-direction: column;
  gap: calc(8px * var(--scale));
}

.bk-label {
  font-size: calc(13px * var(--scale));
  color: var(--color-text-soft);
  margin-bottom: calc(8px * var(--scale));
}

.modal .form input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
.modal .form select,
.modal .form textarea {
  font-size: calc(19px * var(--scale));
}

.bk-modal .field-row input {
  font-size: calc(20px * var(--scale));
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
}

.bk-receive {
  background: #f9fafb;
}

.bk-swap {
  align-self: center;
  margin: calc(-4px * var(--scale)) 0 calc(-18px * var(--scale));
  position: relative;
  z-index: 2;
  width: calc(36px * var(--scale));
  height: calc(36px * var(--scale));
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.3s;
}

.bk-swap:hover {
  transform: rotate(180deg);
}

.bk-rate {
  margin-top: calc(4px * var(--scale));
  font-size: calc(13px * var(--scale));
  color: var(--color-text-soft);
  font-variant-numeric: tabular-nums;
}

.bk-addr {
  margin-top: calc(16px * var(--scale));
  display: flex;
  align-items: center;
  gap: calc(10px * var(--scale));
  font-size: calc(14px * var(--scale));
}

.bk-fix {
  margin-top: calc(24px * var(--scale));
  height: calc(54px * var(--scale));
  min-height: calc(54px * var(--scale));
  border-radius: calc(8px * var(--scale));
  font-size: calc(17px * var(--scale));
}

.bk-modal .btn.btn--accent.bk-fix:disabled,
.bk-modal .btn.btn--accent.bk-fix.is-off {
  background: #d5d9df;
  opacity: 1;
  cursor: default;
}

.bk-summary {
  margin: calc(4px * var(--scale)) 0 0;
  font-size: calc(18px * var(--scale));
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  color: var(--color-navy);
  font-variant-numeric: tabular-nums;
}

.bk-summary[hidden] {
  display: none;
}

.bk-contacts {
  margin-top: calc(16px * var(--scale));
  display: flex;
  flex-direction: column;
  gap: calc(12px * var(--scale));
}

.bk-contact {
  display: flex;
  align-items: center;
  gap: calc(16px * var(--scale));
  min-height: calc(72px * var(--scale));
  padding: calc(14px * var(--scale)) calc(16px * var(--scale));
  border: 1px solid var(--color-border);
  border-radius: calc(8px * var(--scale));
  color: var(--color-navy);
  transition: border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.bk-contact:hover {
  border-color: var(--color-accent);
  color: var(--color-navy);
}

.bk-contact__icon {
  flex: none;
  width: calc(44px * var(--scale));
  height: calc(44px * var(--scale));
  border-radius: 50%;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.bk-contact__copy {
  flex: 1;
  min-width: 0;
}

.bk-contact__title {
  display: block;
  font-size: calc(17px * var(--scale));
  font-weight: 600;
}

.bk-contact__meta {
  display: block;
  margin-top: 2px;
  font-size: calc(14px * var(--scale));
  color: var(--color-text-soft);
}

.bk-foot {
  margin-top: calc(20px * var(--scale));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: calc(12px * var(--scale));
  font-size: calc(13px * var(--scale));
  color: var(--color-text-soft);
}

.bk-back {
  border: 0;
  background: transparent;
  padding: 0;
  font-family: inherit;
  font-size: calc(13px * var(--scale));
  color: var(--link);
  cursor: pointer;
  touch-action: manipulation;
}

.bk-hours {
  font-size: calc(12px * var(--scale));
  line-height: 1.2;
}

.bk-modal .currency-menu {
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
  .bk-modal {
    max-width: 100%;
    padding: calc(32px * var(--scale)) calc(20px * var(--scale)) calc(24px * var(--scale));
  }

  .bk-foot {
    flex-wrap: wrap;
  }
}

@media (min-width: 768px) {
  .modal {
    padding: calc(36px * var(--scale)) calc(32px * var(--scale)) calc(28px * var(--scale));
  }

  .fix-widget {
    right: calc(28px * var(--scale));
    bottom: calc(28px * var(--scale));
  }
}
