/* ============================================================
   dist-tutor — модалка входа и регистрации по образцу «Класса».
   Источник: /Volumes/T9/Class/whiteboard-app/src/features/auth/AuthModal.tsx

   Геометрия и тени сняты с образца, палитра — общая с home.css
   (--dt-accent), чтобы шапка и модалка звучали одинаково.

   ВАЖНО: у портала html{font-size:62.5%} → 1rem = 10px, а величины
   образца сняты при 16px, поэтому здесь всё в пикселях.
   Ещё в index.tpl в самом низу висит `* { margin: 0 auto; }`,
   поэтому margin у своих элементов задаём явно.
   ============================================================ */

.dt-auth {
    --dt-auth-accent:        var(--dt-accent, #2563eb);
    --dt-auth-accent-strong: #1d4ed8;
    --dt-auth-ring:          rgba(37, 99, 235, .10);
    --dt-auth-border-strong: rgba(37, 99, 235, .30);
    --dt-auth-field-border:  rgba(15, 23, 42, .08);
    --dt-auth-surface:       rgba(255, 255, 255, .92);
    --dt-auth-surface-soft:  rgba(255, 255, 255, .82);
    --dt-auth-font:          var(--dt-font, 'Google Sans', Arial, Helvetica, sans-serif);

    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 16px;
    margin: 0;
    font-family: var(--dt-auth-font);
    font-size: 15px;
    line-height: 1.4;
    color: #334155;
}
.dt-auth[hidden] { display: none; }
.dt-auth * { box-sizing: border-box; }

.dt-auth__overlay {
    position: absolute;
    inset: 0;
    margin: 0;
    background: rgba(15, 23, 42, .24);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    animation: dt-auth-fade .3s ease both;
}

.dt-auth__card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    margin: auto;
    padding: 24px 32px 26px;
    border: 1px solid rgba(255, 255, 255, .85);
    border-radius: 34px;
    background: var(--dt-auth-surface);
    box-shadow: 0 34px 90px -54px rgba(15, 23, 42, .64),
                inset 0 1px 0 rgba(255, 255, 255, .95);
    -webkit-backdrop-filter: blur(40px);
    backdrop-filter: blur(40px);
    animation: dt-auth-rise .34s cubic-bezier(.22, 1, .36, 1) both;
    text-align: left;
}

/* тонкая световая линия по верхней кромке карточки */
.dt-auth__hairline {
    position: absolute;
    left: 32px;
    right: 32px;
    top: 0;
    height: 1px;
    margin: 0;
    pointer-events: none;
    background: linear-gradient(90deg,
        rgba(37, 99, 235, 0) 0%,
        rgba(37, 99, 235, .7) 50%,
        rgba(37, 99, 235, 0) 100%);
}

.dt-auth__close {
    position: absolute;
    right: 16px;
    top: 16px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(226, 232, 240, .8);
    border-radius: 9999px;
    background: var(--dt-auth-surface-soft);
    color: #64748b;
    box-shadow: 0 10px 18px -16px rgba(15, 23, 42, .6),
                inset 0 1px 0 rgba(255, 255, 255, .96);
    cursor: pointer;
    transition: color .18s ease, border-color .18s ease;
}
.dt-auth__close:hover {
    border-color: var(--dt-auth-border-strong);
    color: var(--dt-auth-accent);
}
.dt-auth__close svg { display: block; width: 20px; height: 20px; margin: 0; }

.dt-auth__logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .9);
    border-radius: 16px;
    background: var(--dt-auth-surface-soft);
    box-shadow: 0 20px 38px -24px rgba(15, 23, 42, .46),
                inset 0 1px 0 rgba(255, 255, 255, .94);
}
.dt-auth__logo img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: contain;
}

.dt-auth .dt-auth__title {
    margin: 0 0 8px;
    padding: 0;
    font-family: var(--dt-auth-font);
    font-size: 34px;
    font-weight: 600;
    line-height: 1.12;
    letter-spacing: 0;
    text-align: center;
    text-shadow: none;
    color: #0f172a;
}
.dt-auth__lead {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.45;
    text-align: center;
    color: #64748b;
}

/* ---------- сообщения ---------- */

.dt-auth__alert {
    margin: 0 0 14px;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}
.dt-auth__alert[hidden] { display: none; }
.dt-auth__alert--error {
    border: 1px solid rgba(254, 226, 226, .9);
    background: rgba(254, 242, 242, .9);
    color: #dc2626;
}
.dt-auth__alert--ok {
    border: 1px solid rgba(209, 250, 229, .9);
    background: rgba(236, 253, 245, .9);
    color: #047857;
}
.dt-auth__notice {
    margin: 12px 0 0;
    padding: 12px 16px;
    border: 1px solid rgba(254, 243, 199, .9);
    border-radius: 16px;
    background: rgba(255, 251, 235, .9);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
    color: #92400e;
}

/* ---------- поля ---------- */

.dt-auth__fields { display: flex; flex-direction: column; gap: 12px; margin: 0; }

.dt-auth .dt-auth__field {
    display: block;
    width: 100%;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 14px 16px;
    border: 1px solid var(--dt-auth-field-border);
    border-radius: 18px;
    background: #f4f6fb;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .72);
    font-family: var(--dt-auth-font);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.3;
    color: #334155;
    transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
    -webkit-appearance: none;
    appearance: none;
}
.dt-auth .dt-auth__field::placeholder { color: #94a3b8; font-weight: 400; }
.dt-auth .dt-auth__field:focus {
    outline: none;
    border-color: var(--dt-auth-border-strong);
    background: #fff;
    box-shadow: 0 0 0 4px var(--dt-auth-ring);
}
.dt-auth .dt-auth__field:disabled { opacity: .7; cursor: not-allowed; }
.dt-auth .dt-auth__field.is-invalid {
    border-color: rgba(220, 38, 38, .45);
    background: #fff5f5;
}

/* ---------- «я регистрируюсь как» ---------- */

.dt-auth__role { margin: 14px 0 0; }
.dt-auth__role-label {
    display: block;
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
}
.dt-auth__role-list { display: flex; gap: 10px; margin: 0; }
.dt-auth .dt-auth__role-item {
    position: relative;
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--dt-auth-field-border);
    border-radius: 18px;
    background: #f4f6fb;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    color: #475569;
    text-align: center;
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease,
                color .18s ease, box-shadow .18s ease;
}
/* Родные радио и чекбокс прячем совсем: в шапке портала лежит старый CSS,
   который умеет вернуть им размеры, поэтому убираем их каноническим
   visually-hidden, а не просто прозрачностью. */
.dt-auth .dt-auth__role-item input,
.dt-auth .dt-auth__consent input[type="checkbox"] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    opacity: 0 !important;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
}
.dt-auth .dt-auth__role-item:hover { border-color: var(--dt-auth-border-strong); }
.dt-auth .dt-auth__role-item.is-checked {
    border-color: var(--dt-auth-accent);
    background: #eff6ff;
    color: var(--dt-auth-accent);
    font-weight: 600;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .16);
}

/* ---------- согласие ---------- */

.dt-auth .dt-auth__consent {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 16px 0 0;
    padding: 0;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    color: #334155;
    cursor: pointer;
}
/* сам квадратик рисуем — родной чекбокс в каждой ОС выглядит по-своему */
.dt-auth .dt-auth__box {
    flex: none;
    position: relative;
    display: block;
    width: 20px;
    height: 20px;
    margin: 1px 0 0;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9);
    transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease;
}
.dt-auth .dt-auth__box::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    margin: 0;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(.6);
    opacity: 0;
    transition: opacity .14s ease, transform .14s ease;
}
.dt-auth .dt-auth__consent:hover .dt-auth__box { border-color: var(--dt-auth-border-strong); }
.dt-auth .dt-auth__consent input:checked ~ .dt-auth__box {
    border-color: var(--dt-auth-accent);
    background: var(--dt-auth-accent);
}
.dt-auth .dt-auth__consent input:checked ~ .dt-auth__box::after {
    opacity: 1;
    transform: rotate(45deg) scale(1);
}
.dt-auth .dt-auth__consent input:focus-visible ~ .dt-auth__box {
    border-color: var(--dt-auth-accent);
    box-shadow: 0 0 0 4px var(--dt-auth-ring);
}
.dt-auth__consent a { color: var(--dt-auth-accent); font-weight: 600; text-decoration: none; }
.dt-auth__consent a:hover { color: var(--dt-auth-accent-strong); text-decoration: underline; }

/* ---------- капча ---------- */

.dt-auth__captcha { margin: 16px 0 0; }
.dt-auth__captcha > div { margin: 0 !important; }
.dt-auth__captcha:empty { display: none; }

/* ---------- кнопка ---------- */

.dt-auth__actions { margin: 24px 0 0; }
.dt-auth .dt-auth__primary {
    display: block;
    width: 100%;
    margin: 0;
    padding: 14px 20px;
    border: 1px solid transparent;
    border-radius: 18px;
    background: var(--dt-auth-accent);
    background-image: linear-gradient(90deg, #3b82f6, #2f74ee 40%, #2563eb 72%, #1d4ed8);
    background-size: 220% 100%;
    background-position: 0% 50%;
    box-shadow: 0 14px 30px -20px rgba(37, 99, 235, .8);
    font-family: var(--dt-auth-font);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: .01em;
    color: #fff;
    text-shadow: none;
    text-align: center;
    cursor: pointer;
    transition: background-position .52s cubic-bezier(.22, 1, .36, 1),
                transform .18s ease, opacity .18s ease;
}
.dt-auth .dt-auth__primary:hover { background-position: 100% 50%; color: #fff; }
.dt-auth .dt-auth__primary:active { transform: scale(.985); }
.dt-auth .dt-auth__primary:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

/* ---------- подвал модалки ---------- */

.dt-auth__foot {
    margin: 24px 0 0;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
    color: #64748b;
}
.dt-auth__foot p { margin: 0; }
.dt-auth__foot p + p { margin: 8px 0 0; }
.dt-auth .dt-auth__link {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    color: var(--dt-auth-accent);
    text-decoration: none;
    cursor: pointer;
}
.dt-auth .dt-auth__link:hover { color: var(--dt-auth-accent-strong); text-decoration: none; }

/* ---------- режимы ---------- */

.dt-auth [data-pane] { display: none; }
.dt-auth[data-mode="login"]    [data-pane~="login"],
.dt-auth[data-mode="register"] [data-pane~="register"],
.dt-auth[data-mode="forgot"]   [data-pane~="forgot"] { display: block; }
.dt-auth[data-mode="register"] label.dt-auth__consent[data-pane~="register"] { display: flex; }

/* после успеха форму прячем и оставляем сообщение */
.dt-auth.is-done .dt-auth__form,
.dt-auth.is-done .dt-auth__foot { display: none; }

@keyframes dt-auth-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dt-auth-rise {
    from { opacity: 0; transform: translateY(12px) scale(.985); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .dt-auth__overlay, .dt-auth__card { animation: none; }
}

@media (max-width: 520px) {
    .dt-auth { align-items: flex-start; padding: 12px; }
    .dt-auth__card { padding: 22px 20px 24px; border-radius: 28px; }
    .dt-auth__hairline { left: 20px; right: 20px; }
    .dt-auth .dt-auth__title { font-size: 28px; }    .dt-auth__close { right: 12px; top: 12px; }
}

/* тело не должно прокручиваться под открытой модалкой */
body.dt-auth-open { overflow: hidden; }
