.sb-app-detail-v3,
.sb-launcher-v3,
.sb-app-detail-v3 *,
.sb-launcher-v3 * {
    box-sizing: border-box;
}

.sb-app-detail-v3,
.sb-launcher-v3 {
    /* .sb-app-button is shared with the catalogue, where these tokens are
       declared. Without them the primary "Play in browser" gradient resolved
       to nothing and the main call to action looked like plain text. */
    --apps-purple: #7c3aed;
    --apps-blue: #2563eb;
    --apps-cyan: #67e8f9;
    --apps-soft: #94a3b8;
    --apps-line-active: rgba(103, 232, 249, .48);

    --launcher-panel: rgba(11, 18, 40, .92);
    --launcher-line: rgba(148, 163, 184, .18);
    --launcher-muted: #cbd5e1;
    --launcher-soft: #94a3b8;
    --launcher-purple: #7c3aed;
    --launcher-blue: #2563eb;
    --launcher-cyan: #67e8f9;

    width: min(1220px, calc(100% - 28px));
    margin-inline: auto;
    color: #f8fafc;
}

.sb-app-detail-v3 {
    padding: clamp(30px, 5vw, 56px) 0 clamp(48px, 7vw, 80px);
}

.sb-detail-back-v3 {
    width: max-content;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 18px;
    color: var(--launcher-muted);
    font-weight: 800;
    text-decoration: none;
}

.sb-detail-back-v3:hover {
    color: #fff;
}

.sb-app-detail-v3__hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
    gap: clamp(26px, 5vw, 56px);
    align-items: center;
    padding: clamp(26px, 4.5vw, 48px);
    border: 1px solid var(--launcher-line);
    border-radius: 32px;
    background:
        radial-gradient(
            circle at 100% 0%,
            rgba(124, 58, 237, .15),
            transparent 35%
        ),
        var(--launcher-panel);
    box-shadow: 0 30px 90px rgba(2, 6, 23, .32);
}

.sb-app-detail-v3__badges,
.sb-app-detail-v3__roles {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.sb-app-detail-v3__badges span,
.sb-app-detail-v3__roles span {
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--launcher-muted);
    background: rgba(148, 163, 184, .11);
    font-size: .73rem;
    font-weight: 850;
}

.sb-app-detail-v3__badges span.is-ready {
    color: #bbf7d0;
    background: rgba(34, 197, 94, .13);
}

.sb-app-detail-v3 h1 {
    margin: 16px 0 0;
    color: #fff;
    font-size: clamp(2.3rem, 5vw, 3.9rem);
    line-height: 1.02;
    letter-spacing: -.045em;
    text-wrap: balance;
}

.sb-app-detail-v3__tagline {
    margin: 13px 0 0;
    color: #c4b5fd;
    font-size: 1.08rem;
    font-weight: 800;
    line-height: 1.45;
}

.sb-app-detail-v3__description,
.sb-app-detail-v3__content p {
    color: var(--launcher-muted);
    line-height: 1.72;
}

.sb-app-detail-v3__description {
    max-width: 690px;
    margin: 11px 0 0;
    font-size: 1.04rem;
}

.sb-app-detail-v3__facts {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin: 22px 0 0;
}

.sb-app-detail-v3__facts div {
    min-width: 132px;
    flex: 1 1 132px;
    padding: 13px 15px;
    border: 1px solid var(--launcher-line);
    border-radius: 16px;
    background: rgba(255, 255, 255, .04);
}

.sb-app-detail-v3__facts dt {
    color: var(--launcher-soft);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.sb-app-detail-v3__facts dd {
    margin: 4px 0 0;
    color: #fff;
    font-weight: 850;
}

.sb-app-detail-v3__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 24px;
}

/* The learner's action is the loudest thing in the hero. */
.sb-app-detail-v3__actions .sb-app-button--primary {
    gap: 9px;
    padding: 13px 26px;
    font-size: 1.02rem;
}

/* Admin access is present but deliberately quiet. */
.sb-app-detail-v3__admin {
    margin: 16px 0 0;
    padding-top: 15px;
    border-top: 1px solid var(--launcher-line);
    font-size: .84rem;
}

.sb-app-detail-v3__admin a {
    color: var(--launcher-soft);
    font-weight: 750;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sb-app-detail-v3__admin a:hover {
    color: var(--launcher-cyan);
}

.sb-app-detail-v3__media {
    min-width: 0;
    display: grid;
    place-items: center;
    padding: clamp(18px, 3vw, 30px);
    border: 1px solid var(--launcher-line);
    border-radius: 26px;
    background:
        radial-gradient(
            circle at 30% 20%,
            rgba(124, 58, 237, .18),
            transparent 62%
        ),
        rgba(255, 255, 255, .035);
}

.sb-app-detail-v3__media img {
    width: 100%;
    max-height: 330px;
    object-fit: contain;
    filter: drop-shadow(0 22px 40px rgba(2, 6, 23, .45));
}

.sb-app-detail-v3__content {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 18px;
    margin-top: 18px;
}

.sb-app-detail-v3__content article,
.sb-app-detail-v3__related {
    padding: clamp(20px, 4vw, 30px);
    border: 1px solid var(--launcher-line);
    border-radius: 24px;
    background: var(--launcher-panel);
}

.sb-app-detail-v3__eyebrow {
    margin: 0 0 8px;
    color: var(--launcher-cyan) !important;
    font-size: .73rem;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.sb-app-detail-v3__content h2,
.sb-app-detail-v3__related h2 {
    margin: 0;
    color: #fff;
    font-size: clamp(1.3rem, 2.4vw, 1.75rem);
    line-height: 1.15;
    letter-spacing: -.03em;
}

.sb-app-detail-v3__roles {
    margin-top: 18px;
}

.sb-app-detail-v3__note {
    margin-top: 15px;
    padding: 14px;
    border-left: 3px solid var(--launcher-cyan);
    border-radius: 0 13px 13px 0;
    color: var(--launcher-muted);
    background: rgba(103, 232, 249, .07);
    line-height: 1.6;
}

.sb-app-detail-v3__related {
    margin-top: 18px;
}

.sb-app-detail-v3__related > div {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 20px;
}

.sb-app-detail-v3__related a {
    min-width: 0;
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 11px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--launcher-line);
    border-radius: 16px;
    color: #fff;
    background: rgba(255, 255, 255, .035);
    text-decoration: none;
}

.sb-app-detail-v3__related a:hover {
    border-color: rgba(103, 232, 249, .35);
}

.sb-app-detail-v3__related img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.sb-app-detail-v3__related strong,
.sb-app-detail-v3__related small {
    display: block;
}

.sb-app-detail-v3__related small {
    margin-top: 4px;
    color: var(--launcher-soft);
}

.sb-launcher-v3 {
    width: min(1440px, calc(100% - 28px));
    padding: 16px 0 42px;
}

.sb-launcher-v3__header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    margin-bottom: 12px;
    padding: 12px 15px;
    border: 1px solid var(--launcher-line);
    border-radius: 18px;
    background: rgba(8, 14, 32, .92);
    box-shadow: 0 18px 55px rgba(2, 6, 23, .25);
}

.sb-launcher-v3__title {
    min-width: 0;
    display: flex;
    gap: 11px;
    align-items: center;
}

.sb-launcher-v3__back {
    min-height: 44px;
    flex: 0 0 auto;
    display: inline-flex;
    gap: 7px;
    align-items: center;
    padding: 0 14px 0 10px;
    border: 1px solid var(--launcher-line);
    border-radius: 12px;
    color: #fff;
    background: rgba(255, 255, 255, .045);
    font-size: .82rem;
    font-weight: 800;
    text-decoration: none;
}

.sb-launcher-v3__back:hover,
.sb-launcher-v3__back:focus-visible {
    border-color: rgba(103, 232, 249, .38);
    background: rgba(103, 232, 249, .08);
}

.sb-launcher-v3__identity {
    min-width: 0;
}

.sb-launcher-v3__identity p {
    margin: 0;
    color: var(--launcher-cyan);
    font-size: .66rem;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.sb-launcher-v3__identity h1 {
    overflow: hidden;
    margin: 3px 0 0;
    color: #fff;
    font-size: clamp(1.15rem, 2vw, 1.5rem);
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sb-launcher-v3__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
    justify-content: flex-end;
}

.sb-launcher-v3__controls button,
.sb-launcher-v3__controls a {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--launcher-line);
    border-radius: 11px;
    padding: 7px 11px;
    color: #fff;
    background: rgba(255, 255, 255, .045);
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.sb-launcher-v3__controls button:hover,
.sb-launcher-v3__controls a:hover {
    border-color: rgba(103, 232, 249, .38);
}

.sb-launcher-v3__state {
    display: inline-flex;
    gap: 7px;
    align-items: center;
    padding: 8px 13px;
    border-radius: 999px;
    color: #fde68a;
    background: rgba(245, 158, 11, .12);
    font-size: .72rem;
    font-weight: 850;
}

.sb-launcher-v3__state::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.sb-launcher-v3__state[data-state="loading"]::before {
    animation: sbLauncherPulse 1.1s ease-in-out infinite;
}

.sb-launcher-v3__state[data-state="ready"],
.sb-launcher-v3__state.is-ready {
    color: #bbf7d0;
    background: rgba(34, 197, 94, .13);
}

.sb-launcher-v3__state[data-state="failed"] {
    color: #fecaca;
    background: rgba(239, 68, 68, .14);
}

.sb-launcher-v3__notice {
    margin-bottom: 11px;
    padding: 12px 14px;
    border: 1px solid rgba(34, 197, 94, .25);
    border-radius: 13px;
    color: #bbf7d0;
    background: rgba(34, 197, 94, .08);
}

.sb-launcher-v3__notice.is-error {
    border-color: rgba(239, 68, 68, .28);
    color: #fecaca;
    background: rgba(239, 68, 68, .08);
}

.sb-launcher-v3__stage {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--launcher-line);
    border-radius: 22px;
    background: #020617;
    box-shadow: 0 30px 90px rgba(2, 6, 23, .4);
}

.sb-launcher-v3__stage iframe {
    width: 100%;
    height: clamp(560px, calc(100vh - 210px), 1020px);
    display: block;
    border: 0;
    background: #fff;
}

.sb-launcher-v3__stage:fullscreen,
.sb-launcher-v3__stage:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    border: 0;
    border-radius: 0;
}

.sb-launcher-v3__stage:fullscreen iframe,
.sb-launcher-v3__stage:-webkit-full-screen iframe {
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
}

.sb-launcher-v3__loading {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 9px;
    color: #fff;
    background: #020617;
    text-align: center;
    transition: opacity .25s ease;
}

.sb-launcher-v3__loading.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.sb-launcher-v3__loading strong {
    font-size: 1.06rem;
    letter-spacing: -.015em;
}

.sb-launcher-v3__loading span {
    color: var(--launcher-soft);
    font-size: .9rem;
}

.sb-launcher-v3__spinner {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.sb-launcher-v3__spinner span {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: linear-gradient(
        135deg,
        var(--launcher-purple),
        var(--launcher-cyan)
    );
    animation: sbLauncherBounce 1.05s ease-in-out infinite;
}

.sb-launcher-v3__spinner span:nth-child(2) {
    animation-delay: .14s;
}

.sb-launcher-v3__spinner span:nth-child(3) {
    animation-delay: .28s;
}

.sb-launcher-v3__failed {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 11px;
    padding: 28px;
    background: #020617;
    text-align: center;
}

.sb-launcher-v3__failed[hidden] {
    display: none;
}

.sb-launcher-v3__failed h2 {
    max-width: 22ch;
    margin: 0;
    color: #fff;
    font-size: clamp(1.5rem, 3.4vw, 2.1rem);
    line-height: 1.15;
    letter-spacing: -.035em;
}

.sb-launcher-v3__failed p {
    max-width: 46ch;
    margin: 0;
    color: var(--launcher-muted);
    line-height: 1.65;
}

.sb-launcher-v3__failed-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    justify-content: center;
    margin-top: 8px;
}

.sb-launcher-v3__failed-actions a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--launcher-line);
    border-radius: 12px;
    padding: 9px 16px;
    color: #fff;
    background: rgba(255, 255, 255, .045);
    font-weight: 800;
    text-decoration: none;
}

.sb-launcher-v3__failed-actions a:hover {
    border-color: rgba(103, 232, 249, .38);
}

.sb-launcher-v3__footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    margin-top: 12px;
    padding: 15px;
    border: 1px solid var(--launcher-line);
    border-radius: 17px;
    background: var(--launcher-panel);
}

.sb-launcher-v3__footer strong {
    color: #fff;
}

.sb-launcher-v3__footer p {
    margin: 4px 0 0;
    color: var(--launcher-soft);
    line-height: 1.5;
}

.sb-launcher-v3__complete {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    padding: 9px 15px;
    color: #fff;
    background: linear-gradient(
        135deg,
        var(--launcher-purple),
        var(--launcher-blue)
    );
    font: inherit;
    font-weight: 850;
    text-decoration: none;
    cursor: pointer;
}

.sb-launcher-v3__complete:disabled {
    opacity: .58;
    cursor: wait;
}

.sb-launcher-v3__unavailable {
    min-height: 520px;
    display: grid;
    place-content: center;
    justify-items: center;
    padding: 30px;
    border: 1px solid var(--launcher-line);
    border-radius: 22px;
    background: var(--launcher-panel);
    text-align: center;
}

.sb-launcher-v3__unavailable img {
    width: 76px;
    height: 76px;
    object-fit: contain;
}

.sb-launcher-v3__unavailable > p:first-of-type {
    margin: 17px 0 0;
    color: var(--launcher-cyan);
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.sb-launcher-v3__unavailable h2 {
    max-width: 680px;
    margin: 7px 0 0;
    color: #fff;
    font-size: clamp(2rem, 5vw, 4.2rem);
    line-height: .95;
    letter-spacing: -.055em;
}

.sb-launcher-v3__unavailable > p:last-of-type {
    max-width: 660px;
    color: var(--launcher-muted);
    line-height: 1.7;
}

.sb-launcher-v3__unavailable > div {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    justify-content: center;
    margin-top: 10px;
}

.sb-launcher-v3__unavailable > div > a:not(.sb-launcher-v3__complete) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--launcher-line);
    border-radius: 12px;
    padding: 9px 15px;
    color: #fff;
    text-decoration: none;
}

@keyframes sbLauncherSpin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes sbLauncherBounce {
    0%, 80%, 100% {
        opacity: .35;
        transform: translateY(0) scale(.82);
    }

    40% {
        opacity: 1;
        transform: translateY(-7px) scale(1);
    }
}

@keyframes sbLauncherPulse {
    50% {
        opacity: .3;
    }
}

@media (max-width: 850px) {
    .sb-app-detail-v3__hero,
    .sb-app-detail-v3__content,
    .sb-launcher-v3__header,
    .sb-launcher-v3__footer {
        grid-template-columns: 1fr;
    }

    .sb-app-detail-v3__related > div {
        grid-template-columns: 1fr;
    }

    .sb-launcher-v3__controls {
        justify-content: flex-start;
    }
}

@media (max-width: 560px) {
    .sb-app-detail-v3,
    .sb-launcher-v3 {
        width: min(100% - 16px, 1220px);
    }

    .sb-app-detail-v3__hero {
        padding: 20px;
    }

    .sb-app-detail-v3__facts,
    .sb-app-detail-v3__actions {
        display: grid;
        width: 100%;
    }

    .sb-app-detail-v3__facts div,
    .sb-app-detail-v3__actions > * {
        width: 100%;
    }

    /* Two per row rather than one tall stack — five full-width buttons pushed
       the activity itself off the first screen. */
    .sb-launcher-v3__controls {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .sb-launcher-v3__controls > * {
        width: 100%;
    }

    .sb-launcher-v3__state {
        grid-column: 1 / -1;
        justify-content: center;
    }

    .sb-launcher-v3__stage iframe {
        height: clamp(460px, calc(100vh - 250px), 760px);
    }

    .sb-launcher-v3__failed-actions {
        display: grid;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sb-launcher-v3 *,
    .sb-app-detail-v3 * {
        animation: none !important;
        transition-duration: .01ms !important;
    }
}

/* External browser apps open on their own site rather than inside a frame. */
.sb-launcher-v3__handoff {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 14px;
    padding: clamp(44px, 8vw, 80px) 24px;
    margin: 20px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 26px;
    background: rgba(10, 14, 34, .55);
}

.sb-launcher-v3__handoff h2 {
    margin: 0;
    font-size: clamp(1.35rem, 3.4vw, 1.9rem);
    line-height: 1.2;
}

.sb-launcher-v3__handoff p {
    margin: 0;
    max-width: 48ch;
    line-height: 1.65;
    color: #cbd5f5;
}

.sb-launcher-v3__handoff-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 8px;
}

@media (max-width: 560px) {
    .sb-launcher-v3__handoff { margin: 12px; }
    .sb-launcher-v3__handoff-actions .sb-app-button { width: 100%; }
}
.sb-launcher-v3 > .sb-admin-preview-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    margin: 14px;
    padding: 13px 16px;
    border: 1px solid rgba(124, 58, 237, .28);
    border-radius: 14px;
    background: #f5f3ff;
    color: #4c1d95;
}

.sb-launcher-v3 > .sb-admin-preview-banner span { flex: 1 1 320px; }
.sb-launcher-v3 > .sb-admin-preview-banner a { color: inherit; font-weight: 750; }
.sb-launcher-v3__preview-note { color: #64748b; font-size: .9rem; }
