/* ===== 2FA: ввод кода из Telegram (6 квадратов -> слияние -> результат) ===== */
.otp { position: relative; display: flex; justify-content: center;
    gap: clamp(14px, 4vw, 24px); margin: 20px 0 6px; }
.otp__boxes, .otp__merged { display: none; }
.otp__box { flex: 0 1 auto; width: clamp(40px, 11.5vw, 52px); aspect-ratio: 1 / 1;
    border-radius: 14px; border: 1.5px solid var(--line); background: var(--panel-2);
    display: grid; place-items: center; user-select: none; -webkit-user-select: none;
    font-size: clamp(20px, 6vw, 26px); font-weight: 800; color: var(--text);
    transition: transform .45s cubic-bezier(.6, -.1, .3, 1.3), opacity .35s ease,
        border-color .15s ease, box-shadow .2s ease; }
.otp--js .otp__boxes { display: flex; }
.otp--js #id_code { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%;
    opacity: 0; border: 0; padding: 0; margin: 0; font-size: 16px; cursor: pointer;
    background: transparent; }
.otp__box.is-filled { border-color: rgba(139, 92, 246, .55); }
.otp__box.is-active { border-color: var(--warning);
    box-shadow: 0 0 0 3px rgba(224, 163, 60, .16), 0 0 18px rgba(224, 163, 60, .22); }
.otp.is-busy .otp__box.is-filled { animation: otpPulse .45s ease-in-out infinite; }
.otp.is-busy .otp__box:nth-child(2).is-filled { animation-delay: .05s; }
.otp.is-busy .otp__box:nth-child(3).is-filled { animation-delay: .1s; }
.otp.is-busy .otp__box:nth-child(4).is-filled { animation-delay: .15s; }
.otp.is-busy .otp__box:nth-child(5).is-filled { animation-delay: .2s; }
.otp.is-busy .otp__box:nth-child(6).is-filled { animation-delay: .25s; }
@keyframes otpPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

.otp__merged { position: absolute; left: 50%; top: 50%; z-index: 4;
    width: clamp(40px, 11.5vw, 52px); aspect-ratio: 1 / 1; border-radius: 14px;
    border: 1.5px solid var(--brand-light); background: var(--panel-2);
    display: grid; place-items: center;
    transform: translate(-50%, -50%) scale(0); opacity: 0;
    transition: transform .4s cubic-bezier(.34, 1.4, .5, 1), opacity .3s ease; }
.otp--js .otp__merged { display: grid; }
.otp.is-merge .otp__box { transform: scale(.08); opacity: 0; }
.otp.is-merge .otp__merged { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.otp__spinner { width: 52%; aspect-ratio: 1; border-radius: 50%;
    border: 3px solid var(--line); border-top-color: var(--brand-light);
    animation: otpSpin .7s linear infinite; }
@keyframes otpSpin { to { transform: rotate(360deg); } }
.otp__icon { display: none; width: 58%; height: 58%; }
.otp__icon path { fill: none; stroke: currentColor; stroke-width: 3;
    stroke-linecap: round; stroke-linejoin: round; }
.otp__merged.is-ok { border-color: var(--accent); color: var(--accent);
    animation: otpGlowOk 1.1s ease-in-out infinite; }
.otp__merged.is-ok .otp__check { display: block; }
.otp__merged.is-fail { border-color: var(--danger); color: var(--danger);
    animation: otpGlowFail 1.1s ease-in-out infinite; }
.otp__merged.is-fail .otp__cross { display: block; }
.otp__merged.is-ok .otp__spinner, .otp__merged.is-fail .otp__spinner { display: none; }
@keyframes otpGlowOk {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 176, 74, .5); }
    50% { box-shadow: 0 0 0 14px rgba(99, 176, 74, 0); } }
@keyframes otpGlowFail {
    0%, 100% { box-shadow: 0 0 0 0 rgba(217, 83, 79, .5); }
    50% { box-shadow: 0 0 0 14px rgba(217, 83, 79, 0); } }

.otp__error { min-height: 1.3em; margin-top: 6px; text-align: center;
    color: var(--danger); font-size: .9rem; }
.otp__submit { width: 100%; }

@media (prefers-reduced-motion: reduce) {
    .otp__box, .otp__merged { transition: none; }
    .otp.is-busy .otp__box.is-filled, .otp__spinner,
    .otp__merged.is-ok, .otp__merged.is-fail { animation: none; }
}

/* без JS поле кода - обычный инпут на всю ширину карточки */
.otp:not(.otp--js) { display: block; }
.otp:not(.otp--js) #id_code { width: 100%; }

/* ===== 500: страница ошибки ===== */
.page-err { background: var(--bg); min-height: 100vh; }
.err500 { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='184' height='184'%3E%3Cg fill='none' stroke='%236c3ff5' stroke-opacity='.07' stroke-width='1.5'%3E%3Crect x='6' y='6' width='45' height='45' rx='10'/%3E%3Crect x='98' y='6' width='45' height='45' rx='10'/%3E%3Crect x='6' y='98' width='45' height='45' rx='10'/%3E%3Crect x='98' y='98' width='45' height='45' rx='10'/%3E%3C/g%3E%3Cg fill='%236c3ff5' fill-opacity='.10'%3E%3Crect x='52' y='52' width='45' height='45' rx='10'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 184px 184px; }
.err500__sq { position: absolute; width: 14px; height: 14px; border-radius: 4px;
    border: 1.5px solid rgba(217, 83, 79, .35); background: rgba(217, 83, 79, .08);
    animation: errFloat 9s ease-in-out infinite; }
.err500__sq:nth-child(1)  { left: 8%;  top: 18%; animation-delay: 0s; }
.err500__sq:nth-child(2)  { left: 16%; top: 64%; width: 10px; height: 10px; animation-delay: -2s; }
.err500__sq:nth-child(3)  { left: 26%; top: 30%; width: 8px;  height: 8px;  animation-delay: -5s; }
.err500__sq:nth-child(4)  { left: 74%; top: 14%; width: 18px; height: 18px; animation-delay: -1s; }
.err500__sq:nth-child(5)  { left: 84%; top: 58%; width: 11px; height: 11px; animation-delay: -4s; }
.err500__sq:nth-child(6)  { left: 90%; top: 26%; width: 9px;  height: 9px;  animation-delay: -7s; }
.err500__sq:nth-child(7)  { left: 48%; top: 8%;  width: 12px; height: 12px; animation-delay: -3s; }
.err500__sq:nth-child(8)  { left: 55%; top: 82%; width: 16px; height: 16px; animation-delay: -6s; }
.err500__sq:nth-child(9)  { left: 6%;  top: 84%; width: 9px;  height: 9px;  animation-delay: -8s; }
.err500__sq:nth-child(10) { left: 93%; top: 80%; width: 13px; height: 13px; animation-delay: -2.5s; }
.err500__sq:nth-child(11) { left: 34%; top: 88%; width: 10px; height: 10px; animation-delay: -5.5s; }
.err500__sq:nth-child(12) { left: 64%; top: 44%; width: 8px;  height: 8px;  animation-delay: -7.5s; }
@keyframes errFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: .5; }
    50%      { transform: translateY(-22px) rotate(8deg); opacity: 1; } }
.err500__main { text-align: center; padding-top: clamp(48px, 12vh, 110px); }
.err500__code { font-size: clamp(84px, 18vw, 160px); font-weight: 900; line-height: 1;
    letter-spacing: -.04em; user-select: none;
    background: linear-gradient(180deg, #f3ecff 20%, var(--brand-light) 70%, var(--brand));
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 10px 30px rgba(108, 63, 245, .35)); }
.err500__zero { font-style: normal; color: var(--danger);
    -webkit-text-fill-color: var(--danger); }
.err500__title { margin: 18px 0 10px; font-size: clamp(22px, 4.5vw, 30px); }
.err500__text { max-width: 520px; margin: 0 auto 26px; }
.err500__actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.err500__actions .btn i { margin-right: 6px; }

@media (prefers-reduced-motion: reduce) {
    .err500__sq { animation: none; opacity: .6; }
}

/* ===== 500: эффекты (глитч, свечение за курсором, янтарные квадраты, дрейф сетки) ===== */
.err500 { animation: errGridDrift 60s linear infinite; }
@keyframes errGridDrift {
    from { background-position: 0 0; }
    to   { background-position: 184px 184px; } }

.err500__glow { position: absolute; left: 50%; top: 42%; width: 90vmax; height: 90vmax;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(108, 63, 245, .14) 0%, rgba(108, 63, 245, 0) 55%);
    will-change: transform; }

/* Каждый третий «обломок» - янтарный, как тёплые клетки следа мыши в site.js */
.err500__sq:nth-child(3n)  { border-color: rgba(224, 163, 60, .4); background: rgba(224, 163, 60, .1); }
.err500__sq:nth-child(4n)  { border-color: rgba(139, 92, 246, .45); background: rgba(139, 92, 246, .12); }

/* Глитч на коде: редкие вспышки смещения и цветового сплита */
.err500__code { position: relative; animation: errFlicker 7s linear infinite; }
.err500__code::before, .err500__code::after {
    content: attr(data-text); position: absolute; inset: 0; pointer-events: none; }
.err500__code::before { color: var(--danger); opacity: 0; animation: errGlitchA 7s steps(1) infinite; }
.err500__code::after  { color: var(--brand-light); opacity: 0; animation: errGlitchB 7s steps(1) infinite; }
@keyframes errFlicker {
    0%, 93%, 100% { opacity: 1; }
    94% { opacity: .55; } 95% { opacity: 1; } 96.5% { opacity: .7; } 97% { opacity: 1; } }
@keyframes errGlitchA {
    0%, 93.9% { opacity: 0; transform: none; clip-path: inset(0 0 0 0); }
    94%   { opacity: .8; transform: translate(-4px, 2px); clip-path: inset(12% 0 58% 0); }
    94.6% { opacity: .8; transform: translate(3px, -1px);  clip-path: inset(55% 0 8% 0); }
    95.2% { opacity: 0; transform: none; }
    96.8% { opacity: .6; transform: translate(-2px, 1px); clip-path: inset(30% 0 40% 0); }
    97.4% { opacity: 0; transform: none; } }
@keyframes errGlitchB {
    0%, 94.4% { opacity: 0; transform: none; clip-path: inset(0 0 0 0); }
    94.6% { opacity: .7; transform: translate(4px, -2px); clip-path: inset(60% 0 12% 0); }
    95.1% { opacity: .7; transform: translate(-3px, 2px);  clip-path: inset(5% 0 78% 0); }
    95.7% { opacity: 0; transform: none; }
    97.2% { opacity: .5; transform: translate(2px, -1px);  clip-path: inset(42% 0 30% 0); }
    97.8% { opacity: 0; transform: none; } }

/* Лёгкое «дыхание» свечения за цифрами */
.err500__code { filter: drop-shadow(0 10px 30px rgba(108, 63, 245, .35));
    animation: errFlicker 7s linear infinite, errCodeGlow 5s ease-in-out infinite; }
@keyframes errCodeGlow {
    0%, 100% { filter: drop-shadow(0 10px 30px rgba(108, 63, 245, .35)); }
    50%      { filter: drop-shadow(0 10px 46px rgba(108, 63, 245, .55)); } }

@media (prefers-reduced-motion: reduce) {
    .err500, .err500__code, .err500__code::before, .err500__code::after { animation: none; }
    .err500__glow { display: none; }
}

/* ===== 500: canvas-амбиент (снег + угли) и тёплое свечение снизу ===== */
.err500__canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.err500::after { content: ''; position: absolute; left: 50%; bottom: -30vmax;
    width: 120vmax; height: 60vmax; transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(224, 163, 60, .07) 0%, rgba(224, 163, 60, 0) 60%);
    pointer-events: none; }


/* ===== Auth: вход и регистрация ===== */
.page-auth { background-color: var(--bg); }
.auth-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.auth-bg__orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.auth-bg__orb--a { width: 46vmax; height: 46vmax; left: -12vmax; top: -14vmax;
    background: radial-gradient(circle, rgba(108, 63, 245, .32), transparent 65%);
    animation: authOrbA 16s ease-in-out infinite alternate; }
.auth-bg__orb--b { width: 40vmax; height: 40vmax; right: -10vmax; bottom: -12vmax;
    background: radial-gradient(circle, rgba(224, 163, 60, .16), transparent 65%);
    animation: authOrbB 19s ease-in-out infinite alternate; }
@keyframes authOrbA { to { transform: translate(6vmax, 4vmax) scale(1.12); } }
@keyframes authOrbB { to { transform: translate(-5vmax, -5vmax) scale(1.08); } }

.auth-wrap { max-width: 430px; margin: 0 auto; padding: clamp(28px, 6vh, 64px) 16px 56px; }
.auth-card { position: relative; padding: 30px 28px 26px; border-radius: 22px;
    background: linear-gradient(165deg, rgba(34, 28, 66, .92), rgba(18, 15, 38, .94));
    border: 1px solid rgba(139, 92, 246, .28);
    box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .75),
                0 0 0 1px rgba(255, 255, 255, .03) inset,
                0 -20px 60px -30px rgba(108, 63, 245, .35) inset;
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    animation: authIn .55s cubic-bezier(.2, .9, .3, 1.1) both; }
@keyframes authIn { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.auth-card::before { content: ''; position: absolute; inset: 0; border-radius: inherit;
    padding: 1px; background: linear-gradient(140deg, rgba(167, 139, 250, .55), transparent 30%, transparent 70%, rgba(224, 163, 60, .3));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.auth-card__badge { width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 18px;
    display: grid; place-items: center; font-size: 24px; color: #fff;
    background: linear-gradient(140deg, var(--brand), var(--brand-light));
    box-shadow: 0 10px 26px -8px rgba(108, 63, 245, .7), 0 0 0 4px rgba(139, 92, 246, .12);
    animation: authBadge 4.5s ease-in-out infinite; }
@keyframes authBadge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.auth-card h1 { text-align: center; font-size: 27px; margin: 0 0 6px;
    background: linear-gradient(100deg, #f3ecff 10%, var(--brand-light) 55%, var(--accent-hi));
    -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-card__sub { text-align: center; margin: 0 0 20px; font-size: 14px; }
.auth-card .auth-form { display: grid; gap: 14px; }
.auth-card .field { gap: 7px; }
.auth-card .field__label { font-size: 13.5px; color: var(--brand-soft); letter-spacing: .01em; }

/* поля: выше, круглее, с иконкой слева (data-icon ставится в forms.py) */
.page-auth input.input { min-height: 50px; padding: 12px 14px 12px 46px;
    border-radius: 14px; border: 1.5px solid rgba(139, 92, 246, .22);
    background: rgba(13, 11, 28, .55); font-size: 16px;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease; }
.page-auth input.input:hover { border-color: rgba(139, 92, 246, .5); }
.page-auth input.input:focus { border-color: var(--brand-light);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, .22), 0 0 24px -6px rgba(108, 63, 245, .5);
    background: rgba(13, 11, 28, .8); }
/* иконки полей - отдельным элементом .field__glyph поверх инпута. Фон самого
   поля при автозаполнении Chrome перекрывается inset-тенью из правила
   -webkit-autofill (она заливает всё поле цветом панели) и иконка пропадала;
   у соседнего элемента, идущего поверх, этой проблемы нет */
.page-auth .field__ic { position: relative; display: block; }
.page-auth .field__glyph { position: absolute; left: 14px; top: 50%;
    width: 21px; height: 21px; transform: translateY(-50%);
    background-repeat: no-repeat; background-position: center;
    background-size: contain; pointer-events: none; }
.page-auth .field__glyph--user { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4.5 20c1.4-3.4 4.4-5 7.5-5s6.1 1.6 7.5 5'/%3E%3C/svg%3E"); }
.page-auth .field__glyph--lock { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='10.5' width='14' height='9.5' rx='2'/%3E%3Cpath d='M8 10.5V8a4 4 0 0 1 8 0v2.5'/%3E%3C/svg%3E"); }
.page-auth .field__glyph--envelope { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5.5' width='18' height='13' rx='2'/%3E%3Cpath d='M3.5 7.5 12 13l8.5-5.5'/%3E%3C/svg%3E"); }
.page-auth .field__glyph--cube { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2.8 20.5 7.3v9.4L12 21.2 3.5 16.7V7.3z'/%3E%3Cpath d='M12 12.2 20.5 7.8M12 12.2 3.5 7.8M12 12.2v8.4'/%3E%3C/svg%3E"); }
.page-auth .field__glyph--gift { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='9' width='16' height='4' rx='1'/%3E%3Cpath d='M6 13v7h12v-7M12 9v11M12 9c-1.6-3.2-5.2-3-5.2.4h5.2zm0 0c1.6-3.2 5.2-3 5.2.4h-5.2z'/%3E%3C/svg%3E"); }
/* у поля с «глазиком» иконка не должна наезжать на кнопку
   (.field__pw уже relative в 08-nav-forms-cart.css) */
.page-auth .field__pw input.input { padding-right: 46px; }
.page-auth .field__eye { border-radius: 10px; }
.page-auth .helptext { font-size: 12.5px; }
.page-auth .fielderror { font-size: 12.5px; }

/* кнопка: градиент, свечение, пробегающий блик */
.page-auth .auth-btn { position: relative; overflow: hidden; width: 100%;
    justify-content: center; min-height: 52px; margin-top: 4px;
    font-size: 15.5px; font-weight: 700; letter-spacing: .02em; color: #fff;
    border-radius: 14px; border: 0; cursor: pointer;
    background: linear-gradient(120deg, var(--brand) 0%, var(--brand-light) 55%, #a78bfa 100%);
    background-size: 180% 100%;
    box-shadow: 0 12px 30px -10px rgba(108, 63, 245, .65),
                0 0 0 1px rgba(167, 139, 250, .25) inset;
    transition: transform .16s ease, box-shadow .2s ease, background-position .5s ease; }
.page-auth .auth-btn::after { content: ''; position: absolute; top: 0; bottom: 0; left: -70%;
    width: 45%; transform: skewX(-20deg);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
    transition: left .55s ease; }
.page-auth .auth-btn:hover { transform: translateY(-2px);
    background-position: 90% 0;
    box-shadow: 0 16px 38px -10px rgba(108, 63, 245, .8),
                0 0 0 1px rgba(167, 139, 250, .4) inset; }
.page-auth .auth-btn:hover::after { left: 130%; }
.page-auth .auth-btn:active { transform: translateY(0) scale(.985); }
.page-auth .auth-btn i { font-size: 14px; transition: transform .2s ease; }
.page-auth .auth-btn:hover i { transform: translateX(4px); }

/* ошибка - «пилюля» поверх формы */
.page-auth .auth-error { justify-self: stretch; list-style: none; padding: 10px 14px;
    border-radius: 12px; font-size: 13.5px;
    background: rgba(217, 83, 79, .12); border: 1px solid rgba(217, 83, 79, .45);
    color: #ffb3ae; }

/* чекбокс согласия - отдельная «плитка», :has подсвечивает выбранную */
.page-auth .check { position: relative; align-items: center; padding: 12px 14px 12px 42px;
    border-radius: 12px; border: 1.5px solid rgba(139, 92, 246, .22);
    background: rgba(13, 11, 28, .5); cursor: pointer;
    transition: border-color .18s ease, background .18s ease; }
.page-auth .check:hover { border-color: rgba(139, 92, 246, .55); }
.page-auth .check input[type="checkbox"] { position: absolute; left: 13px; top: 50%;
    transform: translateY(-50%); margin: 0; width: 18px; height: 18px; accent-color: var(--brand-light); }
.page-auth .check:has(input:checked) { border-color: rgba(99, 176, 74, .55);
    background: rgba(99, 176, 74, .08); }
.page-auth .check a { color: var(--brand-light); }

.auth-links { margin-top: 18px; text-align: center; font-size: 13.5px; }
.auth-links a, .auth-legal a { color: var(--brand-light); text-decoration: underline;
    text-underline-offset: 2px; }
.auth-links a:hover, .auth-legal a:hover { color: #fff; }
.auth-legal { margin-top: 10px; font-size: 12px; opacity: .75; text-align: center; }

@media (max-width: 480px) {
    .auth-card { padding: 24px 18px 20px; border-radius: 18px; }
    .auth-card h1 { font-size: 23px; }
    .page-auth input.input { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-card, .auth-card__badge, .auth-bg__orb { animation: none; }
    .page-auth .auth-btn, .page-auth .auth-btn::after { transition: none; }
}

