:root {
    --bg: #f5f5f3;
    --surface: #ffffff;
    --surface-alt: #fafaf9;
    --text: #111111;
    --text-soft: #747474;
    --border: #e5e5e5;
    --primary: #111111;
    --primary-contrast: #ffffff;
    --danger-bg: #fff4f4;
    --danger: #9b1c1c;
    --success-bg: #f1faf3;
    --success: #236b35;
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --shadow: 0 8px 24px rgba(17, 17, 17, 0.06);
    --app-width: 720px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.auth-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(245, 245, 243, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(229, 229, 229, 0.9);
}

.auth-brand {
    width: min(var(--app-width), 100%);
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top) + 1rem) 1rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.auth-brand-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: var(--primary-contrast);
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.auth-brand-icon svg {
    width: 26px;
    height: 26px;
}

.auth-brand strong,
.auth-brand small {
    display: block;
}

.auth-brand strong {
    font-size: 1.05rem;
    font-weight: 700;
}

.auth-brand small {
    color: var(--text-soft);
    font-size: 0.9rem;
}

.auth-main {
    width: 100%;
    max-width: var(--app-width);
    margin: 0 auto;
    padding: 3rem 1rem calc(3rem + env(safe-area-inset-bottom));
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.auth-intro {
    margin-bottom: 1.75rem;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 0.5rem;
    color: var(--text-soft);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-intro h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.8rem, 5vw, 2.25rem);
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.auth-intro p {
    margin: 0;
    color: var(--text-soft);
}

.auth-form {
    display: grid;
    gap: 1rem;
}

.field {
    display: grid;
    gap: 0.45rem;
}

.field label {
    font-weight: 600;
    font-size: 0.94rem;
}

.field small {
    color: var(--text-soft);
    font-size: 0.84rem;
}

.field input {
    width: 100%;
    min-height: 52px;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
    border-color: #111111;
    box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 5.2rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.65rem;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--text-soft);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
}

.primary-button {
    width: 100%;
    min-height: 52px;
    margin-top: 0.25rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--primary);
    border-radius: var(--radius-lg);
    background: var(--primary);
    color: var(--primary-contrast);
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.primary-button:hover {
    opacity: 0.92;
}

.primary-button:active {
    transform: translateY(1px);
}

.primary-button:disabled {
    opacity: 0.55;
    cursor: wait;
}

.text-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

.auth-switch {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    color: var(--text-soft);
    font-size: 0.92rem;
}

.auth-switch .text-button {
    color: var(--text);
}

.auth-message {
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 0.9rem;
}

.auth-message.error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: #f0cccc;
}

.auth-message.success {
    background: var(--success-bg);
    color: var(--success);
    border-color: #cce6d2;
}

.check-row {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.check-row input {
    margin-top: 0.25rem;
}

.confirmation-view {
    text-align: center;
}

.confirmation-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 1rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--success-bg);
    color: var(--success);
    font-size: 1.5rem;
    font-weight: 800;
}

.confirmation-view h2 {
    margin: 0 0 0.5rem;
    font-size: 1.35rem;
}

.confirmation-view p {
    margin: 0 0 1.5rem;
    color: var(--text-soft);
}

.auth-back {
    margin: 1rem 0 0;
    text-align: center;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.auth-back a:hover {
    color: var(--text);
}

.auth-footer {
    margin-top: auto;
    padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    color: var(--text-soft);
    font-size: 0.82rem;
    text-align: center;
}

@media (max-width: 480px) {
    .auth-main {
        padding-top: 1.5rem;
    }

    .auth-card {
        padding: 1.25rem;
        border-radius: var(--radius-lg);
    }

    .auth-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}
