/* Mobile first. Base covers 320–374px. */
html:has(body.touch-auth) {
  font-size: 16px;
}

body.touch-auth {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: #1c2836;
  background: #f3f6fa;
  overflow-x: clip;
}

body.touch-auth > main {
  flex: 1 0 auto;
  display: flex;
  width: 100%;
}

.touch-main {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(16px + var(--keyboard-inset, 0px));
}

.touch-content {
  width: 100%;
}

footer.footer.touch-footer {
  position: static;
  bottom: auto;
  width: auto;
  height: auto;
  line-height: 1.4;
  white-space: normal;
  flex: 0 0 auto;
  background: transparent;
  border: 0 !important;
  font-size: 13px;
  text-align: center;
  padding: 4px 12px calc(10px + env(safe-area-inset-bottom));
}

.touch-footer-inner {
  max-width: 28rem;
  margin: 0 auto;
}

.auth-shell {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #e4ebf3;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(22, 42, 68, 0.06);
  padding: 20px 16px 18px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.auth-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: #1e4f8a;
}

.auth-mark .bi {
  font-size: 26px;
  line-height: 1;
}

.auth-system {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5c6b7c;
}

.auth-product {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 700;
}

.auth-aside-copy {
  display: none;
}

.auth-title {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
}

.auth-lead {
  margin: 0 0 18px;
  font-size: 16px;
  line-height: 1.45;
  color: #3e4d5f;
}

.auth-form,
.auth-author,
.auth-resend {
  margin: 0;
}

.auth-author + .auth-author {
  margin-top: 10px;
}

.auth-label {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 650;
}

.phone-field {
  display: flex;
  align-items: stretch;
  min-height: 60px;
  border: 1.5px solid #d5deea;
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.phone-field:focus-within {
  border-color: #1e4f8a;
  box-shadow: 0 0 0 4px rgba(30, 79, 138, 0.16);
}

.phone-icon {
  width: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  color: #1e4f8a;
}

.phone-icon .bi {
  font-size: 22px;
  line-height: 1;
}

.phone-code,
.phone-number {
  border: 0;
  outline: 0;
  background: transparent;
  color: #1c2836;
  box-shadow: none;
}

.auth-input {
  display: block;
  width: 100%;
  min-height: 60px;
  padding: 0 14px;
  border: 1.5px solid #d5deea;
  border-radius: 16px;
  background: #fff;
  color: #1c2836;
  font-size: 18px;
}

.auth-input:focus {
  border-color: #1e4f8a;
  outline: 0;
  box-shadow: 0 0 0 4px rgba(30, 79, 138, 0.16);
}

.phone-code {
  width: 92px;
  flex: 0 0 92px;
  min-height: 58px;
  padding: 0 8px 0 0;
  border-right: 1px solid #d5deea;
  font-size: 16px;
  font-weight: 650;
}

.phone-number,
.auth-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 58px;
  padding: 0 14px;
  font-size: 18px;
}

.phone-number::placeholder,
.auth-input::placeholder {
  color: #6b7a8c;
}

.auth-hint {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: #526277;
}

.auth-error,
.field-validation-error,
.validation-summary-errors {
  display: block;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #f0c2c2;
  border-left: 4px solid #b42318;
  border-radius: 12px;
  background: #fff6f6;
  color: #8f1d1d;
  font-size: 14px;
  line-height: 1.4;
}

.validation-summary-valid,
.field-validation-valid {
  display: none;
}

.validation-summary-errors ul {
  margin: 0;
  padding-left: 1.1rem;
}

.auth-status {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #c9daf2;
  border-left: 4px solid #1e4f8a;
  border-radius: 12px;
  background: #f4f8fd;
  color: #1e3a5f;
  font-size: 14px;
  line-height: 1.45;
}

.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  margin-top: 14px;
  scroll-margin-bottom: calc(20px + var(--keyboard-inset, 0px));
  padding: 12px 16px;
  border-radius: 14px;
  border: 1.5px solid transparent;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  touch-action: manipulation;
  transition: transform 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
}

.auth-btn:focus-visible,
.phone-code:focus-visible,
.phone-number:focus-visible,
.auth-input:focus-visible,
.otp-digit:focus-visible,
.auth-disclosure summary:focus-visible {
  outline: 3px solid #1e4f8a;
  outline-offset: 2px;
}

.auth-btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

.auth-btn:disabled,
.auth-btn.is-loading {
  cursor: default;
  opacity: 0.72;
}

.auth-btn-primary {
  color: #fff;
  background: #1e4f8a;
}

.auth-btn-primary:hover,
.auth-btn-primary:focus-visible {
  color: #fff;
  background: #183f6e;
}

.auth-btn-ghost {
  color: #1e4f8a;
  background: #fff;
  border-color: #c5d4e6;
}

.auth-btn-text {
  min-height: 48px;
  color: #1e4f8a;
  background: transparent;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-btn.is-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
}

.auth-split {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 2px;
  color: #6b7a8c;
  font-size: 13px;
}

.auth-split::before,
.auth-split::after {
  content: "";
  height: 1px;
  flex: 1;
  background: #e1e8f0;
}

.auth-disclosure {
  margin-top: 8px;
  border-top: 1px solid #e7eef5;
}

.auth-disclosure summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 15px;
  font-weight: 650;
  color: #1e4f8a;
  list-style: none;
}

.auth-disclosure summary::-webkit-details-marker {
  display: none;
}

.auth-disclosure .auth-label {
  margin-top: 12px;
}

.auth-disclosure summary::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.auth-disclosure[open] summary::before {
  transform: rotate(225deg) translate(-2px, -2px);
}

.auth-password-note {
  margin: 0;
  font-size: 14px;
  color: #526277;
}

.otp-phone {
  margin: 0 0 14px;
  font-size: 16px;
  line-height: 1.45;
}

.otp-phone strong {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.otp-timer {
  margin-bottom: 16px;
  text-align: center;
}

.otp-timer-label {
  font-size: 13px;
  color: #526277;
}

#otp-countdown {
  font-size: 32px;
  line-height: 1.2;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.otp-boxes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.otp-digit {
  width: 100%;
  height: 48px;
  min-width: 0;
  padding: 0;
  border: 1.5px solid #d5deea;
  border-radius: 12px;
  background: #fff;
  color: #1c2836;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  touch-action: manipulation;
}

.otp-digit:focus {
  border-color: #1e4f8a;
  box-shadow: 0 0 0 3px rgba(30, 79, 138, 0.16);
}

.otp-code-store {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-btn,
  .auth-btn.is-loading::before {
    animation: none;
    transition: none;
  }

  .auth-btn:active:not(:disabled) {
    transform: none;
  }
}

@media (max-height: 480px) and (orientation: landscape) {
  .touch-main {
    align-items: flex-start;
    padding-top: 8px;
  }

  .auth-shell {
    padding-top: 14px;
    padding-bottom: 12px;
  }

  .auth-brand,
  .auth-lead {
    margin-bottom: 8px;
  }

  .auth-title {
    font-size: 24px;
  }
}

@media (max-width: 374px) {
  .touch-main {
    padding-left: 8px;
    padding-right: 8px;
  }

  .auth-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .phone-field {
    flex-wrap: wrap;
    min-height: 0;
    overflow: visible;
  }

  .phone-icon {
    width: 44px;
    flex-basis: 44px;
    min-height: 48px;
  }

  .phone-code {
    width: auto;
    flex: 1 1 auto;
    min-height: 48px;
    border-right: 0;
    border-bottom: 1px solid #d5deea;
  }

  .phone-number {
    flex: 1 0 100%;
    min-height: 60px;
  }

  .otp-boxes {
    gap: 4px;
  }
}

/* 375–575 */
@media (min-width: 375px) {
  .touch-main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .auth-shell {
    padding: 24px 18px 20px;
  }

  .otp-boxes {
    gap: 6px;
  }

  .otp-digit {
    height: 52px;
    font-size: 22px;
  }
}

/* 576–767 */
@media (min-width: 576px) {
  .touch-main {
    padding-top: calc(28px + env(safe-area-inset-top));
    padding-bottom: 28px;
  }

  .auth-shell {
    max-width: 440px;
    padding: 28px 24px 24px;
  }

  .phone-number,
  .auth-input {
    font-size: 20px;
  }

  .auth-btn {
    min-height: 58px;
    font-size: 18px;
  }

  .otp-digit {
    height: 58px;
  }
}

/* 768–991 tablet */
@media (min-width: 768px) {
  body.touch-auth {
    background:
      radial-gradient(820px 360px at 50% -80px, rgba(30, 79, 138, 0.09), transparent 70%),
      #eef3f8;
  }

  .auth-shell {
    max-width: 460px;
    border-radius: 22px;
  }
}

/* 992–1199 large tablet */
@media (min-width: 992px) {
  .auth-shell {
    max-width: 480px;
    padding: 32px 28px 26px;
  }
}

/* 1200+ desktop */
@media (min-width: 1200px) {
  .touch-main {
    padding-top: 40px;
    padding-bottom: 40px;
  }

  .auth-shell {
    display: grid;
    grid-template-columns: minmax(240px, 340px) 440px;
    gap: 48px;
    align-items: center;
    max-width: 920px;
    padding: 12px;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .auth-aside-copy {
    display: block;
    margin: 14px 0 0;
    max-width: 32ch;
    font-size: 17px;
    line-height: 1.5;
    color: #3e4d5f;
  }

  .auth-card {
    background: #fff;
    border: 1px solid #e4ebf3;
    border-radius: 20px;
    box-shadow: 0 14px 36px rgba(22, 42, 68, 0.07);
    padding: 32px 28px 26px;
  }
}
