/* IMEPG mobile shell — applies below 768px only. Desktop markup and styles are untouched. */
.ms-shell,
.ms-profile,
.ms-tabs {
    display: none;
}

@media (max-width: 767px) {
    :root {
        --ms-indigo: #2f2a6b;
        --ms-indigo-2: #463bb0;
        --ms-ink: #1d1b2f;
        --ms-muted: #6f6c85;
        --ms-paper: #f5f4fb;
        --ms-card: #ffffff;
        --ms-line: #e9e6f4;
        --ms-lilac: #ece9fd;
        --ms-mint: #e2f6ee;
        --ms-peach: #fdeee4;
        --ms-sky: #e6f0fe;
    }

    /* ---- public site: replace the desktop chrome with the shell ---- */
    .ms-public .announcement,
    .ms-public .site-header,
    .ms-public .site-footer {
        display: none !important;
    }

    .ms-public,
    .ms-portal {
        background: var(--ms-paper);
    }

    .ms-portal .ep-topbar,
    .ms-portal .ep-footer {
        display: none !important;
    }

    .ms-portal .ep-main {
        padding: 14px 16px 8px;
    }

    .ms-portal .ep-page-heading {
        margin: 0 0 14px;
    }

    .ms-portal .ep-page-heading h1 {
        font-size: 1.45rem;
        line-height: 1.2;
    }

    .ms-portal .ep-page-heading p {
        font-size: 0.95rem;
    }

    .ms-portal .ep-eyebrow {
        font-size: 0.65rem;
    }

    .ms-shell {
        display: block;
        position: relative;
        z-index: 2;
    }

    body {
        padding-bottom: calc(86px + env(safe-area-inset-bottom));
        overflow-x: hidden;
    }

    /* ---- curved indigo header ---- */
    .ms-hero {
        position: relative;
        padding: calc(14px + env(safe-area-inset-top)) 18px 40px;
        color: #fff;
        background:
            radial-gradient(120% 90% at 100% 0%, rgba(126, 108, 255, 0.55), transparent 62%),
            linear-gradient(150deg, var(--ms-indigo) 8%, var(--ms-indigo-2) 92%);
        border-radius: 0 0 30px 30px;
        overflow: hidden;
    }

    .ms-hero::before {
        content: "";
        position: absolute;
        inset: auto -30% -58% -30%;
        height: 78%;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.06);
        pointer-events: none;
    }

    .ms-hero-top {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .ms-brand {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        color: #fff;
        font-family: "Plus Jakarta Sans", sans-serif;
        font-weight: 800;
        letter-spacing: 0.02em;
        text-decoration: none;
    }

    .ms-brand img {
        width: 30px;
        height: 30px;
        border-radius: 9px;
        background: #fff;
        padding: 3px;
    }

    .ms-hero-actions {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .ms-round {
        display: grid;
        place-items: center;
        width: 40px;
        height: 40px;
        min-width: 40px;
        border: 1px solid rgba(255, 255, 255, 0.28);
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.14);
        color: #fff;
        padding: 0;
        cursor: pointer;
        text-decoration: none;
    }

    .ms-round svg {
        width: 19px;
        height: 19px;
    }

    .ms-round .ms-avatar {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        object-fit: cover;
        border: 1px solid rgba(255, 255, 255, 0.6);
    }

    .ms-round .ms-avatar-fallback {
        display: grid;
        place-items: center;
        width: 30px;
        height: 30px;
        border-radius: 50%;
        background: #fff;
        color: var(--ms-indigo);
        font-weight: 700;
        font-size: 0.8rem;
    }

    .ms-login {
        color: #fff;
        font-weight: 600;
        font-size: 0.9rem;
        text-decoration: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.5);
        padding-bottom: 2px;
    }

    .ms-eyebrow {
        position: relative;
        margin: 18px 0 2px;
        font-size: 0.72rem;
        letter-spacing: 0.14em;
        text-transform: uppercase;
        color: rgba(255, 255, 255, 0.72);
    }

    .ms-greeting {
        position: relative;
        margin: 0 0 14px;
        font-family: "Plus Jakarta Sans", sans-serif;
        font-size: 1.5rem;
        line-height: 1.22;
        font-weight: 700;
        color: #fff;
        max-width: 20ch;
    }

    .ms-search {
        position: relative;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 6px 6px 14px;
        background: #fff;
        border-radius: 999px;
        box-shadow: 0 10px 24px rgba(19, 14, 60, 0.22);
    }

    .ms-search > svg {
        width: 18px;
        height: 18px;
        color: var(--ms-muted);
        flex: none;
    }

    .ms-search input {
        flex: 1;
        min-width: 0;
        border: 0;
        background: transparent;
        font: inherit;
        font-size: 0.92rem;
        color: var(--ms-ink);
        padding: 8px 0;
    }

    .ms-search input:focus {
        outline: none;
    }

    .ms-search button {
        display: grid;
        place-items: center;
        width: 36px;
        height: 36px;
        border: 0;
        border-radius: 50%;
        background: var(--ms-indigo);
        color: #fff;
        cursor: pointer;
    }

    .ms-search button svg {
        width: 17px;
        height: 17px;
    }

    /* white arc sweeping under the indigo header */
    .ms-hero-arc {
        position: absolute;
        left: -12%;
        right: -12%;
        bottom: -26px;
        height: 52px;
        background: var(--ms-paper);
        border-radius: 50% 50% 0 0 / 100% 100% 0 0;
        pointer-events: none;
    }

    /* ---- quick action cards ---- */
    .ms-quick {
        position: relative;
        z-index: 3;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
        margin: -6px 14px 0;
    }

    .ms-quick a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        padding: 12px 4px 10px;
        background: var(--ms-card);
        border: 1px solid var(--ms-line);
        border-radius: 16px;
        color: var(--ms-ink);
        text-align: center;
        text-decoration: none;
        font-size: 0.68rem;
        font-weight: 600;
        line-height: 1.25;
        box-shadow: 0 6px 16px rgba(38, 30, 90, 0.06);
    }

    .ms-quick .ms-chip {
        display: grid;
        place-items: center;
        width: 38px;
        height: 38px;
        border-radius: 12px;
        color: var(--ms-indigo);
    }

    .ms-quick .ms-chip svg {
        width: 19px;
        height: 19px;
    }

    .ms-quick a:nth-child(1) .ms-chip { background: var(--ms-lilac); }
    .ms-quick a:nth-child(2) .ms-chip { background: var(--ms-mint); }
    .ms-quick a:nth-child(3) .ms-chip { background: var(--ms-peach); }
    .ms-quick a:nth-child(4) .ms-chip { background: var(--ms-sky); }

    /* ---- bottom tab bar with centre action ---- */
    .ms-tabs {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        align-items: end;
        padding: 8px 6px calc(6px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.97);
        border-top: 1px solid var(--ms-line);
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 28px rgba(30, 24, 70, 0.1);
        backdrop-filter: blur(12px);
    }

    .ms-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-end;
        gap: 3px;
        min-height: 48px;
        padding: 4px 2px;
        border: 0;
        background: none;
        color: #8b879e;
        font: inherit;
        font-size: 0.63rem;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
    }

    .ms-tab svg {
        width: 21px;
        height: 21px;
    }

    .ms-tab[aria-current="page"],
    .ms-tab.is-active {
        color: var(--ms-indigo);
    }

    .ms-tab[aria-current="page"] svg,
    .ms-tab.is-active svg {
        stroke-width: 2.1;
    }

    .ms-tab-fab {
        position: relative;
        top: -20px;
        justify-self: center;
        width: 56px;
        height: 56px;
        min-height: 56px;
        padding: 0;
        border-radius: 50%;
        background: linear-gradient(145deg, var(--ms-indigo-2), var(--ms-indigo));
        color: #fff;
        border: 5px solid var(--ms-paper);
        box-shadow: 0 10px 22px rgba(47, 42, 107, 0.34);
    }

    .ms-tab-fab svg {
        width: 23px;
        height: 23px;
    }

    .ms-tab-fab span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .ms-tab-count {
        position: absolute;
        top: 2px;
        right: calc(50% - 20px);
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 999px;
        background: #e5484d;
        color: #fff;
        font-size: 0.6rem;
        line-height: 16px;
        text-align: center;
    }

    /* ---- profile screen ---- */
    .ms-profile {
        position: fixed;
        inset: 0;
        z-index: 90;
        display: flex;
        flex-direction: column;
        background: var(--ms-paper);
        transform: translateY(100%);
        visibility: hidden;
        transition: transform 0.28s ease, visibility 0.28s;
        overscroll-behavior: contain;
    }

    .ms-profile.is-open {
        transform: translateY(0);
        visibility: visible;
    }

    .ms-profile-head {
        position: relative;
        padding: calc(12px + env(safe-area-inset-top)) 18px 46px;
        color: #fff;
        background:
            radial-gradient(120% 90% at 0% 0%, rgba(126, 108, 255, 0.5), transparent 60%),
            linear-gradient(150deg, var(--ms-indigo) 10%, var(--ms-indigo-2) 90%);
        border-radius: 0 0 30px 30px;
        overflow: hidden;
    }

    .ms-profile-head::after {
        content: "";
        position: absolute;
        left: -12%;
        right: -12%;
        bottom: -24px;
        height: 48px;
        background: var(--ms-paper);
        border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    }

    .ms-profile-bar {
        position: relative;
        z-index: 2;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .ms-profile-bar h2 {
        margin: 0;
        font-family: "Plus Jakarta Sans", sans-serif;
        font-size: 1.02rem;
        font-weight: 700;
        color: #fff;
    }

    .ms-profile-identity {
        position: relative;
        z-index: 2;
        display: flex;
        align-items: center;
        gap: 14px;
        margin-top: 22px;
    }

    .ms-profile-avatar {
        width: 68px;
        height: 68px;
        border-radius: 50%;
        object-fit: cover;
        border: 3px solid rgba(255, 255, 255, 0.85);
        background: #fff;
        flex: none;
    }

    .ms-profile-avatar-fallback {
        display: grid;
        place-items: center;
        width: 68px;
        height: 68px;
        border-radius: 50%;
        border: 3px solid rgba(255, 255, 255, 0.85);
        background: #fff;
        color: var(--ms-indigo);
        font-family: "Plus Jakarta Sans", sans-serif;
        font-size: 1.5rem;
        font-weight: 800;
        flex: none;
    }

    .ms-profile-identity strong {
        display: block;
        font-family: "Plus Jakarta Sans", sans-serif;
        font-size: 1.12rem;
        line-height: 1.25;
        color: #fff;
    }

    .ms-profile-identity small {
        display: block;
        margin-top: 3px;
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.78);
        word-break: break-word;
    }

    .ms-profile-edit {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        margin-top: 8px;
        padding: 5px 11px;
        border: 1px solid rgba(255, 255, 255, 0.4);
        border-radius: 999px;
        color: #fff;
        font-size: 0.72rem;
        font-weight: 600;
        text-decoration: none;
    }

    .ms-profile-body {
        flex: 1;
        overflow-y: auto;
        padding: 6px 16px calc(28px + env(safe-area-inset-bottom));
        -webkit-overflow-scrolling: touch;
    }

    .ms-profile-group {
        margin: 0 0 14px;
        padding: 6px 4px;
        background: var(--ms-card);
        border: 1px solid var(--ms-line);
        border-radius: 18px;
        box-shadow: 0 8px 20px rgba(38, 30, 90, 0.05);
    }

    .ms-profile-row {
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 52px;
        padding: 8px 12px;
        color: var(--ms-ink);
        font-size: 0.9rem;
        font-weight: 600;
        text-decoration: none;
        background: none;
        border: 0;
        width: 100%;
        font-family: inherit;
        text-align: left;
        cursor: pointer;
    }

    .ms-profile-row + .ms-profile-row {
        border-top: 1px solid #f1eff9;
    }

    .ms-profile-row .ms-chip {
        display: grid;
        place-items: center;
        width: 36px;
        height: 36px;
        min-width: 36px;
        border-radius: 11px;
        background: var(--ms-lilac);
        color: var(--ms-indigo);
    }

    .ms-profile-row .ms-chip svg {
        width: 18px;
        height: 18px;
    }

    .ms-profile-row small {
        display: block;
        font-size: 0.72rem;
        font-weight: 500;
        color: var(--ms-muted);
        margin-top: 1px;
    }

    .ms-profile-row .ms-chevron {
        margin-left: auto;
        color: #b3afc6;
        font-size: 1.05rem;
        line-height: 1;
    }

    .ms-profile-signout {
        margin: 4px 0 0;
    }

    .ms-profile-signout button {
        width: 100%;
        min-height: 50px;
        border: 1px solid #f0d6d8;
        border-radius: 16px;
        background: #fff;
        color: #b4232a;
        font: inherit;
        font-weight: 650;
        cursor: pointer;
    }

    .ms-profile-guest-cta {
        display: grid;
        gap: 10px;
        margin: 0 0 14px;
    }

    .ms-profile-guest-cta a {
        display: grid;
        place-items: center;
        min-height: 50px;
        border-radius: 16px;
        font-weight: 700;
        text-decoration: none;
        background: var(--ms-indigo);
        color: #fff;
    }

    .ms-profile-guest-cta a.is-ghost {
        background: #fff;
        color: var(--ms-indigo);
        border: 1px solid var(--ms-line);
    }

    .ms-profile-note {
        margin: 2px 4px 16px;
        font-size: 0.76rem;
        line-height: 1.5;
        color: var(--ms-muted);
    }

    /* keep page content clear of the arc and cards */
    .ms-public main {
        padding-top: 16px;
    }

    .ms-public .container {
        padding-left: 16px;
        padding-right: 16px;
    }

    .ms-public .section {
        padding-top: 26px;
        padding-bottom: 26px;
    }

    .ms-public .hero-grid {
        grid-template-columns: 1fr;
        gap: 26px;
        min-height: 0;
        padding-top: 26px;
        padding-bottom: 34px;
    }

    .ms-public .hero-copy h1 {
        font-size: clamp(30px, 8.6vw, 38px);
        line-height: 1.14;
        letter-spacing: -1.2px;
    }

    .ms-public .hero-description {
        font-size: 16px;
        line-height: 1.72;
        margin-top: 16px;
    }

    .ms-public .hero-buttons {
        flex-wrap: wrap;
    }

    .ms-public .hero-visual {
        margin-left: 0;
    }

    .ms-public .hero-photo {
        height: 260px;
        border-radius: 12px 12px 54px 12px;
    }

    .ms-public .section h2 {
        font-size: clamp(24px, 6.4vw, 30px);
        line-height: 1.2;
    }

    .ms-auth .ms-hero {
        padding-bottom: 26px;
        border-radius: 0 0 22px 22px;
    }

    .ms-auth .ms-eyebrow,
    .ms-auth .ms-greeting,
    .ms-auth .ms-search,
    .ms-auth .ms-hero-arc {
        display: none;
    }
}

@media (max-width: 380px) {
    .ms-quick {
        gap: 6px;
        margin-left: 10px;
        margin-right: 10px;
    }

    .ms-quick a {
        font-size: 0.62rem;
        padding: 10px 2px 8px;
    }

    .ms-quick .ms-chip {
        width: 34px;
        height: 34px;
    }

    .ms-greeting {
        font-size: 1.35rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ms-profile {
        transition: none;
    }
}
