 :root {
    --color-page-bg: #606073;
    --color-card-bg: #f5f5f7;
    --color-card-border: #d1d1d6;
    --color-heading: #1c1c1e;
    --color-subtext: #6e6e73;
    --color-surface-muted: #e8e8ed;
    --color-surface-border: #c7c7cc;
    --color-text-body: #3a3a3c;
    --color-input-bg: #ffffff;
    --color-placeholder: #aeaeb2;
    --color-accent: #abcdef; //#7f7f7f;
    --color-primary: #636366;
    --color-primary-hover: #8e8e93;
    --color-on-primary: #ffffff;
    --color-error: #c0392b;
    --color-focus-ring: rgba(127,127,127,0.18);
    --color-error-ring: rgba(192,57,43,0.15);
    --color-shadow: rgba(0,0,0,0.35);
 }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--color-page-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--color-heading);
    padding: 24px 16px;
}

.login-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-card-border);
    border-radius: 18px;
    padding: 48px 40px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 12px 40px var(--color-shadow);
    animation: fadeUp 0.35s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.logo-wrap { text-align: center; margin-bottom: 36px; }
.logo-wrap img { width: 180px; height: auto; }

h1 { font-size: 1.35rem; font-weight: 600; color: var(--color-heading); margin-bottom: 6px; text-align: center; }

.subtitle { font-size: 0.875rem; color: var(--color-subtext); text-align: center; margin-bottom: 28px; }

/* Secondary/hint copy nested inside .subtitle (e.g. "check your spam
   folder") — smaller than the surrounding subtitle text so it reads as
   a supporting aside rather than part of the primary message. */
.hint-text { display: block; margin-top: 4px; font-size: 0.8em; color: var(--color-subtext); }

#forgot-email-display,
#reset-email-display { color: var(--color-text-body); }

.email-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-surface-muted);
    border: 1px solid var(--color-surface-border);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}
.email-display span { color: var(--color-text-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-display button {
    background: none; border: none; color: var(--color-subtext); font-size: 0.78rem;
    cursor: pointer; padding: 0 0 0 10px; flex-shrink: 0;
    text-decoration: underline; transition: color 0.2s;
}
.email-display button:hover { color: var(--color-text-body); }

.form-group { margin-bottom: 18px; }

label {
    display: block; font-size: 0.78rem; font-weight: 600; color: var(--color-subtext);
    margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.06em;
}

input[type="email"],
input[type="password"],
input[type="text"]:not(.otp-digit) {
    width: 100%; background: var(--color-input-bg); border: 1px solid var(--color-surface-border); border-radius: 10px;
    color: var(--color-heading); font-size: 1rem; padding: 13px 16px; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s; -webkit-appearance: none;
}
input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:not(.otp-digit):focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}
input.input-error {
    border-color: var(--color-error) !important;
    box-shadow: 0 0 0 3px var(--color-error-ring) !important;
}
input::placeholder { color: var(--color-placeholder); }

/* Show/hide toggle button overlaid on password fields (see
   .password-field wrapper markup in the password/create-password/
   reset-password screens; toggle wired up in js/login.js). */
.password-field { position: relative; }
.password-field input[type="password"],
.password-field input[type="text"] {
    padding-right: 44px;
}
.password-toggle-btn {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: none;
    border: none;
    color: var(--color-subtext);
    cursor: pointer;
}
.password-toggle-btn:hover { color: var(--color-text-body); }
.password-toggle-btn svg {
    width: 20px; height: 20px; fill: none; stroke: currentColor;
    stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.password-toggle-btn .icon-eye-off { display: none; }
.password-toggle-btn[aria-pressed="true"] .icon-eye { display: none; }
.password-toggle-btn[aria-pressed="true"] .icon-eye-off { display: block; }

.field-error {
    display: none;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--color-error);
    padding-left: 2px;
}
.field-error.visible { display: block; }

.btn-primary {
    display: block; width: 100%; padding: 14px;
    background: var(--color-primary); color: var(--color-on-primary); border: none; border-radius: 10px;
    font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    letter-spacing: 0.03em; margin-top: 6px;
    position: relative;
}
.btn-primary:hover  { background: var(--color-primary-hover); }
.btn-primary:active { transform: scale(0.98); }

/* ── "Something is happening" loading state, toggled by login.js's
   beginButtonLoading()/beginFormLoading() on click/submit. Hides the
   button's own text and spins a small ring in its place; the button also
   gets disabled so it can't be double-clicked while a request is in flight. ── */
.is-loading {
    color: transparent !important;
    pointer-events: none;
    cursor: default;
}
.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border-radius: 50%;
    border: 2px solid transparent;
    animation: btn-spin 0.7s linear infinite;
}
.btn-primary.is-loading::after {
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
}
.text-link.is-loading,
.forgot-link.is-loading {
    position: relative;
    padding-right: 22px;
}
.text-link.is-loading::after,
.forgot-link.is-loading::after {
    color: var(--color-primary);
    border-color: var(--color-surface-border);
    border-top-color: currentColor;
    width: 14px;
    height: 14px;
    margin-top: -7px;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

.divider { border: none; border-top: 1px solid var(--color-card-border); margin: 28px 0; }

.forgot-link {
    display: block; text-align: center; color: var(--color-primary);
    font-size: 0.875rem; text-decoration: none; transition: color 0.2s;
}
.forgot-link:hover { color: var(--color-text-body); }

.forgot-panel { display: none; animation: fadeUp 0.3s ease both; }

.back-btn {
    background: none; border: none; color: var(--color-primary); font-size: 0.875rem;
    cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
    margin-bottom: 20px; padding: 0; transition: color 0.2s;
}
.back-btn:hover { color: var(--color-heading); }
.back-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.success-msg {
    display: none; text-align: center; padding: 16px;
    background: var(--color-surface-muted); border: 1px solid var(--color-surface-border);
    border-radius: 10px; color: var(--color-text-body); font-size: 0.9rem; line-height: 1.5;
}
.success-msg strong { display: block; color: var(--color-heading); margin-bottom: 4px; }

.text-link {
    margin-top: 10px;
    background: none;
    border: none;
    color: var(--color-primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.85rem;
}

.text-link:hover { color: var(--color-text-body); }

.otp-inputs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 4px;
}
.otp-digit {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    background: var(--color-input-bg);
    border: 1px solid var(--color-surface-border);
    border-radius: 10px;
    color: var(--color-heading);
    outline: none;
    -webkit-appearance: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.otp-digit:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}
.otp-digit.input-error {
    border-color: var(--color-error) !important;
    box-shadow: 0 0 0 3px var(--color-error-ring) !important;
}
@media (max-width: 480px) {
    .otp-digit { width: 40px; height: 48px; font-size: 1.25rem; }
    .otp-inputs { gap: 8px; }
}

@media (max-width: 480px) {
    .login-card { padding: 36px 24px 32px; }
}

