.dialog:has(.auth-view) {
  width: min(460px, calc(100% - 24px));
  padding: 30px clamp(16px, 6vw, 32px) 20px;
  border-radius: 13px;
  background: #171020;
  color-scheme: dark;
}
.dialog:has(.auth-view) .dialog-close {
  top: 8px;
  right: 8px;
  background: transparent;
  border-color: transparent;
}
.dialog:has(.auth-view) .dialog-close:hover { background: var(--panel); border-color: var(--line); }
.auth-view { --auth-field: color-mix(in srgb, var(--panel) 80%, var(--accent)); --auth-outline: #82699a; }
.auth-header { display: grid; justify-items: center; gap: 16px; margin-bottom: 24px; text-align: center; }
.auth-brand { display: inline-flex; align-items: center; gap: 7px; font-size: 1rem; font-weight: 800; letter-spacing: -.03em; }
.auth-view .auth-header h2 { margin: 0; font-size: 1.375rem; text-wrap: balance; }
.auth-form { display: grid; gap: 12px; }
.auth-view .auth-field label, .auth-view .auth-otp-label { display: block; margin: 0 0 6px; }
.auth-view .auth-otp-label { margin: 0; }
.auth-view .auth-field input { display: block; min-height: 48px; border-color: var(--auth-outline); border-radius: 11px; background: var(--auth-field); }
.auth-view .auth-field input:focus { border-color: var(--accent); }
.auth-password { position: relative; }
.auth-view .auth-password input { padding-inline-end: 52px; }
.auth-eye {
  position: absolute;
  inset: 2px 2px 2px auto;
  display: grid;
  place-items: center;
  width: 44px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
}
.auth-eye:hover { color: var(--text); }
.auth-eye svg { width: 19px; height: 19px; }
.auth-eye[aria-pressed='false'] .auth-eye-slash { display: none; }
.auth-view .auth-primary, .auth-telegram { width: 100%; min-height: 48px; border-radius: 11px; text-align: center; }
.auth-view .auth-primary { margin-top: 6px; }
.auth-view :disabled { cursor: not-allowed; }
.auth-primary:disabled { opacity: .55; }
.auth-view :is(.auth-note, .auth-feedback) { margin: 0; font-size: .8125rem; }
.auth-view .auth-feedback { color: #ffb6c2; }
.auth-view #auth-email-availability:empty { display: none; }
.auth-view :is(.auth-feedback, #auth-otp-status):empty,
.auth-form[data-auth-verified] #auth-otp-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.auth-link {
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: .2em;
}
.auth-link:hover:not(:disabled) { color: var(--text); }
.auth-forgot { display: block; margin: 4px auto 0; font-size: .875rem; }
.auth-alternative { display: flex; align-items: center; gap: 12px; margin: 8px 0 12px; color: var(--muted); font-size: .8125rem; }
.auth-alternative::before, .auth-alternative::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.auth-telegram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--auth-outline);
  background: var(--auth-field);
  color: var(--text);
  font-size: .875rem;
  font-weight: 750;
}
.auth-telegram[href]:hover { border-color: var(--accent); }
.auth-telegram:disabled { color: var(--muted); }
.auth-telegram svg { flex: none; width: 22px; height: 22px; }
.auth-telegram + .auth-note { margin-top: 6px; text-align: center; }
.auth-view .auth-switch { margin: 6px 0 0; color: var(--muted); text-align: center; }
.auth-view .auth-instructions { margin: 0 0 16px; text-align: center; overflow-wrap: anywhere; }
.auth-verify-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 12px; font-size: .875rem; }
.auth-verify-actions button:disabled { opacity: .55; }

.auth-otp { position: relative; width: min(328px, 100%); margin-inline: auto; }
.auth-otp-slots { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.auth-otp-slot {
  position: relative;
  display: grid;
  min-height: 52px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--auth-outline);
  border-radius: 13px;
  background: var(--auth-field);
  font-size: 1.375rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.auth-otp-slot[data-active] { border-color: var(--primary); background: color-mix(in srgb, var(--auth-field) 74%, var(--accent)); box-shadow: inset 0 0 0 1px var(--primary); }
.auth-otp-caret { position: absolute; width: 2px; height: 18px; border-radius: 2px; background: var(--primary); }
.auth-view .auth-otp input {
  position: absolute;
  z-index: 1;
  inset: 0;
  height: 100%;
  padding: 0;
  opacity: 0;
}
.auth-otp:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 13px; }
.auth-otp:has(input[aria-invalid='true']) .auth-otp-slot { border-color: #ffb6c2; }
.auth-otp-confirmation {
  position: absolute;
  inset: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  visibility: hidden;
  border-radius: 13px;
  background: #a7efc1;
  color: #102c1b;
  font-size: .9375rem;
  font-weight: 800;
  text-align: center;
  pointer-events: none;
}
.auth-otp-confirmation svg { flex: none; width: 20px; height: 20px; }
.auth-otp-done, .auth-otp-done:has(input:focus-visible) { outline: none; }
.auth-otp-done .auth-otp-confirmation { visibility: visible; }
.auth-form[data-auth-verified] :is(.auth-primary, .auth-verify-actions) { visibility: hidden; }

@media (forced-colors: active) {
  .auth-otp-slot[data-active] { outline: 2px solid Highlight; outline-offset: -3px; }
  .auth-otp-caret { background: Highlight; }
  .auth-otp-confirmation { border: 1px solid CanvasText; }
}
