/* Mobile-native beta signup modal overrides. Loaded after per-page inline CSS. */
.beta-modal-overlay {
  overflow: hidden;
  overscroll-behavior: contain;
}

.beta-modal {
  display: flex;
  flex-direction: column;
  max-height: calc(var(--signup-viewport-height, 100dvh) - 2rem);
  overflow: hidden;
}

.beta-modal-form {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.15rem;
  scroll-padding-bottom: 5.25rem;
  -webkit-overflow-scrolling: touch;
}

.beta-modal-close {
  z-index: 3;
}

.beta-extra-scroll-cue {
  display: none;
}

@media (max-width: 700px), (pointer: coarse) and (max-height: 900px) {
  .beta-modal-overlay {
    align-items: flex-end;
    justify-content: center;
    inset: auto 0 auto 0;
    top: var(--signup-viewport-top, 0px);
    height: var(--signup-viewport-height, 100dvh);
    padding: max(env(safe-area-inset-top), 8px) 0 0;
  }

  .beta-modal {
    width: 100%;
    max-width: none;
    max-height: calc(var(--signup-viewport-height, 100dvh) - max(env(safe-area-inset-top), 8px));
    border-radius: 24px 24px 0 0;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
    box-shadow: 0 -18px 55px rgba(35, 25, 70, 0.22);
  }

  .beta-modal-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    margin-bottom: 0.7rem;
  }

  .beta-modal-title {
    font-size: 1.28rem;
    margin-bottom: 0.22rem;
  }

  .beta-modal-sub {
    font-size: 0.88rem;
    margin-bottom: 0.9rem;
    line-height: 1.42;
  }

  .beta-modal-form {
    gap: 0.7rem;
    padding: 0 0.12rem 0.15rem 0;
  }

  .beta-email-input,
  .beta-lang-select,
  .beta-other-language-input {
    min-height: 48px;
    font-size: 16px;
  }

  .beta-extra-languages {
    max-height: min(34vh, 220px);
    max-height: min(34dvh, 220px);
    overflow-y: auto;
    position: relative;
    scrollbar-color: rgba(141, 105, 255, 0.65) rgba(141, 105, 255, 0.12);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .beta-extra-languages::-webkit-scrollbar {
    width: 6px;
  }

  .beta-extra-languages::-webkit-scrollbar-track {
    background: rgba(141, 105, 255, 0.1);
    border-radius: 999px;
  }

  .beta-extra-languages::-webkit-scrollbar-thumb {
    background: rgba(141, 105, 255, 0.68);
    border-radius: 999px;
  }

  .beta-extra-languages.is-scrollable:not(.is-at-bottom) {
    box-shadow: inset 0 -34px 24px -22px rgba(91, 76, 138, 0.65);
  }

  .beta-extra-languages.is-scrollable:not(.is-at-bottom) .beta-language-chip-grid {
    padding-bottom: 1.9rem;
  }

  .beta-extra-scroll-cue {
    display: none;
    align-items: center;
    justify-content: center;
    align-self: center;
    min-height: 1.6rem;
    margin: -2.25rem auto 0.2rem;
    padding: 0.32rem 0.62rem;
    border-radius: 999px;
    background: rgba(42, 37, 51, 0.9);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.01em;
    line-height: 1;
    pointer-events: none;
    position: relative;
    z-index: 4;
    box-shadow: 0 8px 18px rgba(35, 25, 70, 0.2);
  }

  .beta-extra-scroll-cue::after {
    content: "";
    width: 0;
    height: 0;
    margin-left: 0.38rem;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
  }

  .beta-extra-languages.is-scrollable:not(.is-at-bottom) + .beta-extra-scroll-cue {
    display: inline-flex;
  }

  .beta-language-chip-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .beta-language-chip {
    width: 100%;
    min-height: 38px;
    border-radius: 12px;
    justify-content: flex-start;
    line-height: 1.2;
  }

  .beta-email-consent {
    font-size: 0.76rem;
  }

  .beta-submit-btn {
    position: sticky;
    bottom: 0;
    z-index: 2;
    min-height: 50px;
    box-shadow: 0 -10px 18px rgba(255, 255, 255, 0.94);
  }

  .beta-success {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@supports not (height: 100dvh) {
  .beta-modal {
    max-height: calc(var(--signup-viewport-height, 100vh) - 2rem);
  }

  @media (max-width: 700px), (pointer: coarse) and (max-height: 900px) {
    .beta-modal-overlay {
      height: var(--signup-viewport-height, 100vh);
    }

    .beta-modal {
      max-height: calc(var(--signup-viewport-height, 100vh) - max(env(safe-area-inset-top), 8px));
    }
  }
}
