:root {
    --card-max: 420px;
    --pad-desktop: 2.5rem;
    --pad-mobile: 1.25rem;
    --bg1: #1f1f1f;
    --bg2: #0a0a0a;
    --primary: #97cb5a;
    --primaryHover: #71cd05;
    --text: #111;
    --muted: #555;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

.connect-page {
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg1), var(--bg2));
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    gap: 18px;
}

.page-logo {
    display: flex;
    justify-content: center;
    width: 100%;
}

    .page-logo img {
        max-width: 240px;
        width: min(70vw, 240px);
        height: auto;
    }

.connect-card {
    width: 100%;
    max-width: var(--card-max);
    background: #ffffff;
    padding: var(--pad-desktop);
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    margin: 0 auto;
}

    .connect-card h1 {
        margin: 0 0 0.5rem;
        font-size: 1.6rem;
        color: var(--text);
    }

.subtitle {
    margin-bottom: 1.6rem;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.35;
}

.field {
    margin-bottom: 1.1rem;
}

    .field label {
        display: block;
        font-weight: 600;
        margin-bottom: 0.35rem;
        font-size: 0.95rem;
        color: var(--text);
    }

    .field input,
    .field select {
        width: 100%;
        padding: 0.85rem 0.9rem;
        border-radius: 10px;
        border: 1px solid #ccc;
        /* Prevent iOS zoom */
        font-size: 16px;
        line-height: 1.2;
        background: #fff;
        color: var(--text);
    }

        .field input:focus,
        .field select:focus {
            outline: none;
            border-color: #2563eb;
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
        }

    .field input:disabled {
        background: #f3f3f3;
        color: #888;
        cursor: not-allowed;
    }

/* Environment chooser select — green outline signals that choosing an option signs you straight in. */
.field select.env-select {
    border: 2px solid var(--primary);
    font-weight: 600;
}

    .field select.env-select:focus {
        border-color: var(--primaryHover);
        box-shadow: 0 0 0 3px rgba(151, 203, 90, 0.3);
    }

    .field select.env-select--go {
        border-color: var(--primaryHover);
        background: #f2fae9;
    }

.primary-btn {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.9rem;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

    .primary-btn:hover {
        background: var(--primaryHover);
    }

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

.secondary-btn {
    width: 100%;
    margin-top: 0.6rem;
    padding: 0.85rem;
    border: 1px solid #ccc;
    border-radius: 12px;
    background: #fff;
    color: #444;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

    .secondary-btn:hover {
        background: #f7f7f7;
    }

.link {
    display: inline-block;
    margin-top: 1rem;
    color: #2f7d31;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

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

.msg {
    margin-top: 1rem;
    padding: 0.85rem;
    border-radius: 10px;
    font-size: 0.95rem;
    line-height: 1.35;
}

    .msg.error {
        background: #fee2e2;
        color: #991b1b;
    }

    .msg.info {
        background: #e7f4e4;
        color: #2f6d2f;
    }

/* SSO divider + button */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    margin: 1.25rem 0 1rem;
}

    .divider::before,
    .divider::after {
        content: "";
        flex: 1;
        border-bottom: 1px solid #e2e2e2;
    }

    .divider span {
        padding: 0 0.75rem;
    }

.ms-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ccc;
    border-radius: 12px;
    background: #fff;
    color: #444;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

    .ms-btn:hover {
        background: #f7f7f7;
    }

    .ms-btn[aria-disabled="true"] {
        opacity: 0.55;
        cursor: not-allowed;
    }

.ms-icon {
    width: 18px;
    height: 18px;
}

/* Mobile tweaks */
@media (max-width: 480px) {
    .connect-page {
        justify-content: flex-start;
        padding-top: max(18px, env(safe-area-inset-top));
    }

    .connect-card {
        padding: var(--pad-mobile);
        border-radius: 14px;
    }

        .connect-card h1 {
            font-size: 1.35rem;
        }

    .subtitle {
        margin-bottom: 1.25rem;
    }

    .page-logo img {
        width: min(78vw, 260px);
    }
}

/* Short screens / keyboard open */
@media (max-height: 700px) {
    .connect-page {
        justify-content: flex-start;
    }
}
