/* Подтверждение почты кодом из письма (страница /login). */
.otp-wrap[hidden] { display: none; }
.otp-card { position: relative; text-align: center; animation: otp-rise .55s var(--ease, cubic-bezier(.2, .8, .2, 1)) both; }
.otp-card .brand { justify-content: center; }
.otp-title { margin: 6px 0 8px; font: 700 26px/1.2 var(--f-display); letter-spacing: -.01em; }
.otp-lead { margin: 0 auto 22px; max-width: 34ch; color: var(--muted); font-size: 15px; line-height: 1.5; }
.otp-lead b { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.otp-label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 13px; font-weight: 500; }

/* Конверт: клапан открывается, письмо с четырьмя точками выезжает и покачивается. */
.otp-env { position: relative; width: 120px; height: 96px; margin: 0 auto 8px; }
.otp-env-svg { width: 100%; height: 100%; overflow: visible; }
.env-back { fill: var(--surface-3, #23262b); }
.env-front { fill: var(--surface-2, #1b1d21); stroke: var(--line-2, #2e3136); stroke-width: 1; }
.env-flap { fill: var(--surface-3, #23262b); stroke: var(--line-2, #2e3136); stroke-width: 1; transform-origin: 60px 44px; animation: otp-flap .5s .25s cubic-bezier(.3, 1.4, .5, 1) both; }
.env-letter { animation: otp-letter .7s .55s cubic-bezier(.2, 1.3, .4, 1) both, otp-float 3.2s 1.4s ease-in-out infinite; }
.env-letter rect:first-child { fill: var(--text, #f2f0eb); }
.env-letter circle { fill: var(--accent, #ff5a26); animation: otp-dot 1.6s 1.3s ease-in-out infinite; }
.env-letter circle:nth-of-type(2) { animation-delay: 1.45s; }
.env-letter circle:nth-of-type(3) { animation-delay: 1.6s; }
.env-letter circle:nth-of-type(4) { animation-delay: 1.75s; }
.env-line { fill: color-mix(in srgb, var(--bg, #0b0c0e) 22%, transparent); }
.otp-spark { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--accent, #ff5a26); opacity: 0; animation: otp-spark 2.4s 1.1s ease-out infinite; }
.otp-spark.s1 { left: 6px; top: 22px; }
.otp-spark.s2 { right: 4px; top: 12px; animation-delay: 1.6s; background: var(--accent-2, #ff8a5c); }
.otp-spark.s3 { right: 18px; bottom: 6px; animation-delay: 2.1s; width: 4px; height: 4px; }

/* Поле: одно настоящее поле ввода поверх четырёх ячеек. Вставка и автоподстановка кода работают. */
.otp-box { position: relative; width: min(372px, 100%); margin: 0 auto; }
.otp-box input {
  position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; border: 0; padding: 0; margin: 0;
  background: transparent; color: transparent; caret-color: transparent; font-size: 16px; letter-spacing: 0; outline: none;
  -webkit-text-fill-color: transparent; cursor: text;
}
.otp-box input::selection { background: transparent; }
.otp-cells { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.otp-cell {
  --c: var(--line-2, #2e3136);
  position: relative; display: grid; place-items: center; height: 66px; border-radius: 14px;
  background: var(--surface-2, #1b1d21); border: 1.5px solid var(--c);
  transition: border-color .2s, background-color .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1), box-shadow .25s;
}
.otp-cell b { font: 700 30px/1 var(--f-display); color: var(--text); font-variant-numeric: tabular-nums; }
.otp-cell.is-filled { --c: color-mix(in srgb, var(--accent, #ff5a26) 55%, var(--line-2, #2e3136)); background: color-mix(in srgb, var(--accent, #ff5a26) 7%, var(--surface-2, #1b1d21)); }
.otp-cell.is-filled b { animation: otp-pop .32s cubic-bezier(.3, 1.6, .5, 1) both; }
.otp-cell.is-filled::after { content: ""; position: absolute; left: 30%; right: 30%; bottom: 10px; height: 3px; border-radius: 3px; background: var(--accent, #ff5a26); animation: otp-bar .3s ease-out both; }
.otp-box.is-focus .otp-cell.is-active { --c: var(--accent, #ff5a26); transform: translateY(-3px); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, #ff5a26) 20%, transparent), 0 10px 24px -12px color-mix(in srgb, var(--accent, #ff5a26) 70%, transparent); }
.otp-box.is-focus .otp-cell.is-active:not(.is-filled)::before { content: ""; width: 2px; height: 28px; border-radius: 2px; background: var(--accent, #ff5a26); animation: otp-caret 1s steps(1) infinite; }

.otp-box.is-error .otp-cells { animation: otp-shake .42s cubic-bezier(.36, .07, .19, .97) both; }
.otp-box.is-error .otp-cell { --c: var(--err, #ff5c5c); background: color-mix(in srgb, var(--err, #ff5c5c) 8%, var(--surface-2, #1b1d21)); }
.otp-box.is-error .otp-cell::after { background: var(--err, #ff5c5c); }
.otp-box.is-busy .otp-cell { animation: otp-wave 1s ease-in-out infinite; }
.otp-box.is-busy .otp-cell:nth-child(2) { animation-delay: .1s; }
.otp-box.is-busy .otp-cell:nth-child(3) { animation-delay: .2s; }
.otp-box.is-busy .otp-cell:nth-child(4) { animation-delay: .3s; }
.otp-box.is-busy .otp-cell:nth-child(5) { animation-delay: .4s; }
.otp-box.is-busy .otp-cell:nth-child(6) { animation-delay: .5s; }

/* Успех: ячейки по очереди зеленеют и собираются, поверх рисуется галочка. */
.otp-box.is-ok .otp-cell { --c: var(--ok, #3ddc84); background: color-mix(in srgb, var(--ok, #3ddc84) 12%, var(--surface-2, #1b1d21)); animation: otp-ok .5s cubic-bezier(.3, 1.4, .5, 1) both; }
.otp-box.is-ok .otp-cell::after { background: var(--ok, #3ddc84); }
.otp-box.is-ok .otp-cell b { color: var(--ok, #3ddc84); }
.otp-box.is-ok .otp-cell:nth-child(2) { animation-delay: .07s; }
.otp-box.is-ok .otp-cell:nth-child(3) { animation-delay: .14s; }
.otp-box.is-ok .otp-cell:nth-child(4) { animation-delay: .21s; }
.otp-box.is-ok .otp-cell:nth-child(5) { animation-delay: .28s; }
.otp-box.is-ok .otp-cell:nth-child(6) { animation-delay: .35s; }
.otp-done { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; z-index: 3; opacity: 0; pointer-events: none; }
.otp-done circle { fill: var(--ok, #3ddc84); }
.otp-done path { fill: none; stroke: var(--bg, #0b0c0e); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; }
.otp-box.is-ok .otp-done { animation: otp-done .45s .45s cubic-bezier(.3, 1.6, .5, 1) both; }
.otp-box.is-ok .otp-done path { animation: otp-draw .35s .75s ease-out forwards; }
.otp-box.is-ok .otp-cells { animation: otp-blur .4s .5s ease-out forwards; }

.otp-card .err { min-height: 0; margin-top: 12px; }
.otp-card.is-done .otp-foot, .otp-card.is-done .otp-help { visibility: hidden; }
.otp-submit { margin-top: 20px; }
.otp-submit[disabled] { opacity: .5; cursor: default; }
.otp-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 18px; }
.otp-resend { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 2px; border: 0; background: none; color: var(--accent-2, #ff8a5c); font: 500 14px/1.3 var(--f-ui); cursor: pointer; }
.otp-resend[disabled] { color: var(--dim); cursor: default; }
.otp-resend svg { width: 20px; height: 20px; transform: rotate(-90deg); flex: none; }
.otp-resend .ring-bg { fill: none; stroke: var(--line-2, #2e3136); stroke-width: 2.5; }
.otp-resend .ring { fill: none; stroke: var(--accent, #ff5a26); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 62.83; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear; }
.otp-resend:not([disabled]) .ring { stroke-dashoffset: 0; }
.otp-foot .link-btn { min-height: 44px; }
.otp-help { margin-top: 10px; line-height: 1.5; }
.otp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@keyframes otp-rise { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes otp-flap { from { transform: scaleY(1); } to { transform: scaleY(-1); } }
@keyframes otp-letter { from { transform: translateY(34px); } to { transform: translateY(0); } }
@keyframes otp-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes otp-dot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes otp-spark { 0% { opacity: 0; transform: scale(.4) translateY(0); } 20% { opacity: 1; } 100% { opacity: 0; transform: scale(1) translateY(-14px); } }
@keyframes otp-pop { from { opacity: 0; transform: translateY(10px) scale(.6); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes otp-bar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes otp-caret { 0% { opacity: 1; } 50% { opacity: 0; } }
@keyframes otp-shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); } }
@keyframes otp-wave { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes otp-ok { 0% { transform: scale(1); } 45% { transform: scale(1.08) translateY(-4px); } 100% { transform: scale(1); } }
@keyframes otp-done { from { opacity: 0; transform: scale(.3) rotate(-30deg); } to { opacity: 1; transform: none; } }
@keyframes otp-draw { to { stroke-dashoffset: 0; } }
@keyframes otp-blur { to { opacity: .25; filter: blur(2px); } }

@media (max-width: 380px) {
  .otp-cells { gap: 6px; }
  .otp-cell { height: 56px; border-radius: 12px; }
  .otp-cell b { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .otp-card, .env-flap, .env-letter, .env-letter circle, .otp-spark, .otp-cell, .otp-cell b, .otp-cell::after, .otp-cells, .otp-done, .otp-done path { animation: none !important; transition: none !important; }
  .env-flap { transform: scaleY(-1); }
  .otp-box.is-ok .otp-done { opacity: 1; }
  .otp-box.is-ok .otp-done path { stroke-dashoffset: 0; }
}

/* Смена пароля: «Забыли пароль?», почта, новый пароль. Замок открывается, когда пароль подходит. */
.forgot-row { display: flex; justify-content: flex-end; margin-top: 8px; }
.forgot-row[hidden] { display: none; }
.forgot-row .link-btn { min-height: 32px; color: var(--accent-2, #ff8a5c); text-decoration: none; }
.forgot-row .link-btn:hover { color: var(--text); text-decoration: underline; }
.pw-card .field { text-align: left; }
.pw-card .otp-lead { margin-bottom: 8px; }
.pw-foot { justify-content: center; }
.lock { position: relative; width: 96px; height: 96px; margin: 0 auto 6px; }
.lock-svg { width: 100%; height: 100%; overflow: visible; animation: lock-in .6s .15s cubic-bezier(.3, 1.5, .5, 1) both; }
.lock-shackle { fill: none; stroke: var(--line-2, #2e3136); stroke-width: 8; stroke-linecap: round; transform-origin: 64px 44px; transition: transform .45s cubic-bezier(.3, 1.6, .5, 1), stroke .3s; }
.lock-body { fill: var(--surface-3, #23262b); stroke: var(--line-2, #2e3136); stroke-width: 1; transform-box: fill-box; transform-origin: center; }
.lock-hole { fill: var(--accent, #ff5a26); transition: fill .3s; }
.lock .otp-spark.s1 { left: 4px; top: 30px; }
.lock .otp-spark.s2 { right: 6px; top: 18px; }
.lock.is-busy .lock-body { animation: lock-jiggle .5s ease-in-out infinite; }
.lock.is-open .lock-shackle { stroke: var(--ok, #3ddc84); transform: translateY(-7px) rotate(-28deg); }
.lock.is-open .lock-hole { fill: var(--ok, #3ddc84); }
.lock.is-done .lock-body { animation: otp-ok .5s cubic-bezier(.3, 1.4, .5, 1) both; }
.pw-input { position: relative; display: block; }
.pw-input input { width: 100%; padding-right: 52px; }
.pw-eye { position: absolute; right: 4px; top: 50%; width: 44px; height: 44px; margin-top: -22px; display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; }
.pw-eye:hover { color: var(--text); }
.pw-eye svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pw-eye[aria-pressed="true"] .pw-eye-off { display: none; }
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.pw-meter i { height: 4px; border-radius: 4px; background: var(--line-2, #2e3136); transform-origin: left; transition: background-color .25s; }
.pw-meter[data-level="1"] i:nth-child(-n+1) { background: var(--err, #ff5c5c); animation: otp-bar .3s ease-out both; }
.pw-meter[data-level="2"] i:nth-child(-n+2) { background: var(--warn, #ffb547); animation: otp-bar .3s ease-out both; }
.pw-meter[data-level="3"] i:nth-child(-n+3) { background: var(--ok, #3ddc84); animation: otp-bar .3s ease-out both; }
.pw-meter[data-level="4"] i { background: var(--ok, #3ddc84); animation: otp-bar .3s ease-out both; }
.pw-hint { margin-top: 8px; text-align: left; }
@keyframes lock-in { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes lock-jiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@media (prefers-reduced-motion: reduce) {
  .lock-svg, .lock-shackle, .lock-body, .pw-meter i { animation: none !important; transition: none !important; }
}
.ref-row { justify-content: flex-start; margin-top: 12px; }
