/* Shared page atmosphere, followed by phone-specific refinements. */
html:not(.dark-mode) body {
    /* A broad, more pronounced blue glow that fades into the neutral page surface. */
    background: radial-gradient(ellipse 90% 150% at top left, rgba(147, 197, 253, .76) 0%, rgba(191, 219, 254, .42) 48%, rgba(244, 246, 248, 0) 88%), #f4f6f8;
    background-attachment: fixed;
}

/* Reuse the supplied SVG through a mask so each control's CSS color is retained. */
.dropdown-arrow {
    display: inline-block;
    flex: 0 0 auto;
    width: .7em;
    height: .7em;
    background-color: currentColor;
    -webkit-mask: url("dropdown-arrow.bfcc3920696d.svg") center / contain no-repeat;
    mask: url("dropdown-arrow.bfcc3920696d.svg") center / contain no-repeat;
}

/* Phone refinements */
@media (max-width: 700px) {
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        box-sizing: border-box;
        min-height: 100dvh;
        min-width: 0;
        overflow-x: hidden;
        padding: 16px;
    }

    button,
    input,
    select,
    textarea {
        font-size: 16px; /* Prevents iOS from zooming into form fields. */
    }

    /* Home */
    .page-shell {
        padding: 4px 0 28px;
    }

    .topbar {
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 20px;
    }

    .logo-wrap img {
        height: 58px;
    }

    .top-pill {
        max-width: 190px;
        padding: 8px 11px;
        font-size: .76rem;
        line-height: 1.25;
        text-align: right;
    }

    .hero-grid {
        gap: 14px;
    }

    .hero-card {
        min-height: auto;
        padding: 25px 22px;
        border-radius: 20px;
        gap: 28px;
    }

    .primary-title {
        font-size: clamp(2.6rem, 16vw, 3.5rem);
    }

    .primary-subtitle {
        font-size: 1rem;
    }

    .card-copy {
        line-height: 1.6;
    }

    .cta-btn {
        width: 100%;
        min-height: 46px;
    }

    /* Shared application headers and content surfaces */
    .master-container {
        width: 100%;
        padding: 8px 0 28px;
    }

    .header-flex {
        align-items: flex-start;
        flex-direction: column;
        gap: 13px;
        margin-bottom: 22px;
    }

    h1,
    h1.page-title {
        font-size: clamp(1.85rem, 9vw, 2.35rem);
        line-height: 1.05;
    }

    .back-link {
        min-height: 42px;
    }

    .profile-card {
        padding: 24px 18px;
        border-radius: 16px;
    }

    .section-title {
        font-size: 1.12rem;
        margin-top: 26px;
        margin-bottom: 17px;
    }

    .modern-radio {
        flex-wrap: wrap;
        gap: 10px 16px;
    }

    .select2-container {
        max-width: 100%;
    }

    .select2-dropdown {
        max-width: calc(100vw - 32px);
    }

    /* Explore and saved opportunity listings */
    .brand-logo {
        position: static !important;
        display: inline-block;
        width: fit-content;
        text-align: left;
        margin: 0 0 8px;
    }

    .brand-logo img {
        width: 170px !important;
        height: auto !important;
    }

    /* Keep the home logo and platform label on one line on narrow screens. */
    .topbar .home-logo {
        flex: 0 1 auto;
        margin-bottom: 0;
    }

    .topbar .home-logo img {
        width: clamp(120px, 42vw, 170px) !important;
    }

    .topbar .top-pill {
        flex: 1 1 0;
        min-width: 0;
    }

    .auth-nav {
        justify-content: flex-end;
        margin: -68px 0 20px;
    }

    .auth-nav .dropdown,
    .auth-nav .dropdown-button {
        width: auto;
    }

    .auth-nav .dropdown-button {
        min-height: 38px;
        padding: 8px 11px;
        white-space: nowrap;
    }

    .auth-nav .dropdown-content {
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        left: 0;
        min-width: 0;
        max-height: min(360px, calc(100vh - 32px));
        overflow-y: auto;
    }

    .page-title {
        margin-top: 50px;
        text-align: center;
    }

    .page-tagline {
        font-size: .68rem;
        line-height: 1.45;
        letter-spacing: .08em !important;
    }

    .filter-panel {
        padding: 20px 16px;
        margin-bottom: 36px;
        border-radius: 16px;
    }

    input[name="search"] {
        min-height: 48px;
        margin-bottom: 16px;
        padding: 12px 14px;
    }

    .filter-container {
        align-items: stretch;
        gap: 10px;
    }

    .filter-container > * {
        width: 100%;
    }

    .sort-box {
        justify-content: flex-start;
        width: fit-content !important;
        min-height: 40px;
        padding: 4px 8px;
        gap: 5px;
        font-size: .78rem;
    }

    .sort-box select {
        font-size: .78rem;
    }

    .filter-group,
    .dropdown,
    .dropdown-button {
        width: 100%;
    }

    .filter-group .dropdown-button,
    .dropdown-button {
        min-height: 44px;
        text-align: left;
    }

    .filter-group .dropdown-content {
        position: static;
        width: 100%;
        max-height: 220px;
        margin-top: 7px;
        box-shadow: none;
    }

    .view-selector {
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
        margin-top: 16px;
        
    }

    .view-button {
        width: auto !important;
        height: 48px !important;
        min-height: 48px;
        flex: 0 1 auto;
        padding: 6px 8px;
        font-size: .94rem;
        letter-spacing: .015em;
        white-space: nowrap;
    }

    .button-group {
        flex-direction: column;
        gap: 10px;
        margin-top: 24px;
    }

    .button-group .btn-submit,
    .button-group .btn-reset,
    .btn-submit {
        width: 100%;
        min-height: 42px;
        padding: 8px 14px;
        box-sizing: border-box;
        justify-content: center;
    }

    .button-group .preferences-button {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    .opportunities-grid {
        gap: 16px;
        margin-top: 16px;
    }

    .opp-card {
        padding: 19px;
        border-radius: 16px;
    }

    .card-title {
        font-size: 1.1rem;
    }

    .card-inst {
        line-height: 1.45;
    }

    .card-specs {
        padding: 11px 12px;
        margin-bottom: 16px;
    }

    .card-specs p {
        display: block;
        margin: 8px 0;
    }

    .card-specs p span {
        display: block;
        margin-top: 2px;
    }

    .btn-know-more {
        width: 100%;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .results-count,
    .subtitle {
        font-size: .95rem;
        line-height: 1.5;
        margin-bottom: 18px;
    }

    /* Progress board becomes a deliberate horizontal board, not a squeezed grid. */
    .kanban-board {
        grid-template-columns: repeat(4, minmax(272px, 82vw));
        gap: 14px;
        margin: 0 -16px;
        padding: 4px 16px 18px;
        scroll-snap-type: x proximity;
        scrollbar-color: #94a3b8 transparent;
    }

    .kanban-col {
        min-width: 0;
        padding: 14px;
        scroll-snap-align: start;
    }

    .mini-card {
        padding: 14px;
    }

    /* Detail and authentication flows */
    .detail-card {
        padding: 23px 18px;
        border-radius: 16px;
    }

    .detail-card p {
        padding: 12px 0;
        overflow-wrap: anywhere;
    }

    .official-link {
        width: 100%;
        min-height: 46px;
        justify-content: center;
        text-align: center;
    }

    .auth-card,
    .card {
        box-sizing: border-box;
        width: 100%;
        max-width: none;
        margin: 58px auto 20px;
        padding: 25px 20px;
        border-radius: 16px;
    }

    .auth-card h2,
    .card h2 {
        font-size: 1.5rem;
        line-height: 1.2;
    }

    .form-group input,
    .auth-card input,
    .card input {
        width: 100%;
        min-height: 46px;
        box-sizing: border-box;
    }

    .auth-card .btn-submit,
    .card .btn {
        width: 100%;
        min-height: 46px;
    }

    #theme-toggle {
        top: 10px !important;
        right: 10px !important;
        padding: 7px 9px !important;
    }
}

@media (max-width: 380px) {
    .top-pill {
        max-width: 145px;
        font-size: .7rem;
    }

    .profile-card,
    .detail-card,
    .auth-card,
    .card {
        padding-left: 16px;
        padding-right: 16px;
    }
}
