﻿:root {
    --ws-shell-top-height: 46px;
    --ws-shell-bottom-height: 25px;
    --ws-shell-top-bg: var(--theme-surface-soft, #121a25);
    --ws-shell-top-border: var(--theme-border, #2b3c52);
    --ws-shell-bottom-bg: color-mix(in srgb, var(--theme-code-bg, #102033) 92%, var(--theme-accent, #0b6fae) 8%);
    --ws-shell-border-muted: var(--theme-border, #32485f);
    --ws-shell-text: var(--theme-text, #e9f2fb);
    --ws-shell-text-muted: var(--theme-muted, #9fb4c9);
}

body.ws-shell-enabled {
    padding-top: var(--ws-shell-top-height);
    padding-bottom: var(--ws-shell-bottom-height);
}

body.ws-shell-enabled.ws-shell-bottom-hidden {
    padding-bottom: 0;
}

.ws-shell-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--ws-shell-top-height);
    z-index: 4000;
    border-bottom: 1px solid var(--ws-shell-top-border);
    background: linear-gradient(180deg, color-mix(in srgb, var(--ws-shell-top-bg) 94%, #ffffff 6%), var(--ws-shell-top-bg));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 12px;
    color: var(--ws-shell-text);
    box-shadow: 0 5px 18px color-mix(in srgb, var(--theme-code-bg, #102033) 12%, transparent);
}

.ws-shell-skip-link {
    position: fixed;
    z-index: 7000;
    top: 7px;
    left: 10px;
    max-width: calc(100vw - 20px);
    padding: 8px 12px;
    border: 2px solid var(--theme-accent, #0b6fae);
    border-radius: 9px;
    color: #fff;
    background: var(--theme-code-bg, #102033);
    box-shadow: 0 10px 30px rgba(9, 32, 52, .24);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    transform: translateY(-150%);
    transition: transform var(--motion-fast, 100ms) ease;
}

.ws-shell-skip-link:focus { transform: translateY(0); }

.ws-shell-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    white-space: nowrap;
}

.ws-shell-brand-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ws-shell-text);
}

.ws-shell-brand-sub {
    font-size: 11px;
    color: var(--ws-shell-text-muted);
}

.ws-shell-mobile-cluster {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1 1 auto;
    min-width: 0;
    gap: 12px;
}

.ws-shell-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ws-shell-link {
    text-decoration: none;
    color: var(--ws-shell-text);
    border: 1px solid var(--ws-shell-border-muted);
    border-radius: 8px;
    padding: 4px 9px;
    font-size: 12px;
    line-height: 1;
    background: color-mix(in srgb, var(--theme-surface-2, #f3f8fc) 86%, var(--theme-page-2, #e2edf7) 14%);
    font-weight: 700;
    transition: border-color var(--motion-fast, 100ms) ease, background-color var(--motion-fast, 100ms) ease, color var(--motion-fast, 100ms) ease, transform var(--motion-fast, 100ms) ease;
}

.ws-shell-link:hover {
    border-color: var(--theme-border-strong, #5b83ae);
    background: var(--theme-surface, #fbfdff);
    transform: translateY(-1px);
}

.ws-shell-link.active {
    border-color: var(--theme-accent, #0b6fae);
    background: var(--theme-accent, #0b6fae);
    color: #fff;
}

.ws-shell-link:active { transform: translateY(0) scale(.98); }

.ws-shell-mode-toggle {
    min-height: 30px;
    padding: 4px 9px;
    border: 1px solid var(--ws-shell-border-muted);
    border-radius: 8px;
    background: var(--ws-shell-top-bg);
    color: var(--ws-shell-text-muted);
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}
.ws-shell-mode-toggle:hover,
.ws-shell-mode-toggle[aria-pressed="true"] { border-color: var(--theme-accent, #0b6fae); color: var(--ws-shell-text); }

.ws-shell-right {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ws-shell-theme,
.ws-shell-locale {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 2px;
}

.ws-shell-theme-label {
    font-size: 11px;
    color: var(--ws-shell-text-muted);
}

.ws-shell-theme-select,
.theme-select-compact,
.ws-shell-locale-select {
    border: 1px solid var(--ws-shell-border-muted);
    border-radius: 8px;
    background: color-mix(in srgb, var(--theme-surface, #1b2e44) 86%, #000000 14%);
    color: var(--ws-shell-text);
    font-size: 12px;
    padding: 3px 8px;
    min-width: 130px;
    outline: none;
}

.ws-shell-theme-select:focus,
.theme-select-compact:focus,
.ws-shell-locale-select:focus {
    border-color: var(--theme-accent, #62beff);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-accent, #62beff) 35%, transparent);
}

.ws-shell-user {
    font-size: 12px;
    color: var(--ws-shell-text-muted);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ws-shell-connectivity {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 25px;
    padding: 3px 8px;
    border: 1px solid var(--ws-shell-border-muted);
    border-radius: 999px;
    color: var(--ws-shell-text-muted);
    background: var(--theme-surface, #fbfdff);
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
}

.ws-shell-connectivity i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 12%, transparent); }
.ws-shell-connectivity.is-online { color: var(--theme-success, #23784f); }
.ws-shell-connectivity.is-offline { color: var(--theme-danger, #9d303d); }

.ws-shell-menu-button {
    display: none;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    padding: 7px;
    border: 1px solid var(--ws-shell-border-muted);
    border-radius: 9px;
    color: var(--ws-shell-text);
    background: var(--theme-surface, #fbfdff);
    cursor: pointer;
}

.ws-shell-menu-button i { display: block; width: 17px; height: 2px; border-radius: 999px; background: currentColor; transition: transform var(--motion-fast, 100ms) ease, opacity var(--motion-fast, 100ms) ease; }
.ws-shell-menu-button[aria-expanded="true"] i:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.ws-shell-menu-button[aria-expanded="true"] i:nth-child(2) { opacity: 0; }
.ws-shell-menu-button[aria-expanded="true"] i:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

.ws-shell-network-banner {
    position: fixed;
    z-index: 3999;
    top: var(--ws-shell-top-height);
    left: 50%;
    width: min(680px, calc(100vw - 24px));
    padding: 9px 14px;
    border: 1px solid var(--theme-border, #8ca8bd);
    border-top: 0;
    border-radius: 0 0 11px 11px;
    color: var(--theme-text, #102538);
    background: var(--theme-surface, #fbfdff);
    box-shadow: 0 12px 30px rgba(14, 44, 68, .18);
    font-size: 11px;
    font-weight: 750;
    text-align: center;
    transform: translateX(-50%);
}

.ws-shell-network-banner.is-offline { color: var(--theme-danger, #9d303d); border-color: color-mix(in srgb, var(--theme-danger, #9d303d) 42%, var(--theme-border)); }
.ws-shell-network-banner.is-restored { color: var(--theme-success, #23784f); border-color: color-mix(in srgb, var(--theme-success, #23784f) 42%, var(--theme-border)); }

.ws-shell-bottom {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--ws-shell-bottom-height);
    z-index: 4000;
    background: var(--ws-shell-bottom-bg);
    color: var(--theme-code-text, #e7f2ff);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 8px;
    font-size: 11px;
}

.ws-shell-bottom-left {
    min-width: 0;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ws-shell-bottom-right {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.ws-shell-record-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.ws-shell-record-version {
    appearance: none;
    margin: 0;
    padding: 0;
    border: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

.ws-shell-record-version:focus-visible {
    border-radius: 4px;
    outline-color: currentColor;
}

.ws-shell-record-pop {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    min-width: 280px;
    max-width: 360px;
    border: 1px solid var(--ws-shell-border-muted);
    border-radius: 8px;
    background: color-mix(in srgb, var(--theme-surface-soft, #15253b) 90%, #000000 10%);
    color: var(--ws-shell-text);
    padding: 8px 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    line-height: 1.45;
    font-size: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
    pointer-events: none;
    white-space: normal;
    z-index: 5002;
}

.ws-shell-record-wrap.is-open .ws-shell-record-pop {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.ws-shell-record-link {
    color: color-mix(in srgb, var(--theme-accent, #62beff) 90%, #ffffff 10%);
    text-decoration: none;
}

.ws-shell-record-link:hover {
    color: color-mix(in srgb, var(--theme-accent, #62beff) 70%, #ffffff 30%);
    text-decoration: underline;
}

.ws-shell-record-icon {
    display: inline-block;
    width: 14px;
    text-align: center;
    margin-right: 4px;
    line-height: 1;
    transform: translateY(1px);
}

body.ws-shell-enabled.ai-page .ai-app {
    height: calc(100dvh - var(--ws-shell-top-height) - var(--ws-shell-bottom-height));
}

body.ws-shell-enabled.collab-page .layout {
    height: calc(100dvh - var(--ws-shell-top-height) - var(--ws-shell-bottom-height));
}

body.ws-shell-enabled.collab-page {
    overflow: hidden;
}

body.ws-shell-enabled.cas-dashboard-page .container-fluid {
    min-height: calc(100dvh - var(--ws-shell-top-height) - var(--ws-shell-bottom-height));
}

@media (max-width: 1120px) {
    .ws-shell-theme-label {
        display: none;
    }
    .ws-shell-theme-select,
    .theme-select-compact {
        min-width: 108px;
    }
}

@media (max-width: 980px) {
    .ws-shell-brand-sub,
    .ws-shell-user {
        display: none;
    }
    .ws-shell-bottom-left {
        max-width: 56%;
    }
    .ws-shell-record-pop {
        min-width: 240px;
    }
    .ws-shell-theme,
    .ws-shell-locale {
        margin-right: 0;
    }
    .ws-shell-theme-select,
    .theme-select-compact {
        min-width: 90px;
        max-width: 116px;
        font-size: 11px;
    }
}

@media (max-width: 1100px) {
    .ws-shell-topbar { gap: 8px; padding-inline: 10px; }
    .ws-shell-brand { flex: 1 1 auto; }
    .ws-shell-brand-title { overflow: hidden; text-overflow: ellipsis; }
    .ws-shell-menu-button { display: grid; gap: 3px; }
    .ws-shell-mobile-cluster {
        position: fixed;
        z-index: 4100;
        top: calc(var(--ws-shell-top-height) + 7px);
        right: 8px;
        display: none;
        width: min(360px, calc(100vw - 16px));
        max-height: calc(100dvh - var(--ws-shell-top-height) - 18px);
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
        padding: 12px;
        overflow: auto;
        border: 1px solid var(--theme-border, #8ca8bd);
        border-radius: 14px;
        color: var(--theme-text, #102538);
        background: color-mix(in srgb, var(--theme-surface, #fbfdff) 96%, transparent);
        box-shadow: 0 22px 60px rgba(9, 32, 52, .28);
        backdrop-filter: blur(16px);
    }
    body.ws-shell-mobile-open .ws-shell-mobile-cluster { display: flex; }
    .ws-shell-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
    .ws-shell-link { display: flex; min-height: 34px; align-items: center; justify-content: center; padding: 8px 10px; line-height: 1.2; text-align: center; }
    .ws-shell-right { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 8px; }
    .ws-shell-theme, .ws-shell-locale { display: grid; grid-column: span 1; gap: 4px; min-width: 0; }
    .ws-shell-theme-label { display: block; }
    .ws-shell-theme-select, .theme-select-compact, .ws-shell-locale-select { width: 100%; max-width: none; min-width: 0; min-height: 34px; }
    .ws-shell-connectivity { justify-content: center; }
    .ws-shell-user { display: flex; align-items: center; max-width: none; padding-inline: 8px; }
    .ws-shell-bottom-right > span:first-child { display: none; }
    .ws-shell-bottom-left { max-width: 60%; }
}

@media (max-width: 480px) {
    .ws-shell-brand-title { font-size: 12px; }
    .ws-shell-menu-button { width: 40px; height: 40px; }
    .ws-shell-link,
    .ws-shell-theme-select,
    .theme-select-compact,
    .ws-shell-locale-select { min-height: 40px; }
    .ws-shell-right { grid-template-columns: 1fr; }
    .ws-shell-theme, .ws-shell-locale { grid-column: 1; }
    .ws-shell-bottom-right { display: none; }
    .ws-shell-bottom-left { max-width: 100%; width: 100%; text-align: center; }
}


/* Codex shell contract: one compact, neutral shell for every surface. */
:root {
    --shell-codex-bg: #101216;
    --shell-codex-bg-raised: #17191f;
    --shell-codex-bg-hover: #20232b;
    --shell-codex-border: #2b3039;
    --shell-codex-text: #f2f3f5;
    --shell-codex-muted: #9ba3b0;
    --shell-codex-accent: #73b8ff;
    --shell-codex-radius: 8px;
    --shell-codex-control-height: 32px;
}

body.ws-shell-codex {
    --ws-shell-top-height: 52px;
    --ws-shell-bottom-height: 24px;
    --ws-shell-top-bg: var(--shell-codex-bg);
    --ws-shell-top-border: var(--shell-codex-border);
    --ws-shell-bottom-bg: var(--shell-codex-bg);
    --ws-shell-border-muted: var(--shell-codex-border);
    --ws-shell-text: var(--shell-codex-text);
    --ws-shell-text-muted: var(--shell-codex-muted);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.ws-shell-codex .ws-shell-topbar {
    padding-inline: 16px;
    gap: 16px;
    background: var(--shell-codex-bg) !important;
    border-bottom-color: var(--shell-codex-border);
    box-shadow: 0 1px 0 rgba(255,255,255,.025), 0 8px 24px rgba(0,0,0,.18);
}
body.ws-shell-codex .ws-shell-brand { gap: 10px; }
body.ws-shell-codex .ws-shell-brand::before {
    content: "";
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--shell-codex-accent);
    box-shadow: 0 0 0 4px rgba(115,184,255,.12);
}
body.ws-shell-codex .ws-shell-brand-title { font-size: 13px; letter-spacing: .01em; }
body.ws-shell-codex .ws-shell-brand-sub {
    padding-left: 10px;
    border-left: 1px solid var(--shell-codex-border);
    color: var(--shell-codex-muted);
}
body.ws-shell-codex .ws-shell-nav { gap: 2px; }
body.ws-shell-codex .ws-shell-link {
    min-height: var(--shell-codex-control-height);
    padding: 6px 10px;
    border-color: transparent;
    border-radius: var(--shell-codex-radius);
    background: transparent;
    color: var(--shell-codex-muted);
    font-size: 12px;
    font-weight: 600;
}
body.ws-shell-codex .ws-shell-link:hover {
    background: var(--shell-codex-bg-hover);
    color: var(--shell-codex-text);
    border-color: transparent;
    transform: none;
}
body.ws-shell-codex .ws-shell-link.active {
    color: var(--shell-codex-text);
    background: var(--shell-codex-bg-hover);
    border-color: var(--shell-codex-border);
    box-shadow: inset 0 -1px 0 var(--shell-codex-accent);
}
body.ws-shell-codex .ws-shell-theme-select,
body.ws-shell-codex .ws-shell-locale-select {
    min-height: var(--shell-codex-control-height);
    border-color: var(--shell-codex-border);
    border-radius: var(--shell-codex-radius);
    background: var(--shell-codex-bg-raised);
    color: var(--shell-codex-text);
}
body.ws-shell-codex .ws-shell-connectivity {
    min-height: 25px;
    border-color: var(--shell-codex-border);
    border-radius: var(--shell-codex-radius);
    background: transparent;
}
body.ws-shell-codex .ws-shell-bottom {
    background: var(--shell-codex-bg) !important;
    border-top-color: var(--shell-codex-border);
    color: var(--shell-codex-muted);
}
body.ws-shell-codex .ws-shell-bottom a,
body.ws-shell-codex .ws-shell-record-version { color: var(--shell-codex-muted); }
body.ws-shell-codex .ws-shell-bottom a:hover,
body.ws-shell-codex .ws-shell-record-version:hover { color: var(--shell-codex-text); }

@media (max-width: 1100px) {
    body.ws-shell-codex .ws-shell-mobile-cluster {
        border-color: var(--shell-codex-border);
        border-radius: 10px;
        background: var(--shell-codex-bg-raised);
        box-shadow: 0 24px 60px rgba(0,0,0,.4);
        backdrop-filter: none;
    }
    body.ws-shell-codex .ws-shell-menu-button {
        border-color: var(--shell-codex-border);
        border-radius: var(--shell-codex-radius);
        background: var(--shell-codex-bg-raised);
        color: var(--shell-codex-text);
    }
}

@media (prefers-reduced-motion: reduce) {
    body.ws-shell-codex .ws-shell-link { transition: none; }
}
