:root {
    --c-success:        #16a34a;
    --c-success-soft:   #d1fae5;
    --c-danger:         #dc2626;
    --c-danger-soft:    #fee2e2;
    --c-border:         #cbd5e1;
}

@property --auth-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

.auth {
    min-height: 100vh;
    padding: var(--section-y) var(--gutter);
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
}

.auth__back {
    position: absolute;
    top: clamp(0.75rem, 2vw, 1.5rem);
    left: clamp(0.75rem, 2vw, 1.5rem);
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    color: #1e3a8a; font-weight: 600;
    font-size: clamp(0.78rem, 1.1vw, 0.9rem);
    background: rgba(30, 58, 138, 0.05);
    transition: background .15s, color .15s;
    text-decoration: none;
}
.auth__back svg { width: 14px; height: 14px; }
.auth__back:hover { background: rgba(30, 58, 138, 0.10); color: #0f172a; }
@media (max-width: 299px) {
    .auth__back span { display: none; }
    .auth__back { padding: 6px; }
}

.auth__card {
    position: relative;
    width: 100%; max-width: 100%;
    background: #ffffff;
    border-radius: 14px;
    padding: clamp(0.75rem, 4vw, 1.75rem);
    box-shadow: 0 30px 80px -40px rgba(15, 23, 42, .15),
                0 1px 3px rgba(15, 23, 42, .04);
    margin-top: clamp(1.5rem, 5vw, 3rem);
    isolation: isolate;
}
@media (min-width: 540px)  { .auth__card { max-width: 460px; padding: 1.75rem; border-radius: 16px; } }
@media (min-width: 915px)  { .auth__card { max-width: 500px; padding: 2rem;    border-radius: 18px; } }
@media (min-width: 1200px) { .auth__card { max-width: 540px; padding: 2.25rem; } }
@media (min-width: 1920px) { .auth__card { max-width: 580px; padding: 2.5rem;  } }
@media (max-width: 314px) { .auth__card { padding: 0.75rem; border-radius: 12px; } }

.auth__card-border {
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1.5px;
    background: conic-gradient(
        from var(--auth-angle, 0deg),
        rgba(30, 58, 138, 0)  0%,
        rgba(30, 58, 138, 0) 35%,
        rgba(30, 58, 138, .55) 47%,
        rgba(59, 130, 246, .85) 50%,
        rgba(30, 58, 138, .55) 53%,
        rgba(30, 58, 138, 0) 65%,
        rgba(30, 58, 138, 0) 100%
    );
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    pointer-events: none;
    animation: auth-border-spin 7s linear infinite;
    z-index: -1;
}
.auth__card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    border: 1px solid rgba(30, 58, 138, .10);
    pointer-events: none;
    z-index: -1;
}
@keyframes auth-border-spin {
    from { --auth-angle: 0deg; } to { --auth-angle: 360deg; }
}
@media (prefers-reduced-motion: reduce) { .auth__card-border { animation: none; } }

.auth__header { text-align: center; margin-bottom: clamp(0.75rem, 1.5vw, 1rem); }
.auth__brand {
    display: inline-block;
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    letter-spacing: 0.10em;
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    background-image: linear-gradient(
        180deg, #1e3a8a 0%, #2563eb 12.5%, #3b82f6 25%, #2563eb 37.5%,
        #1e3a8a 50%, #2563eb 62.5%, #3b82f6 75%, #2563eb 87.5%, #1e3a8a 100%
    );
    background-size: 100% 200%;
    background-position: 0 0%;
    background-repeat: no-repeat;
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    filter:
        drop-shadow(0 0 4px rgba(59, 130, 246, 0.35))
        drop-shadow(0 -2px 8px rgba(96, 165, 250, 0.22));
    animation:
        hero-fire           18s linear      infinite,
        auth-brand-cycle    18s ease-in-out infinite;
}
@keyframes auth-brand-cycle {
    0%   { clip-path: inset(0 100% 0 0); }
    22%  { clip-path: inset(0   0% 0 0); }
    78%  { clip-path: inset(0   0% 0 0); }
    100% { clip-path: inset(0 100% 0 0); }
}
@media (prefers-reduced-motion: reduce) { .auth__brand { animation: none; } }

.auth__title {
    text-align: center;
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    color: #0b1220;
    font-size: clamp(1.1rem, 2.2vw, 1.5rem);
    margin: 0 0 clamp(0.75rem, 1.5vw, 1.25rem);
}

.auth-form { display: flex; flex-direction: column; gap: clamp(1rem, 2vw, 1.25rem); }

.auth-form__intro {
    margin: 0 0 4px;
    color: #475569;
    font-size: 0.9rem;
    line-height: 1.5;
    text-align: center;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 0.85rem; font-weight: 600; color: #334155; letter-spacing: 0.01em; }
.req { color: var(--c-danger); margin-left: 2px; }

.field__control { position: relative; display: flex; min-width: 0; }
.field__input {
    flex: 1; width: 100%; min-width: 0;
    padding: clamp(10px, 1.5vw, 12px) clamp(10px, 1.5vw, 14px);
    font-size: clamp(0.88rem, 1.3vw, 0.95rem);
    color: #0f172a;
    background: #ffffff;
    border: 1.5px solid var(--c-border);
    border-radius: 10px;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit; line-height: 1.4;
}
.field__input::placeholder { color: #94a3b8; }
.field__input:focus {
    outline: none; border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}
.field.is-invalid .field__input { border-color: var(--c-danger); }
.field.is-valid   .field__input { border-color: var(--c-success); }

.field__error { color: var(--c-danger); font-size: 0.82rem; line-height: 1.4; }
.field__error:empty { display: none; }
.field__error--top:not(:empty) {
    background: var(--c-danger-soft);
    border-radius: 8px;
    padding: 10px 12px;
    border-left: 3px solid var(--c-danger);
    font-weight: 600;
}
.field__hint { color: #475569; font-size: 0.82rem; line-height: 1.4; }
.field__hint.is-success { color: var(--c-success); }

.field__eye {
    position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
    width: 36px; height: 36px;
    border: none; background: transparent; color: #64748b;
    border-radius: 8px; cursor: pointer;
    transition: color .15s, background .15s;
    display: block;
}
.field__eye:hover { color: #1e3a8a; background: rgba(15, 23, 42, .04); }
.field__eye-icon {
    position: absolute; top: 50%; left: 50%;
    width: 20px; height: 20px;
    transform: translate(-50%, -50%);
    transition: opacity .18s ease;
    pointer-events: none;
}
.field__eye-icon--show { opacity: 1; }
.field__eye-icon--hide { opacity: 0; }
.field__control.is-revealed .field__eye-icon--show { opacity: 0; }
.field__control.is-revealed .field__eye-icon--hide { opacity: 1; }

.field--with-action .field__input { padding-right: 144px; }
.field__action {
    position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
    height: calc(100% - 12px); padding: 0 14px;
    display: inline-flex; align-items: center; gap: 6px;
    border: none; border-radius: 8px;
    background: #1e3a8a; color: #ffffff;
    font-weight: 600; font-size: 0.85rem;
    cursor: pointer;
    transition: background .2s;
    font-family: inherit;
}
.field__action:hover:not(:disabled) { background: #1e40af; }
.field__action:disabled { background: #94a3b8; cursor: not-allowed; color: #e2e8f0; }
.field__action-icon { width: 16px; height: 16px; }
.field__action.is-sent { background: var(--c-success); }
.field__action.is-sent:hover:not(:disabled) { background: #15803d; }

@media (max-width: 540px) {
    .field--with-action .field__input { padding-right: 12px; }
    .field--with-action .field__control { flex-direction: column; gap: 8px; }
    .field__action {
        position: static; transform: none; height: auto;
        padding: 10px 14px; width: 100%; justify-content: center;
    }
}

.rules__hint {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 0.78rem;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.auth-form__submit {
    width: 100%;
    padding: 14px 18px;
    background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 100%);
    color: #ffffff;
    border: none; border-radius: 12px;
    font-weight: 700; font-size: 1rem;
    letter-spacing: 0.06em; text-transform: uppercase;
    cursor: pointer;
    transition: transform .15s, box-shadow .2s, opacity .15s;
    box-shadow: 0 8px 22px -8px rgba(30, 58, 138, .55);
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    margin-top: 8px;
    font-family: inherit;
}
.auth-form__submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px -10px rgba(30, 58, 138, .6);
}
.auth-form__submit:disabled {
    opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none;
}
.auth-form__spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-form__back-to-login {
    text-align: center; margin: 8px 0 0;
}
.auth-form__link {
    color: #1e3a8a; font-weight: 700; font-size: 0.88rem;
    border-bottom: 1px dashed rgba(30, 58, 138, 0.4);
    text-decoration: none;
}
.auth-form__link:hover { color: #2563eb; border-bottom-color: #2563eb; }

.code-modal[hidden] { display: none !important; }
.code-modal__alert[hidden] { display: none !important; }
.code-modal__status[hidden] { display: none !important; }

.code-modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: clamp(0.5rem, 2vw, 1.5rem);
    background: rgba(5, 11, 30, 0.86);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: code-modal-in 0.25s ease-out;
}
@keyframes code-modal-in { from { opacity: 0; } to { opacity: 1; } }

.code-modal__close {
    position: absolute;
    top: clamp(0.75rem, 2vw, 1.25rem);
    right: clamp(0.75rem, 2vw, 1.25rem);
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(30, 58, 138, 0.85);
    border: 2px solid rgba(96, 165, 250, 0.55);
    color: #e0e7ff; cursor: pointer; z-index: 2; padding: 0;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s, transform .2s;
}
.code-modal__close::before,
.code-modal__close::after {
    content: '';
    position: absolute;
    width: 18px; height: 2px;
    background: currentColor;
    border-radius: 2px;
}
.code-modal__close::before { transform: rotate(45deg); }
.code-modal__close::after  { transform: rotate(-45deg); }
.code-modal__close:hover { background: rgba(59, 130, 246, .95); transform: scale(1.06); }

.code-modal__panel {
    width: 100%; max-width: 100%;
    background: #ffffff;
    border-radius: clamp(10px, 2vw, 16px);
    padding: clamp(1rem, 4vw, 1.75rem);
    box-shadow: 0 30px 80px -20px rgba(0,0,0,0.5);
    text-align: center;
}
@media (min-width: 540px) { .code-modal__panel { max-width: 440px; padding: 1.75rem; } }
@media (min-width: 915px) { .code-modal__panel { max-width: 480px; padding: 2rem;    } }

.code-modal__alert {
    display: flex; align-items: center; gap: 10px;
    background: var(--c-danger-soft); color: #991b1b;
    border-left: 4px solid var(--c-danger);
    padding: 12px 14px; border-radius: 8px;
    text-align: left; font-size: 0.88rem; line-height: 1.4;
    margin-bottom: 16px;
}
.code-modal__alert svg { width: 20px; height: 20px; flex-shrink: 0; }

.code-modal__title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900; color: #0b1220;
    font-size: 1.4rem; margin: 0 0 8px;
}
.code-modal__sub {
    color: #475569; font-size: 0.9rem;
    margin: 0 0 22px; line-height: 1.5;
}
.code-modal__sub strong { color: #1e3a8a; word-break: break-all; }

.code-inputs {
    display: grid; grid-template-columns: repeat(6, 1fr);
    gap: clamp(4px, 1.2vw, 8px);
    margin-bottom: 18px;
}
@media (max-width: 314px) {
    .code-inputs { grid-template-columns: repeat(3, 1fr); gap: clamp(4px, 1.5vw, 6px); }
    .code-inputs input { font-size: clamp(1.2rem, 5vw, 1.7rem); }
}
.code-inputs input {
    width: 100%; aspect-ratio: 1 / 1;
    min-width: 0;
    border: 2px solid var(--c-border);
    border-radius: clamp(6px, 1.2vw, 10px);
    text-align: center;
    font-size: clamp(1rem, 4vw, 1.7rem);
    font-weight: 700; color: #0f172a;
    background: #ffffff;
    font-variant-numeric: tabular-nums;
    transition: border-color .15s, box-shadow .15s, background .15s;
    font-family: 'Courier New', monospace;
    padding: 0;
}
.code-inputs input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
}
.code-inputs.is-invalid input {
    border-color: var(--c-danger);
    background: var(--c-danger-soft);
    color: #991b1b;
    animation: code-shake 0.45s ease;
}
.code-inputs.is-valid input {
    border-color: var(--c-success);
    background: var(--c-success-soft);
    color: #14532d;
}
@keyframes code-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.code-modal__actions {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; margin: 0 0 8px;
}
.code-modal__resend {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    border: 1.5px solid #cbd5e1;
    background: #ffffff; color: #1e3a8a;
    border-radius: 10px; cursor: pointer;
    font-weight: 600; font-size: 0.85rem;
    transition: all .15s;
    font-family: inherit;
}
.code-modal__resend svg { width: 16px; height: 16px; }
.code-modal__resend:hover:not(:disabled) {
    border-color: #1e3a8a; background: rgba(30,58,138,.06);
}
.code-modal__resend:disabled { color: #94a3b8; cursor: not-allowed; background: #f1f5f9; }

.code-modal__status {
    margin-top: 14px; padding: 12px;
    border-radius: 10px;
    font-size: 0.9rem; font-weight: 600;
    text-align: center;
}
.code-modal__status.is-success { background: var(--c-success-soft); color: var(--c-success); }
.code-modal__status.is-error   { background: var(--c-danger-soft);  color: var(--c-danger);  }
