* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    margin: 0;
    color: var(--mws-text);
    background:
        radial-gradient(120% 52% at 50% -8%, rgba(var(--mws-primary-rgb), 0.16), transparent 58%),
        radial-gradient(110% 46% at 18% 26%, rgba(var(--mws-accent-rgb), 0.10), transparent 60%),
        radial-gradient(118% 50% at 82% 72%, rgba(var(--mws-primary-rgb), 0.09), transparent 62%),
        var(--mws-bg);
    font-family: var(--mws-font-body);
    line-height: 1.6;
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
}

body::before {
    content: "";
    position: fixed;
    inset:
        calc(var(--shell-pad) + var(--safe-top))
        calc(var(--shell-pad) + var(--safe-right))
        calc(var(--shell-pad) + var(--safe-bottom))
        calc(var(--shell-pad) + var(--safe-left));
    z-index: -2;
    border-radius: 34px;
    background:
        linear-gradient(var(--mws-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--mws-grid) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.76), rgba(0, 0, 0, 0.18));
    pointer-events: none;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    border: 0;
    background: none;
}

img,
svg {
    display: block;
    max-width: 100%;
}

svg {
    stroke: currentColor;
}

[hidden] {
    display: none !important;
}

.panel {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--mws-border);
    border-radius: 32px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.12), transparent 36%),
        var(--mws-card-bg);
    box-shadow: var(--mws-shadow);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}

.panel::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(var(--mws-primary-rgb), 0.08), var(--mws-panel-glow);
    pointer-events: none;
}

.os-shell {
    width: min(100% - 24px, 1380px);
    margin-inline: auto;
    padding:
        calc(var(--shell-pad) + var(--safe-top))
        0
        calc(var(--shell-pad) + var(--safe-bottom));
}

.portal-page .os-shell,
.app-module-page .os-shell {
    width: calc(100% - 24px);
    max-width: none;
}

.desktop {
    position: relative;
    display: grid;
    gap: 0;
    min-height: calc(100vh - (var(--shell-pad) * 2) - var(--safe-top) - var(--safe-bottom));
    min-height: calc(100dvh - (var(--shell-pad) * 2) - var(--safe-top) - var(--safe-bottom));
}

.workspace {
    isolation: isolate;
}

.workspace::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
}

.workspace-scroll > * {
    min-width: 0;
}

.topbar-slot {
    position: sticky;
    top: calc(var(--shell-pad) + var(--safe-top));
    z-index: 30;
    display: flex;
    justify-content: flex-end;
    padding-top: 6px;
    margin-bottom: -60px;
    pointer-events: none;
}

.top-bar {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--mws-border);
    border-radius: 999px;
    background: var(--mws-topbar-bg);
    box-shadow: var(--mws-shadow);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.topbar-search {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid rgba(var(--mws-primary-rgb), 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    overflow: hidden;
    transition: width 0.24s ease, background 0.22s ease, border-color 0.22s ease, transform 0.22s ease;
}

.topbar-search:focus-within {
    border-color: rgba(var(--mws-primary-rgb), 0.34);
    background: rgba(var(--mws-primary-rgb), 0.08);
}

.topbar-search-toggle,
.topbar-button,
.theme-toggle,
.topbar-language-trigger,
.topbar-language-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 999px;
    color: var(--mws-text);
    cursor: pointer;
    transition: transform 0.22s ease, background 0.22s ease, border-color 0.22s ease, color 0.22s ease;
}

.topbar-search-toggle,
.topbar-button,
.theme-toggle {
    border: 1px solid rgba(var(--mws-primary-rgb), 0.16);
    background: rgba(255, 255, 255, 0.04);
}

.topbar-search-toggle {
    border: 0;
    background: transparent;
}

.topbar-search-field {
    display: flex;
    align-items: center;
    max-width: 0;
    min-width: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    transition: max-width 0.22s ease, padding 0.22s ease, opacity 0.18s ease;
}

.topbar-search-input {
    width: 100%;
    min-width: 0;
    border: 0;
    color: var(--mws-text);
    background: transparent;
    outline: none;
}

.topbar-search-input::placeholder {
    color: var(--mws-text-muted);
}

.topbar-search.is-open {
    width: min(100%, 257px);
}

.topbar-search.is-open .topbar-search-toggle {
    border-right: 1px solid rgba(var(--mws-primary-rgb), 0.12);
    border-radius: 0;
}

.topbar-search.is-open .topbar-search-field {
    max-width: 260px;
    padding: 0 14px 0 12px;
    opacity: 1;
    pointer-events: auto;
}

.topbar-search-toggle svg,
.topbar-button svg,
.theme-toggle svg,
.topbar-language-trigger svg {
    width: 18px;
    height: 18px;
}

.topbar-search-toggle:hover,
.topbar-button:hover,
.theme-toggle:hover,
.topbar-language-trigger:hover,
.topbar-language-option:hover,
.topbar-language-group.is-open .topbar-language-trigger {
    color: var(--mws-text);
    background: rgba(var(--mws-primary-rgb), 0.12);
    transform: translateY(-1px);
}

.theme-toggle[aria-pressed="true"] {
    background: rgba(var(--mws-primary-rgb), 0.16);
}

.theme-toggle-icon {
    width: 18px;
    height: 18px;
}

.theme-toggle-moon {
    color: var(--mws-moon);
}

.theme-toggle-sun {
    display: none;
    color: var(--mws-sun);
}

html[data-theme="light"] .theme-toggle-sun {
    display: block;
}

html[data-theme="light"] .theme-toggle-moon {
    display: none;
}

.topbar-language-group {
    position: relative;
}

.topbar-language-trigger {
    gap: 8px;
    min-width: 76px;
    padding: 0 12px;
    border: 1px solid rgba(var(--mws-primary-rgb), 0.16);
    background: rgba(255, 255, 255, 0.04);
}

.topbar-language-current {
    font-size: 0.86rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.topbar-language-chevron {
    width: 16px;
    height: 16px;
    color: var(--mws-text-muted);
}

.topbar-language-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 20;
    display: grid;
    gap: 6px;
    min-width: 88px;
    padding: 8px;
    border: 1px solid var(--mws-border);
    border-radius: 18px;
    background: var(--mws-topbar-bg);
    box-shadow: var(--mws-shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.topbar-language-menu.is-compact {
    min-width: 78px;
}

.topbar-language-group.is-open .topbar-language-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.topbar-language-option {
    min-width: 100%;
    padding: 6px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
}

.topbar-language-option.is-active {
    border-color: rgba(var(--mws-primary-rgb), 0.2);
    background: rgba(var(--mws-primary-rgb), 0.14);
}

.topbar-language-option-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 30px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.dock-slot {
    display: flex;
    justify-content: center;
    margin-top: 18px;
}

.dock {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    width: min(100%, 1040px);
    padding: 18px;
    border: 1px solid rgba(var(--mws-primary-rgb), 0.16);
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: var(--mws-shadow);
}

.dock-button {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 72px;
    padding: 14px 16px;
    border-radius: 22px;
    color: var(--mws-text);
    background: rgba(255, 255, 255, 0.04);
    transition: transform 0.22s ease, background 0.22s ease, border-color 0.22s ease;
}

.dock-button:hover,
.dock-button.is-active {
    background: rgba(var(--mws-primary-rgb), 0.12);
    transform: translateY(-2px);
}

.app-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border: 1px solid rgba(var(--mws-primary-rgb), 0.22);
    border-radius: 18px;
    color: var(--mws-text);
    background: linear-gradient(180deg, rgba(var(--mws-primary-rgb), 0.28), rgba(var(--mws-accent-rgb), 0.08));
}

.app-icon svg {
    width: 22px;
    height: 22px;
}

.app-text {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.app-name {
    color: var(--mws-text);
    font-size: 0.94rem;
    font-weight: 800;
}

.app-badge {
    color: var(--mws-text-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.mos-alert {
    margin: 0;
    border-radius: 18px;
    border-color: rgba(var(--mws-primary-rgb), 0.16);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.12);
}

.mos-alert.alert-success {
    color: var(--mws-status-success-text);
    background: rgba(56, 217, 150, 0.14);
}

.mos-alert.alert-danger {
    color: var(--mws-status-danger-text);
    background: rgba(255, 107, 136, 0.14);
}

.mos-alert.alert-warning {
    color: var(--mws-status-warning-text);
    background: rgba(242, 184, 75, 0.16);
}

@media (max-width: 900px) {
    .topbar-slot {
        margin-bottom: -42px;
    }

    .top-bar {
        width: 100%;
        justify-content: flex-end;
    }

    .topbar-search {
        flex: 0 0 auto;
    }
}

@media (max-width: 760px) {
    body::before {
        inset: 10px;
        border-radius: 24px;
    }

    .os-shell {
        width: min(100% - 18px, 1380px);
    }

    .portal-page .os-shell,
    .app-module-page .os-shell {
        width: calc(100% - 18px);
    }

    .topbar-slot {
        margin-bottom: -24px;
    }

    .top-bar {
        gap: 8px;
        padding: 8px;
    }

    .topbar-search {
        width: 44px;
    }

    .topbar-search.is-open {
        width: min(100%, 240px);
    }

    .topbar-search.is-open .topbar-search-field {
        max-width: 196px;
        padding-right: 14px;
        opacity: 1;
        pointer-events: auto;
    }

    .dock {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .panel {
        border-radius: 24px;
    }

    .topbar-slot {
        position: relative;
        top: 0;
        margin-bottom: 14px;
        padding-top: 0;
    }

    .top-bar {
        width: 100%;
        justify-content: space-between;
    }

    .topbar-search.is-open {
        flex: 1 1 auto;
        width: 100%;
    }

    .topbar-search.is-open .topbar-search-field {
        max-width: none;
        width: 100%;
    }

    .dock {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    html:not([data-ui-reduce-motion="off"]) *,
    html:not([data-ui-reduce-motion="off"]) *::before,
    html:not([data-ui-reduce-motion="off"]) *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
/* MWS Security bootstrap UI */
.MWS-honeypot {
    position: absolute !important;
    left: -10000px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

.mos-preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 14px;
    color: var(--mws-text, #f8f5ff);
    background: var(--mws-bg, #07040d);
    transition: opacity 180ms ease, visibility 180ms ease;
}

.mos-preloader.is-finished {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.mos-preloader-mark {
    display: grid;
    width: 58px;
    height: 58px;
    place-items: center;
    border: 2px solid currentColor;
    border-radius: 18px;
    font-size: 1.6rem;
    font-weight: 900;
    animation: MWS-preloader-pulse 800ms ease-in-out infinite alternate;
}

@keyframes MWS-preloader-pulse {
    to { transform: scale(0.92); opacity: 0.65; }
}

@media (prefers-reduced-motion: reduce) {
    html:not([data-ui-reduce-motion="off"]) .mos-preloader,
    html:not([data-ui-reduce-motion="off"]) .mos-preloader-mark {
        animation: none;
        transition: none;
    }
}

.top-bar.panel.topbar-profile {
    --topbar-profile-size: 44px;
    width: auto;
    max-width: calc(100vw - 18px);
    justify-content: flex-end;
    gap: 0;
    padding: 7px;
    overflow: visible;
    border-radius: 999px;
    transition: border-color .22s ease, box-shadow .22s ease;
}

.topbar-profile.is-open {
    border-color: rgba(var(--mws-primary-rgb), .28);
    box-shadow: var(--mws-shadow), 0 0 0 1px rgba(var(--mws-primary-rgb), .08);
}

.topbar-profile-toggle {
    position: relative;
    z-index: 2;
    display: inline-grid;
    place-items: center;
    flex: 0 0 var(--topbar-profile-size);
    width: var(--topbar-profile-size);
    min-width: var(--topbar-profile-size);
    height: var(--topbar-profile-size);
    min-height: var(--topbar-profile-size);
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(var(--mws-primary-rgb), .24);
    border-radius: 50%;
    color: var(--mws-text-muted);
    background: rgba(255, 255, 255, .045);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .16);
    cursor: pointer;
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.topbar-profile-toggle:hover {
    border-color: rgba(var(--mws-primary-rgb), .48);
    box-shadow: 0 10px 24px rgba(var(--mws-primary-rgb), .18);
    transform: translateY(-1px);
}

.topbar-profile-toggle:active {
    transform: scale(.96);
}

.topbar-profile-toggle:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(var(--mws-primary-rgb), .2), 0 9px 22px rgba(0, 0, 0, .18);
}

.topbar-profile.is-open .topbar-profile-toggle {
    border-color: rgba(var(--mws-primary-rgb), .6);
    box-shadow: 0 0 0 3px rgba(var(--mws-primary-rgb), .12), 0 10px 24px rgba(var(--mws-primary-rgb), .2);
}

.topbar-profile-avatar {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 50%;
}

.topbar-profile-avatar-fallback,
.topbar-profile-avatar-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.topbar-profile-avatar-fallback {
    display: grid;
    place-items: center;
    color: var(--mws-text-muted);
    background: rgba(255, 255, 255, .06);
}

.topbar-profile-avatar-fallback svg {
    width: 21px;
    height: 21px;
}

.topbar-profile-avatar-image {
    z-index: 1;
    display: block;
    object-fit: cover;
}

.topbar-profile-menu {
    order: -1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
    max-width: 0;
    margin-right: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(12px);
    transform-origin: right center;
    transition:
        max-width .3s cubic-bezier(.22, 1, .36, 1),
        margin-right .3s cubic-bezier(.22, 1, .36, 1),
        opacity .16s ease,
        transform .26s ease,
        visibility 0s linear .3s;
}

.topbar-profile-menu > * {
    flex: 0 0 auto;
}

.topbar-profile.is-open .topbar-profile-menu {
    max-width: min(680px, calc(100vw - 82px));
    margin-right: 10px;
    overflow: visible;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
    transition:
        max-width .32s cubic-bezier(.22, 1, .36, 1),
        margin-right .32s cubic-bezier(.22, 1, .36, 1),
        opacity .18s ease .05s,
        transform .26s ease,
        visibility 0s;
}

html[data-theme="light"] .topbar-profile-toggle,
html[data-theme="light"] .topbar-profile-avatar-fallback {
    color: var(--mws-text-muted);
    background: rgba(var(--mws-primary-rgb), .065);
}

@media (max-width: 560px) {
    .top-bar.panel.topbar-profile {
        width: auto;
        max-width: 100%;
        padding: 5px;
        border-radius: 999px;
        justify-content: flex-end;
    }

    .topbar-profile-menu {
        gap: 5px;
    }

    .topbar-profile.is-open .topbar-profile-menu {
        max-width: calc(100vw - 80px);
        margin-right: 6px;
    }
}
