:root {
    --primary-color: #36186B;
    --link-color: #6A22C9;
    --title-color: #1B191D;
    --text-color: #3F3D44;
    --label-color: #65676E;
    --icon-color: #6B6970;
    --border-color: #CCCBD0;
    --page-bg: #ffffff;
    --readonly-bg: #EDEDED;
    --error-color: #C63203;
    --icon-error: url("data:image/svg+xml,%3Csvg width='16' height='16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M8 14.667A6.667 6.667 0 1 0 8 1.333a6.667 6.667 0 0 0 0 13.334z' fill='%23C63203' stroke='%23C63203' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M8 4.583a.75.75 0 0 1 .75.75V8a.75.75 0 0 1-1.5 0V5.333a.75.75 0 0 1 .75-.75z' fill='%23fff'/%3E%3Cpath d='M8.667 10.667a.667.667 0 1 1-1.334 0 .667.667 0 0 1 1.334 0z' fill='%23fff'/%3E%3C/svg%3E");
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    background: var(--page-bg);
    color: var(--text-color);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 400px;
    padding: 40px 40px 48px;
    text-align: center;
}

.header {
    margin-bottom: 8px;
}

.logo {
    height: 32px;
    width: auto;
    display: block;
    margin: 0 auto;
}

h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--title-color);
    margin: 24px 0 16px;
    line-height: 1.5;
}

.subtitle {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-color);
    margin-bottom: 24px;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 24px;
    text-align: left;
}

input[type="email"],
input[type="text"],
input[type="password"] {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background-color: #fff;
    color: var(--title-color);
}

input[type="email"]:focus,
input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--link-color);
    box-shadow: 0 0 0 1px var(--link-color);
}

input::placeholder {
    color: var(--label-color);
    font-weight: 400;
}

.field {
    position: relative;
}

.field label {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    line-height: 1;
    color: var(--label-color);
    background: #fff;
    padding: 0 4px;
    pointer-events: none;
    transition: top 0.15s ease, font-size 0.15s ease, color 0.15s ease;
    max-width: calc(100% - 32px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.field input:focus ~ label,
.field input:not(:placeholder-shown) ~ label {
    top: 0;
    font-size: 12px;
    color: var(--link-color);
}

.field.with-toggle input {
    padding-right: 44px;
}

/* Error state */
.form-group.error .field input {
    border-color: var(--error-color);
    box-shadow: 0 0 0 1px var(--error-color);
}

.form-group.error .field input:focus ~ label,
.form-group.error .field input:not(:placeholder-shown) ~ label {
    color: var(--error-color);
}

.error-message {
    display: none;
    align-items: center;
    color: var(--error-color);
    font-size: 14px;
    line-height: 1.4;
    margin-top: 8px;
}

.error-message::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    flex-shrink: 0;
    background-image: var(--icon-error);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.form-group.error .error-message {
    display: flex;
}

.password-toggle {
    position: absolute;
    right: 0;
    top: 0;
    width: 44px;
    height: 52px;
    cursor: pointer;
    color: var(--icon-color);
    background: none;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

.edit-button {
    background: none;
    border: none;
    color: var(--link-color);
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: 3px;
    text-decoration: none;
    flex-shrink: 0;
}

.edit-button:hover {
    background-color: rgba(106, 34, 201, 0.08);
}

.readonly-display {
    height: 52px;
    padding: 0 16px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    text-align: left;
    color: var(--title-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.button-primary {
    width: 100%;
    height: 52px;
    padding: 4px 16px;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 9999px;
    font-size: 16px;
    font-weight: 400;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.15s ease;
    margin-top: 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.button-primary:hover {
    background-color: #2a1252;
}

.button-primary:active {
    background-color: #1f0e3d;
}

.link {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    padding: 2px;
    border-radius: 9999px;
}

.link:hover {
    text-decoration: underline;
}

.link-block {
    display: block;
    text-align: left;
}

.centered-link {
    display: inline-block;
    margin-top: 24px;
}

.resend-text {
    font-size: 14px;
    color: var(--text-color);
    margin-top: 24px;
}

.radio-group {
    margin-bottom: 24px;
}

.radio-option {
    display: flex;
    align-items: center;
    height: 60px;
    padding: 0 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    background-color: #fff;
}

.radio-option input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    border: 1px solid var(--primary-color);
    border-radius: 50%;
    margin: 0;
    margin-left: 16px;
    flex-shrink: 0;
    position: relative;
    cursor: pointer;
}

.radio-option input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--primary-color);
}

.radio-label {
    font-size: 16px;
    font-weight: 400;
    color: var(--title-color);
    cursor: pointer;
    flex: 1;
    text-align: left;
}

.help-text {
    font-size: 16px;
    color: var(--text-color);
    margin-bottom: 24px;
    line-height: 1.5;
}

.text-left {
    text-align: left;
}

/* Screen mount/transition */
.screen {
    animation: fade-in 0.2s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Loading spinner shown between steps */
.spinner-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 360px;
}

.spinner {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    /* Comet-tail ring: rounded head (radial dot) + fading conic trail, masked to a 9px ring. */
    background:
        radial-gradient(farthest-side, var(--primary-color) 94%, transparent) top center/14px 14px no-repeat,
        conic-gradient(transparent 25%, var(--primary-color));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 14px), #000 calc(100% - 14px));
            mask: radial-gradient(farthest-side, transparent calc(100% - 14px), #000 calc(100% - 14px));
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
    body {
        align-items: flex-start;
    }

    .container {
        padding: 32px 24px 40px;
    }
}
