/* Log in / sign up dialog. Builds on styles.css (tokens, buttons, theme). */
.auth-modal { width: min(940px, calc(100vw - 24px)); max-height: calc(100svh - 24px); margin: auto; padding: 0; overflow: hidden; border: 0; border-radius: 28px; background: #fff; color: var(--ink); box-shadow: 0 60px 120px -40px rgba(6, 0, 60, .65), 0 0 0 1px rgba(6, 0, 60, .05); }
.auth-modal::backdrop { background: rgba(6, 0, 60, .45); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.auth-modal[open] { animation: auth-modal-in .35s cubic-bezier(.2, .8, .2, 1); }
.auth-modal[open]::backdrop { animation: auth-fade-in .25s ease; }
/* Entrances start from a visible state: if an animation ever stalls, the dialog is still usable. */
@keyframes auth-modal-in { from { opacity: .5; transform: translateY(18px) scale(.97); } }
@keyframes auth-fade-in { from { opacity: 0; } }
@keyframes auth-sheet-in { from { opacity: .6; transform: translateY(56px); } }
html:has(.auth-modal[open]) { overflow: hidden; }

.auth-shell { display: grid; grid-template-columns: minmax(0, 470px) minmax(0, 1fr); max-height: calc(100svh - 24px); }
.auth { display: flex; flex-direction: column; min-height: 600px; padding: 20px 32px 26px; overflow-y: auto; overscroll-behavior: contain; }
.auth [hidden] { display: none !important; }

/* ---------- Head, progress ---------- */
.auth__head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.auth__logo { width: 116px; height: 30px; color: #0057ce; }
.auth__close, .auth__back { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; color: #55555e; transition: background-color .15s, color .15s, transform .25s; }
.auth__close { margin-inline: auto -8px; }
.auth__back { margin-inline-start: -8px; }
.auth__close:hover, .auth__back:hover { background: #f1f4ff; color: var(--blue); }
.auth__close:hover { transform: rotate(90deg); }
.auth__close svg, .auth__back svg { width: 22px; height: 22px; }
.auth__progress { height: 4px; margin-bottom: 26px; overflow: hidden; border-radius: 4px; background: var(--line); }
.auth__progress i { display: block; width: 30%; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--blue), var(--teal)); transition: width .55s cubic-bezier(.2, .8, .2, 1); }

/* ---------- Steps ---------- */
.auth__flow { display: flex; flex: 1; flex-direction: column; }
.auth__step { display: flex; flex: 1; flex-direction: column; }
.auth__step.is-forward { animation: auth-step-forward .4s cubic-bezier(.2, .8, .2, 1) both; }
.auth__step.is-back { animation: auth-step-back .4s cubic-bezier(.2, .8, .2, 1) both; }
/* right-to-left: the next step arrives from the left, going back arrives from the right */
@keyframes auth-step-forward { from { opacity: .35; transform: translateX(-28px); } }
@keyframes auth-step-back { from { opacity: .35; transform: translateX(28px); } }
.auth h2 { font-size: 30px; font-weight: 800; line-height: 1.5; }
.auth__lead { margin: 4px 0 22px; font-size: 15px; color: #55555e; }
.auth__echo { font: 600 15px "DM Sans", sans-serif; color: var(--ink); white-space: nowrap; }

/* ---------- Fields ---------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.field__box { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px; border: 1.500px solid var(--line); border-radius: 14px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.field__box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 87, 206, .12); }
.field.has-error .field__box, .field.has-error .otp input { border-color: var(--red); }
.field__box input { flex: 1; min-width: 0; padding: 0; border: 0; outline: 0; background: none; text-align: left; font: 500 17px/1.5 "DM Sans", "Vazirmatn", sans-serif; color: inherit; }
.field input::placeholder { color: #b0b0ba; }
.field__box b { flex: none; font: 600 14px "DM Sans", sans-serif; color: var(--muted); }
.field__error { display: block; min-height: 20px; margin-top: 4px; font-size: 12px; color: var(--red); }
.field__eye { display: grid; place-items: center; width: 36px; height: 36px; flex: none; margin-inline-end: -8px; border-radius: 10px; color: var(--muted); }
.field__eye:hover { background: #f1f4ff; color: var(--blue); }
.field__eye svg { width: 20px; height: 20px; }
.auth__forgot { font-size: 13px; font-weight: 500; color: var(--blue); }

.strength { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.strength i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); transition: background-color .25s; }
.strength em { min-width: 44px; text-align: end; font-size: 12px; font-style: normal; color: var(--muted); }
.strength[data-score="1"] i:nth-child(-n+1) { background: var(--red); }
.strength[data-score="2"] i:nth-child(-n+2) { background: #f59e0b; }
.strength[data-score="3"] i:nth-child(-n+3) { background: #65b741; }
.strength[data-score="4"] i:nth-child(-n+4) { background: var(--green); }

.auth__ref { margin: -2px 0 12px; }
.auth__ref summary { width: fit-content; cursor: pointer; list-style: none; font-size: 14px; font-weight: 600; color: var(--blue); }
.auth__ref summary::-webkit-details-marker { display: none; }
.auth__ref summary::before { content: "+ "; }
.auth__ref[open] summary::before { content: "− "; }
.auth__ref .field { margin: 10px 0 0; }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; flex: none; margin-top: 4px; accent-color: var(--blue); }
.check a { color: var(--blue); }

.otp { display: flex; justify-content: center; gap: 10px; }
.otp input { width: 60px; height: 66px; padding: 0; border: 1.500px solid var(--line); border-radius: 14px; outline: 0; background: #fff; text-align: center; font: 700 24px/1 "DM Sans", sans-serif; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
.otp input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 87, 206, .12); }
.otp input.is-filled { border-color: var(--blue); transform: translateY(-2px); }
.otp.is-shaking { animation: auth-shake .45s ease; }
@keyframes auth-shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }

/* ---------- Buttons and notes ---------- */
.auth__submit { position: relative; width: 100%; height: 56px; margin-top: 4px; border-radius: 14px; font-size: 17px; }
.auth__submit span { transition: opacity .15s; }
.auth__submit.is-busy { pointer-events: none; }
.auth__submit.is-busy span { opacity: 0; }
.auth__submit.is-busy::after { content: ""; position: absolute; width: 22px; height: 22px; border: 2.500px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: auth-spin .7s linear infinite; }
@keyframes auth-spin { to { transform: rotate(360deg); } }
.auth__alt { width: 100%; height: 50px; margin-top: 10px; border: 1.500px solid var(--line); border-radius: 14px; font-size: 15px; font-weight: 600; transition: border-color .15s, color .15s; }
.auth__alt:hover { border-color: var(--blue); color: var(--blue); }
.linkish { font-size: inherit; font-weight: 600; color: var(--blue); }
.linkish:disabled { color: var(--muted); cursor: default; }
.auth__timer { margin-top: 12px; text-align: center; font-size: 14px; color: #55555e; }
.auth__clock { font: 600 14px "Vazirmatn", sans-serif; }
.auth__safe { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 16px; font-size: 12.500px; color: #0b6b3e; }
.auth__safe svg { width: 18px; height: 18px; flex: none; }
.auth__safe b { font: 600 12.500px "DM Sans", sans-serif; white-space: nowrap; }
.auth__demo { margin: 12px 0; padding: 10px 14px; border-radius: 12px; background: #fff6e0; color: #7a5200; text-align: center; font-size: 12.500px; line-height: 1.8; }
.auth__demo b { font: 600 13px "DM Sans", sans-serif; }
.auth__demo--pick { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin: auto 0 0; text-align: start; }
.auth__demo--pick .seg { padding: 3px; background: rgba(122, 82, 0, .12); }
.auth__demo--pick .seg button { height: 30px; padding: 0 12px; font-size: 13px; color: #7a5200; }
.auth__demo--pick .seg button.is-on { background: #fff; color: var(--ink); }

/* ---------- Done ---------- */
.auth__done { justify-content: center; text-align: center; }
.auth__tick { width: 84px; height: 84px; margin: 0 auto 18px; fill: none; stroke: var(--green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.auth__tick circle { stroke-dasharray: 151; stroke-dashoffset: 151; transform: rotate(-90deg); transform-origin: center; }
.auth__tick path { stroke-dasharray: 36; stroke-dashoffset: 36; }
.auth__done:not([hidden]) .auth__tick circle { animation: auth-draw .55s ease-out .1s forwards; }
.auth__done:not([hidden]) .auth__tick path { animation: auth-draw .35s ease-out .55s forwards; }
@keyframes auth-draw { to { stroke-dashoffset: 0; } }
.auth__done .auth__submit { margin-top: 8px; }

/* ---------- Brand pane ---------- */
.auth-side { position: relative; isolation: isolate; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; margin: 10px; padding: 26px; border-radius: 20px; color: #fff; background: radial-gradient(120% 110% at 25% 92%, var(--teal) 0, var(--blue) 58%, var(--indigo) 100%); }
.auth-side__pattern { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; opacity: .7; -webkit-mask-image: linear-gradient(200deg, #000 5%, transparent 65%); mask-image: linear-gradient(200deg, #000 5%, transparent 65%); }
.auth-side__card { padding: 14px 16px 8px; border: 1px solid rgba(255, 255, 255, .28); border-radius: 18px; background: rgba(255, 255, 255, .14); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); animation: floaty 6s ease-in-out infinite; }
.auth-side__card p { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: 13px; font-weight: 700; }
.auth-side__card em { padding: 1px 9px; border-radius: 999px; background: rgba(255, 255, 255, .2); font-size: 11px; font-style: normal; font-weight: 400; }
.auth-side__card li { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; }
.auth-side__card li + li { border-top: 1px solid rgba(255, 255, 255, .16); }
.auth-side__card li i { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; color: #fff; font: 700 13px/1 "DM Sans", sans-serif; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .28); }
.auth-side__card li b { font-weight: 700; }
.auth-side__card li span { margin-inline-start: auto; font-weight: 600; }
.auth-side__card li u { min-width: 50px; direction: ltr; text-align: left; font-size: 12px; font-weight: 600; text-decoration: none; color: rgba(255, 255, 255, .8); }
.auth-side__card li u.up { color: #b9ffd8; }
.auth-side__card li u.down { color: #ffc2c9; }
.auth-side__pitch h3 { font-size: 30px; font-weight: 800; line-height: 1.4; }
.auth-side__line { min-height: 28px; margin-top: 12px; font-size: 16px; font-weight: 500; opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .3s; }
.auth-side__line.is-in { opacity: 1; transform: none; }
.auth-side__dots { display: flex; gap: 6px; margin-top: 12px; }
.auth-side__dots i { width: 6px; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .4); transition: width .3s, background-color .3s; }
.auth-side__dots i.on { width: 22px; background: #fff; }

/* ---------- Dark theme ---------- */
[data-theme="dark"] .auth-modal { background: var(--d-surface); color: var(--d-text); box-shadow: 0 60px 120px -40px rgba(0, 0, 0, .9), 0 0 0 1px rgba(255, 255, 255, .1); }
[data-theme="dark"] .auth-modal::backdrop { background: rgba(0, 0, 0, .6); }
[data-theme="dark"] .auth__logo { color: #b1c5ff; }
[data-theme="dark"] :is(.auth__close, .auth__back) { color: #c9cdee; }
[data-theme="dark"] :is(.auth__close:hover, .auth__back:hover, .field__eye:hover) { background: var(--d-raised); color: #fff; }
[data-theme="dark"] :is(.auth__lead, .auth__timer) { color: var(--d-soft); }
[data-theme="dark"] .auth__echo { color: var(--d-text); }
[data-theme="dark"] :is(.field__box, .otp input) { background: var(--d-raised); }
[data-theme="dark"] :is(.field__box:focus-within, .otp input:focus, .otp input.is-filled) { border-color: var(--d-link); box-shadow: 0 0 0 4px rgba(177, 197, 255, .14); }
[data-theme="dark"] .field input::placeholder { color: #5d6390; }
[data-theme="dark"] :is(.auth__forgot, .linkish:not(:disabled), .auth__ref summary, .check a) { color: var(--d-link); }
[data-theme="dark"] .auth__alt:hover { border-color: var(--d-link); color: var(--d-link); }
[data-theme="dark"] .auth__safe { color: #6ee7a8; }
[data-theme="dark"] .auth__demo { background: rgba(245, 158, 11, .14); color: #fcd27a; }
[data-theme="dark"] .auth__demo--pick .seg { background: rgba(0, 0, 0, .25); }
[data-theme="dark"] .auth__demo--pick .seg button { color: #fcd27a; }
[data-theme="dark"] .auth__demo--pick .seg button.is-on { background: #2c3168; color: #fff; }
[data-theme="dark"] .auth-side { background: radial-gradient(120% 110% at 25% 92%, #1fb9cf 0, #0057ce 46%, #06103f 100%); }

/* ---------- One column below 900px, a bottom sheet on phones ---------- */
@media (max-width: 900px) {
  .auth-modal { width: min(480px, calc(100vw - 24px)); }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth { min-height: 0; padding: 20px 28px 24px; }
  .auth__demo--pick { margin-top: 16px; }
}
@media (max-width: 560px) {
  .auth-modal { width: 100vw; max-width: 100vw; max-height: 94svh; margin: auto 0 0; border-radius: 24px 24px 0 0; }
  .auth-modal[open] { animation-name: auth-sheet-in; }
  .auth-shell { max-height: 94svh; }
  .auth { padding: 16px 20px 22px; }
  .auth h2 { font-size: 25px; }
  .otp { gap: 8px; }
  .otp input { width: 100%; max-width: 56px; height: 58px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth__tick circle, .auth__tick path { stroke-dashoffset: 0; }
}
