:root {
    color-scheme: dark;
    --background: #000;
    --field: #0d0d0f;
    --border: #292a2e;
    --text: #f5f5f7;
    --muted: #85858b;
    --button: #f5f5f7;
    --button-text: #050505;
    --danger: #ff696f;
    --success: #69d49f;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    min-height: 100%;
    background: var(--background);
    touch-action: pan-x pan-y;
    overscroll-behavior: none;
}

body {
    min-height: 100%;
    margin: 0;
    overflow-x: hidden;
    background: var(--background);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

body, body *:not(input) {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

img {
    pointer-events: none;
    -webkit-user-drag: none;
    user-drag: none;
}

.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
}

.auth-panel {
    width: min(100%, 390px);
    text-align: center;
}

.auth-logo {
    display: block;
    width: 88px;
    height: 88px;
    margin: 0 auto 22px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--field);
}

h1 {
    margin: 0 0 32px;
    font-size: clamp(28px, 8vw, 36px);
    line-height: 1.1;
    letter-spacing: -0.035em;
}

.auth-form {
    display: grid;
    gap: 12px;
    text-align: left;
}

.auth-form[hidden] { display: none; }

label {
    padding-left: 4px;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

input {
    width: 100%;
    min-height: 52px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    outline: none;
    background: var(--field);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

input:focus {
    border-color: #66676c;
    box-shadow: 0 0 0 3px rgb(255 255 255 / 7%);
}

input::placeholder { color: #66666c; }

#code {
    text-align: center;
    font-size: 27px;
    font-weight: 750;
    letter-spacing: 0.3em;
    padding-left: calc(16px + 0.3em);
}

button { touch-action: manipulation; }

.auth-mode-button {
    justify-self: center;
    width: auto;
    min-height: 36px;
    margin-top: -2px;
    padding: 0 14px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.primary-button, .secondary-button {
    width: 100%;
    min-height: 48px;
    padding: 0 20px;
    border-radius: 999px;
    font: inherit;
    font-size: 15px;
    font-weight: 750;
    cursor: pointer;
}

.primary-button {
    border: 0;
    background: var(--button);
    color: var(--button-text);
}

.secondary-button {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
}

button:active:not(:disabled) { opacity: 0.7; }
button:disabled { cursor: wait; opacity: 0.45; }

.code-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.email-hint {
    margin: 4px 0 0 4px;
    color: var(--muted);
    font-size: 13px;
}

.text-button {
    width: auto;
    min-height: 36px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
}

.auth-message {
    min-height: 21px;
    margin: 14px 0 0;
    color: var(--danger);
    text-align: center;
    font-size: 14px;
    line-height: 1.45;
}

.auth-message.is-success { color: var(--success); }

@media (max-width: 430px) {
    .auth-shell {
        place-items: start center;
        padding-top: max(76px, env(safe-area-inset-top));
    }

    .auth-logo { width: 80px; height: 80px; }
}
