.auth-gate,
.auth-gate * {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.auth-gate::-webkit-scrollbar,
.auth-gate *::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
  background: transparent;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 260;
  background: rgba(8, 14, 26, 0.52);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.auth-gate.is-open {
  display: flex;
}

.app-boot-overlay {
  --app-boot-progress: 0%;
  position: fixed;
  inset: 0;
  z-index: 280;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(24px, var(--safe-top)) max(24px, var(--safe-right)) max(24px, var(--safe-bottom)) max(24px, var(--safe-left));
  background:
    radial-gradient(circle at 50% 31%, rgba(255, 194, 55, 0.28), transparent 26%),
    radial-gradient(circle at 21% 72%, rgba(35, 130, 240, 0.16), transparent 24%),
    radial-gradient(circle at 79% 72%, rgba(139, 222, 58, 0.16), transparent 24%),
    linear-gradient(180deg, #fdfbf7 0%, #eef3f9 100%);
  opacity: 0;
  transition: opacity 240ms ease;
}

.app-boot-card {
  width: min(100%, 420px);
  display: grid;
  justify-items: center;
  gap: 16px;
  text-align: center;
}

.app-boot-logo-shell {
  position: relative;
  display: grid;
  place-items: center;
  width: min(56vw, 232px);
  aspect-ratio: 1;
}

.app-boot-logo-shell::before {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 204, 90, 0.48), rgba(255, 204, 90, 0.14) 44%, transparent 70%);
  filter: blur(16px);
}

.app-boot-logo {
  position: relative;
  width: 100%;
  border-radius: 26px;
  box-shadow: 0 24px 40px rgba(69, 92, 127, 0.2);
}

.app-boot-wordmark {
  position: relative;
  display: inline-grid;
  margin: 0;
  padding: 0 0.02em;
}

.app-boot-wordmark-base,
.app-boot-wordmark-fill {
  grid-area: 1 / 1;
  font-size: clamp(1.7rem, 7vw, 2.6rem);
  line-height: 1.04;
  letter-spacing: 0.1em;
}

.app-boot-wordmark-base {
  color: rgba(28, 48, 79, 0.18);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.62);
}

.app-boot-wordmark-fill {
  width: var(--app-boot-progress);
  overflow: hidden;
  white-space: nowrap;
  color: transparent;
  background: linear-gradient(90deg, #1978f3 0%, #61c0ff 30%, #88d742 62%, #ffb320 100%);
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: none;
  transition: width 220ms ease;
}

.app-boot-help {
  margin: 0;
  max-width: 28ch;
  color: #51698a;
  font-size: 0.95rem;
  line-height: 1.5;
}

.app-boot-progress {
  position: relative;
  width: min(100%, 246px);
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(97, 124, 166, 0.16);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.78),
    0 10px 20px rgba(102, 130, 171, 0.12);
}

.app-boot-progress-bar {
  display: block;
  position: relative;
  width: var(--app-boot-progress);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1978f3 0%, #61c0ff 30%, #88d742 62%, #ffb320 100%);
  transition: width 220ms ease;
}

.app-boot-progress-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.82) 48%, transparent 100%);
  transform: translateX(-120%);
  animation: app-boot-progress-glint 1.45s ease-in-out infinite;
}

body.app-booting .app-boot-overlay {
  display: flex;
  opacity: 1;
}

body.app-booting .app-boot-overlay.is-exiting {
  opacity: 0;
}

body.app-booting .auth-gate {
  display: none !important;
}

body.app-booting .app-shell,
body.app-booting .bottom-nav {
  visibility: hidden;
}

body.auth-open .bottom-nav {
  opacity: 0;
  pointer-events: none;
}

@keyframes app-boot-progress-glint {
  0% {
    transform: translateX(-140%);
  }
  100% {
    transform: translateX(180%);
  }
}

@media (max-height: 640px) {
  .app-boot-card {
    gap: 13px;
  }

  .app-boot-logo-shell {
    width: min(44vw, 180px);
  }

  .app-boot-help {
    font-size: 0.9rem;
  }
}

.auth-card {
  width: min(100%, 360px);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.94), rgba(243, 247, 253, 0.9));
  box-shadow: 0 22px 48px rgba(4, 11, 24, 0.32);
  padding: 18px;
  display: grid;
  gap: 12px;
}

.auth-card h2 {
  margin: 0;
  font-size: 1.44rem;
  color: #1b2b4f;
}

.auth-help {
  margin: 0;
  color: #4f6287;
  font-size: 0.92rem;
}

.auth-language-first {
  display: grid;
  gap: 9px;
  margin-bottom: 4px;
  padding: 11px;
  border-radius: 14px;
  border: 1px solid rgba(54, 87, 142, 0.18);
  background: rgba(246, 250, 255, 0.94);
}

.auth-language-first label {
  display: grid;
  gap: 5px;
  font-size: 0.82rem;
  color: #34527d;
}

.auth-language-first select {
  border-radius: 12px;
  border: 1px solid rgba(54, 87, 142, 0.22);
  padding: 10px 11px;
  font: inherit;
  color: #1a2b49;
  background: rgba(255, 255, 255, 0.96);
}

.auth-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.auth-switch[hidden] {
  display: none;
}

.auth-tab {
  border-radius: 999px;
  border: 1px solid rgba(54, 87, 142, 0.2);
  background: #eef3fb;
  color: #325689;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 530;
  padding: 9px 12px;
}

.auth-tab.is-active {
  border-color: rgba(47, 128, 237, 0.4);
  background: rgba(47, 128, 237, 0.14);
}

.auth-guest-btn {
  border: 1px solid rgba(54, 87, 142, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: #2d5b97;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 610;
  padding: 10px 12px;
  cursor: pointer;
}

.auth-guest-btn:hover,
.auth-guest-btn:focus-visible {
  border-color: rgba(47, 128, 237, 0.42);
  background: rgba(237, 245, 255, 0.96);
}

.auth-guest-hint {
  font-size: 0.78rem;
  line-height: 1.35;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form label {
  display: grid;
  gap: 5px;
  font-size: 0.84rem;
  color: #34527d;
}

.auth-form input,
.auth-form select,
.auth-form textarea {
  border-radius: 12px;
  border: 1px solid rgba(54, 87, 142, 0.22);
  padding: 10px 11px;
  font: inherit;
  color: #1a2b49;
  background: rgba(255, 255, 255, 0.96);
}

.auth-form textarea {
  resize: vertical;
}

.auth-age-block {
  border-radius: 14px;
  border: 1px solid rgba(54, 87, 142, 0.18);
  background: rgba(246, 250, 255, 0.92);
  padding: 9px 10px;
  display: grid;
  gap: 7px;
}

.auth-age-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: #355381;
  font-size: 0.78rem;
  font-weight: 590;
}

.auth-age-head strong {
  font-size: 1rem;
  color: #1f3f74;
}

.auth-age-block input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: #2f80ed;
}

.auth-age-hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: #486287;
}

.auth-avatar-block {
  border-radius: 14px;
  border: 1px solid rgba(54, 87, 142, 0.18);
  background: rgba(246, 250, 255, 0.92);
  padding: 9px;
  display: grid;
  gap: 8px;
}

.auth-avatar-label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 590;
  color: #355381;
}

.auth-avatar-picker {
  display: grid;
  gap: 8px;
}

.auth-avatar-auto-row {
  display: flex;
}

.auth-avatar-auto-btn {
  border-radius: 999px;
  border: 1px solid rgba(55, 87, 137, 0.24);
  background: rgba(255, 255, 255, 0.96);
  color: #315384;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 530;
  padding: 6px 10px;
}

.auth-avatar-auto-btn.is-selected {
  border-color: rgba(47, 128, 237, 0.42);
  background: rgba(47, 128, 237, 0.14);
  color: #214f8e;
}

.auth-avatar-group {
  display: grid;
  gap: 6px;
}

.auth-avatar-group-title {
  margin: 0;
  font-size: 0.69rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4b6389;
  font-weight: 590;
}

.auth-avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.auth-avatar-option {
  border-radius: 10px;
  border: 1px solid rgba(55, 87, 137, 0.2);
  background: rgba(255, 255, 255, 0.96);
  display: grid;
  place-items: center;
  padding: 4px;
}

.auth-avatar-option img {
  width: 44px;
  height: 44px;
  border-radius: 9px;
  display: block;
}

.auth-avatar-option.is-selected {
  border-color: rgba(47, 128, 237, 0.48);
  box-shadow: 0 0 0 2px rgba(47, 128, 237, 0.18);
}

.auth-avatar-hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: #486287;
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: #2e5388;
  font-size: 0.82rem;
}

.auth-secondary-link {
  color: #436ca7;
  font-size: 0.82rem;
  text-decoration: none;
  font-weight: 600;
}

.auth-secondary-link:hover,
.auth-secondary-link:focus-visible {
  text-decoration: underline;
}

.auth-message.is-error {
  color: #a93434;
}

.topbar-avatar-thumb {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
}

.settings-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  z-index: 10;
  border-radius: 14px;
  border: 1px solid rgba(47, 128, 237, 0.24);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 28px rgba(16, 33, 67, 0.16);
  padding: 8px;
  display: grid;
  gap: 6px;
}

.settings-menu-title {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 590;
  color: #4d6286;
  letter-spacing: 0;
  text-transform: none;
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(47, 128, 237, 0.1);
}

.settings-menu-link {
  width: 100%;
  border: 1px solid rgba(47, 128, 237, 0.18);
  border-radius: 10px;
  background: rgba(237, 245, 255, 0.76);
  color: #2b5ca5;
  font: inherit;
  font-size: 0.8rem;
  text-decoration: none;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.settings-menu-link.is-danger {
  color: #a13535;
  border-color: rgba(161, 53, 53, 0.2);
  background: rgba(247, 232, 232, 0.9);
}

.topbar-session-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

body.native-app .auth-gate,
body.compact-layout .auth-gate {
  align-items: flex-start;
  min-height: var(--app-viewport-height);
  height: var(--app-viewport-height);
  max-height: var(--app-viewport-height);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding:
    calc(12px + var(--screen-top-blocker))
    calc(12px + var(--safe-right))
    calc(12px + var(--safe-bottom) + var(--app-keyboard-inset))
    calc(12px + var(--safe-left));
}

body.native-app .auth-card,
body.compact-layout .auth-card {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  max-height: calc(var(--app-viewport-height) - var(--screen-top-blocker) - var(--safe-bottom) - 24px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(18px + var(--safe-bottom) + var(--app-keyboard-inset));
}

body.native-app #registerSubmitBtn,
body.native-app #churchBootstrapSubmitBtn,
body.compact-layout #registerSubmitBtn,
body.compact-layout #churchBootstrapSubmitBtn {
  position: sticky;
  bottom: calc(8px + var(--app-keyboard-inset));
  z-index: 2;
}

@media (max-width: 900px) {
  body:not(.native-app):not(.compact-layout) .auth-gate {
    align-items: flex-start;
    min-height: var(--app-viewport-height);
    height: var(--app-viewport-height);
    max-height: var(--app-viewport-height);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    padding:
      calc(12px + var(--screen-top-blocker))
      calc(12px + var(--safe-right))
      calc(12px + var(--safe-bottom) + var(--app-keyboard-inset))
      calc(12px + var(--safe-left));
  }

  body:not(.native-app):not(.compact-layout) .auth-card {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    max-height: calc(var(--app-viewport-height) - var(--screen-top-blocker) - var(--safe-bottom) - 24px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: calc(18px + var(--safe-bottom) + var(--app-keyboard-inset));
  }

  body:not(.native-app):not(.compact-layout) #registerSubmitBtn,
  body:not(.native-app):not(.compact-layout) #churchBootstrapSubmitBtn {
    position: sticky;
    bottom: calc(8px + var(--app-keyboard-inset));
    z-index: 2;
  }
}

@media (min-width: 901px) {
  body:not(.native-app):not(.compact-layout) .auth-gate {
    padding: 26px;
  }

  body:not(.native-app):not(.compact-layout) .auth-card {
    width: min(100%, 400px);
  }
}

@media (max-width: 640px) {
  .topbar-session-actions {
    justify-content: flex-start;
  }
}
