:root {
    --shell-bg: #080c14;
    --shell-panel: #0d1420;
    --shell-panel-soft: rgba(16, 24, 38, .82);
    --shell-panel-raised: #111a29;
    --shell-border: rgba(145, 166, 196, .13);
    --shell-border-strong: rgba(145, 166, 196, .23);
    --shell-text: #f3f6fb;
    --shell-muted: #8997aa;
    --shell-muted-strong: #a9b5c5;
    --shell-accent: #7d79ff;
    --shell-accent-strong: #9a8dff;
    --shell-accent-soft: rgba(125, 121, 255, .12);
    --shell-blue: #66b7ff;
    --shell-green: #6fddb1;
    --shell-danger: #ff7588;
    --shell-sidebar-width: 264px;
    --shell-radius: 16px;
}

html {
    background: var(--shell-bg);
}

body.server-admin,
body.server-public {
    min-height: 100vh;
    color: var(--shell-text);
    background: var(--shell-bg);
}

.server-backdrop {
    position: fixed;
    z-index: -2;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    background: #080c14;
}

.server-backdrop__grid {
    position: absolute;
    inset: 0;
    opacity: .22;
    background-image:
        linear-gradient(rgba(132, 148, 174, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(132, 148, 174, .035) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, .5) 55%, transparent 100%);
}

.server-backdrop__orb {
    position: absolute;
    width: 42rem;
    height: 42rem;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .08;
}

.server-backdrop__orb--primary {
    top: -23rem;
    left: 18%;
    background: #766dff;
}

.server-backdrop__orb--secondary {
    right: -24rem;
    bottom: -26rem;
    background: #3d9fff;
}

.server-shell {
    min-height: 100vh;
}

.server-sidebar {
    position: fixed;
    z-index: 60;
    inset: 0 auto 0 0;
    width: var(--shell-sidebar-width);
    display: flex;
    flex-direction: column;
    padding: 18px 14px 14px;
    border-right: 1px solid var(--shell-border);
    background: rgba(8, 13, 22, .94);
    backdrop-filter: blur(24px);
}

.server-sidebar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 50px;
    padding: 0 6px 16px;
}

.server-brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    color: var(--shell-text);
    text-decoration: none;
}

.server-brand:hover,
.server-brand:focus-visible {
    color: var(--shell-text);
}

.server-brand__mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid rgba(144, 135, 255, .34);
    border-radius: 12px;
    color: #fff;
    background:
        linear-gradient(145deg, rgba(154, 141, 255, .95), rgba(75, 99, 236, .95));
    box-shadow: 0 12px 30px rgba(59, 70, 188, .22);
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: -.04em;
}

.server-brand__copy {
    display: grid;
    min-width: 0;
    line-height: 1.05;
}

.server-brand__copy strong {
    font-size: .96rem;
    font-weight: 820;
    letter-spacing: -.02em;
}

.server-brand__copy small {
    margin-top: 5px;
    color: var(--shell-muted);
    font-size: .64rem;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.server-sidebar__close,
.server-topbar__menu,
.server-account__logout {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--shell-muted-strong);
    background: transparent;
}

.server-sidebar__close svg,
.server-topbar__menu svg,
.server-account__logout svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.server-sidebar__close {
    display: none;
}

.server-nav {
    min-height: 0;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    padding: 8px 0 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(150, 164, 186, .16) transparent;
}

.server-nav__group {
    display: grid;
    gap: 4px;
}

.server-nav__label {
    padding: 0 11px 6px;
    color: #68778a;
    font-size: .62rem;
    font-weight: 780;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.server-nav__link {
    position: relative;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: #96a4b7;
    text-decoration: none;
    font-size: .78rem;
    font-weight: 680;
    transition: 140ms ease;
    transition-property: color, background, border-color, transform;
}

.server-nav__link svg {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.server-nav__link:hover {
    color: #dce4ef;
    border-color: rgba(139, 155, 180, .08);
    background: rgba(255, 255, 255, .035);
}

.server-nav__link.is-active {
    color: #f7f8ff;
    border-color: rgba(132, 123, 255, .2);
    background: linear-gradient(90deg, rgba(121, 111, 255, .15), rgba(121, 111, 255, .055));
    box-shadow: inset 3px 0 0 rgba(145, 136, 255, .85);
}

.server-nav__link.is-active svg {
    color: #a59cff;
}

.server-nav__live {
    width: 6px;
    height: 6px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--shell-green);
    box-shadow: 0 0 0 4px rgba(111, 221, 177, .08);
}

.server-nav__root {
    margin-left: auto;
    padding: 2px 6px;
    border: 1px solid rgba(157, 143, 255, .25);
    border-radius: 999px;
    color: #b8b0ff;
    background: rgba(126, 116, 255, .09);
    font-size: .52rem;
    font-weight: 850;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.server-sidebar__footer {
    flex: 0 0 auto;
    display: grid;
    gap: 9px;
    padding-top: 12px;
    border-top: 1px solid var(--shell-border);
}

.server-download-menu {
    position: relative;
}

.server-download-menu > summary {
    min-height: 50px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 9px;
    border: 1px solid var(--shell-border);
    border-radius: 12px;
    color: var(--shell-muted-strong);
    background: rgba(255, 255, 255, .025);
    cursor: pointer;
    list-style: none;
}

.server-download-menu > summary::-webkit-details-marker {
    display: none;
}

.server-download-menu > summary svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: var(--shell-accent-strong);
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.server-download-menu > summary > span:nth-child(2) {
    min-width: 0;
    display: grid;
}

.server-download-menu > summary strong {
    overflow: hidden;
    color: #dbe2ee;
    font-size: .7rem;
    font-weight: 760;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-download-menu > summary small {
    margin-top: 2px;
    overflow: hidden;
    color: #718094;
    font-size: .58rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-download-menu__chevron {
    width: 7px;
    height: 7px;
    border-right: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 140ms ease;
}

.server-download-menu[open] .server-download-menu__chevron {
    transform: rotate(225deg) translate(-2px, -1px);
}

.server-download-menu__panel {
    position: absolute;
    z-index: 80;
    right: 0;
    bottom: calc(100% + 8px);
    left: 0;
    display: grid;
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--shell-border-strong);
    border-radius: 12px;
    background: #101827;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .38);
}

.server-download-menu__panel a {
    display: grid;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--shell-text);
    text-decoration: none;
}

.server-download-menu__panel a:hover {
    background: rgba(255, 255, 255, .045);
}

.server-download-menu__panel strong {
    font-size: .7rem;
}

.server-download-menu__panel small {
    margin-top: 2px;
    color: var(--shell-muted);
    font-size: .6rem;
}

.server-account {
    min-height: 54px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 7px 6px 7px 8px;
    border-radius: 12px;
}

.server-account__avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(124, 116, 255, .22);
    border-radius: 10px;
    color: #dcd8ff;
    background: rgba(124, 116, 255, .1);
    font-size: .76rem;
    font-weight: 850;
}

.server-account__copy {
    min-width: 0;
    display: grid;
}

.server-account__copy strong,
.server-account__copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-account__copy strong {
    font-size: .7rem;
    font-weight: 760;
}

.server-account__copy span {
    margin-top: 3px;
    color: var(--shell-muted);
    font-size: .58rem;
}

.server-account__logout:hover {
    color: #f2f5fa;
    border-color: var(--shell-border);
    background: rgba(255, 255, 255, .04);
}

.server-stage {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-left: var(--shell-sidebar-width);
}

.server-topbar {
    position: sticky;
    z-index: 35;
    top: 0;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 clamp(22px, 3vw, 42px);
    border-bottom: 1px solid var(--shell-border);
    background: rgba(8, 12, 20, .78);
    backdrop-filter: blur(22px);
}

.server-topbar__menu {
    display: none;
}

.server-topbar__title {
    min-width: 0;
    display: grid;
}

.server-topbar__title span {
    color: #68778b;
    font-size: .56rem;
    font-weight: 770;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.server-topbar__title strong {
    margin-top: 2px;
    overflow: hidden;
    font-size: .8rem;
    font-weight: 750;
    letter-spacing: -.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-topbar__status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
    color: #7f8ca0;
    font-size: .62rem;
    font-weight: 650;
}

.server-topbar__pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--shell-green);
    box-shadow: 0 0 0 4px rgba(111, 221, 177, .08);
}

.server-main {
    width: min(100%, 1480px);
    flex: 1 0 auto;
    align-self: center;
    padding: clamp(28px, 4vw, 54px) clamp(20px, 3.5vw, 50px) 64px;
}

.server-main > .page-heading:first-child,
.server-main > .access-hero:first-child {
    margin-top: 0;
}

/* Les éditeurs complexes peuvent exploiter les écrans larges sans élargir tout le back-office. */
.server-main.server-main--wide {
    width: min(100%, 1980px);
}

.server-footer {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 clamp(22px, 3vw, 42px);
    border-top: 1px solid rgba(145, 166, 196, .08);
    color: #58667a;
    font-size: .6rem;
}

.server-sidebar-overlay {
    display: none;
}

/* Harmonisation des composants historiques avec le nouveau shell. */
.server-admin .page-heading,
.server-admin .library-heading,
.server-admin .section-heading {
    color: var(--shell-text);
}

.server-admin .page-heading h1,
.server-admin .library-heading h2,
.server-admin .section-heading h2 {
    letter-spacing: -.035em;
}

.server-admin .page-heading__eyebrow {
    color: #8f87ff;
    font-size: .62rem;
    font-weight: 820;
    letter-spacing: .14em;
}

.server-admin .surface-card,
.server-admin .manifest-card,
.server-admin .edit-card,
.server-admin .form-card,
.server-admin .release-card,
.server-admin .scan-current-card,
.server-admin .scan-history-card,
.server-admin .guide-admin-card,
.server-admin .update-overview-card {
    border-color: var(--shell-border);
    background: linear-gradient(180deg, rgba(18, 27, 42, .78), rgba(12, 19, 31, .86));
    box-shadow: 0 18px 48px rgba(0, 0, 0, .16);
}

.server-admin .emulator-card {
    border-color: var(--shell-border);
    background: linear-gradient(180deg, rgba(17, 26, 40, .83), rgba(11, 18, 29, .91));
    box-shadow: 0 15px 36px rgba(0, 0, 0, .14);
}

.server-admin .emulator-card:hover {
    border-color: rgba(143, 132, 255, .26);
    box-shadow: 0 18px 46px rgba(0, 0, 0, .2);
}

.server-admin .primary-button {
    border-color: rgba(140, 130, 255, .42);
    background: linear-gradient(135deg, #7269ef, #5d68df);
    box-shadow: 0 9px 24px rgba(83, 82, 203, .2);
}

.server-admin .secondary-button {
    border-color: var(--shell-border-strong);
    background: rgba(255, 255, 255, .025);
}

.server-admin .secondary-button:hover {
    border-color: rgba(144, 135, 255, .3);
    background: rgba(125, 121, 255, .07);
}

.server-admin .form-control,
.server-admin .form-select,
.server-admin .app-input,
.server-admin .app-select {
    border-color: var(--shell-border-strong);
    color: var(--shell-text);
    background-color: rgba(7, 12, 20, .66);
}

.server-admin .form-control:focus,
.server-admin .form-select:focus,
.server-admin .app-input:focus,
.server-admin .app-select:focus {
    border-color: rgba(137, 128, 255, .55);
    box-shadow: 0 0 0 3px rgba(125, 121, 255, .1);
}

.server-admin .alert {
    border-radius: 12px;
    font-size: .76rem;
}

/* Surface publique pour connexion et setup. */
.public-shell {
    width: min(100%, 1180px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    padding: 0 24px;
}

.public-header {
    min-height: 80px;
    display: flex;
    align-items: center;
}

.public-main {
    min-height: 0;
    display: grid;
    flex: 1 1 auto;
    place-items: center;
    padding: 32px 0 70px;
}

.public-main > * {
    width: 100%;
}

.public-footer {
    padding: 18px 0 26px;
    color: #667488;
    font-size: .62rem;
    text-align: center;
}

.server-public .auth-card,
.server-public .form-card {
    border-color: var(--shell-border-strong);
    background: rgba(13, 20, 32, .88);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .26);
}

@media (max-width: 1080px) {
    .server-sidebar {
        width: 246px;
    }

    .server-stage {
        padding-left: 246px;
    }

    .server-main {
        padding-right: 26px;
        padding-left: 26px;
    }
}

@media (max-width: 860px) {
    body.server-admin.is-navigation-open {
        overflow: hidden;
    }

    .server-sidebar {
        width: min(308px, calc(100vw - 36px));
        transform: translateX(-102%);
        box-shadow: 24px 0 80px rgba(0, 0, 0, .38);
        transition: transform 180ms ease;
    }

    .server-sidebar.is-open {
        transform: translateX(0);
    }

    .server-sidebar__close,
    .server-topbar__menu {
        display: grid;
    }

    .server-stage {
        padding-left: 0;
    }

    .server-sidebar-overlay {
        position: fixed;
        z-index: 50;
        inset: 0;
        display: block;
        visibility: hidden;
        padding: 0;
        border: 0;
        opacity: 0;
        background: rgba(1, 4, 9, .68);
        backdrop-filter: blur(3px);
        transition: 180ms ease;
        transition-property: opacity, visibility;
    }

    body.server-admin.is-navigation-open .server-sidebar-overlay {
        visibility: visible;
        opacity: 1;
    }

    .server-topbar {
        padding: 0 18px;
    }

    .server-topbar__status {
        display: none;
    }

    .server-main {
        padding: 26px 16px 46px;
    }

    .server-footer {
        padding: 0 18px;
    }
}

@media (max-width: 560px) {
    .server-topbar {
        min-height: 58px;
    }

    .server-topbar__title span {
        display: none;
    }

    .server-topbar__title strong {
        font-size: .76rem;
    }

    .server-main {
        padding-top: 22px;
    }

    .server-footer {
        justify-content: center;
    }

    .server-footer span:last-child {
        display: none;
    }

    .public-shell {
        padding: 0 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .server-sidebar,
    .server-sidebar-overlay,
    .server-nav__link,
    .server-download-menu__chevron {
        transition-duration: .01ms !important;
    }
}
