/* Shared desktop-style application shell. All visual values resolve through the active --ws-* theme tokens. */

.ws-desktop-menubar {
    min-height: 34px;
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 0 .25rem;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: thin;

    color: var(--ws-text);
    background: var(--ws-surface);
    border-bottom: 1px solid var(--ws-border);
    box-shadow: var(--ws-shadow-soft);
}

.ws-menu {
    position: relative;
    flex: 0 0 auto;
}

.ws-menu > summary {
    list-style: none;
    cursor: default;
    min-height: 34px;
    display: flex;
    align-items: center;
    padding: 0 .65rem;
    white-space: nowrap;
    user-select: none;
    color: var(--ws-text);
}

.ws-menu > summary::-webkit-details-marker { display: none; }
.ws-menu[open] > summary,
.ws-menu > summary:hover {
    background: var(--ws-control-hover);
    color: var(--ws-text);
}

.ws-menu-popup {
    position: fixed;
    top: 64px;
    min-width: 210px;
    max-width: min(92vw, 440px);
    padding: .35rem;
    z-index: 2100;

    color: var(--ws-text);
    background: var(--ws-surface);
    border: 1px solid var(--ws-border);
    border-radius: var(--ws-radius);
    box-shadow: var(--ws-shadow);
    backdrop-filter: var(--ws-backdrop-filter);
    -webkit-backdrop-filter: var(--ws-backdrop-filter);
}

.ws-menu-popup-wide { min-width: 330px; }
.ws-theme-popup { min-width: 290px; }

.ws-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem .6rem;
    border: 0;
    border-radius: max(0px, calc(var(--ws-radius) * .65));
    background: transparent;
    color: var(--ws-text);
    text-decoration: none;
    text-align: left;
    font: inherit;
}

.ws-menu-item:hover,
.ws-menu-item:focus-visible {
    color: var(--ws-primary-text);
    background: var(--ws-primary);
    outline: none;
}

.ws-menu-item small {
    display: block;
    color: var(--ws-text-muted);
    line-height: 1.15;
}

.ws-menu-item:hover small,
.ws-menu-item:focus-visible small { color: currentColor; opacity: .9; }

.ws-menu-icon {
    width: 1.25rem;
    text-align: center;
    flex: 0 0 auto;
}

.ws-menu-separator {
    height: 1px;
    margin: .3rem .25rem;
    background: var(--ws-border);
}

.ws-menu-heading,
.ws-menu-empty,
.ws-menu-note {
    padding: .35rem .6rem;
    color: var(--ws-text-muted);
    font-size: .86em;
}

.ws-menu-heading { font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.ws-menu-note { border-top: 1px solid var(--ws-border); margin-top: .25rem; }

.ws-menu-inline-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .2rem;
}

.ws-context-menu-hook {
    display: flex;
    align-items: center;
    padding: 0 .65rem;
    color: var(--ws-text-muted);
    white-space: nowrap;
    border-left: 1px solid var(--ws-border);
    margin-left: .25rem;
}

/* Fixed right-edge page actions */
.ws-edge-actions {
    position: fixed;
    right: 0;
    top: 38%;
    transform: translateY(-50%);
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: .35rem .3rem;

    background: var(--ws-surface);
    border: 1px solid var(--ws-border);
    border-right: 0;
    border-radius: var(--ws-radius-lg) 0 0 var(--ws-radius-lg);
    box-shadow: var(--ws-shadow-soft);
    backdrop-filter: var(--ws-backdrop-filter);
    -webkit-backdrop-filter: var(--ws-backdrop-filter);
}

.ws-edge-button {
    width: 2.35rem;
    height: 2.35rem;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--ws-text);
    background: var(--ws-control-bg);
    border: 1px solid var(--ws-border);
    border-radius: var(--ws-radius);
    box-shadow: var(--ws-shadow-soft);
}

.ws-edge-button:hover,
.ws-edge-button.is-active {
    color: var(--ws-primary-text);
    background: var(--ws-primary);
}

.ws-edge-button svg { width: 1.18rem; height: 1.18rem; fill: currentColor; }

/* Fixed five-button navigation shared across desktop/tablet/mobile. Items change by active area. */
.ws-bottom-commandbar {
    position: fixed;
    left: 50%;
    bottom: max(.5rem, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 1070;

    width: min(680px, calc(100vw - 1rem));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: .25rem;
    padding: .35rem;

    color: var(--ws-text);
    background: var(--ws-surface);
    border: 1px solid var(--ws-border);
    border-radius: var(--ws-radius-lg);
    box-shadow: var(--ws-shadow);
    backdrop-filter: var(--ws-backdrop-filter);
    -webkit-backdrop-filter: var(--ws-backdrop-filter);
}

.ws-bottom-command {
    min-width: 0;
    min-height: 3.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .15rem;
    padding: .25rem;
    color: var(--ws-text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--ws-radius);
    text-decoration: none;
}

.ws-bottom-command:hover,
.ws-bottom-command.is-active {
    color: var(--ws-primary-text);
    background: var(--ws-primary);
    border-color: var(--ws-primary);
}

.ws-bottom-icon { font-weight: 800; line-height: 1; }
.ws-bottom-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .78em;
}

.ws-quick-panel { min-width: min(520px, 72vw); }
.ws-notes-textarea { min-height: 220px; resize: vertical; }

.ws-area-placeholder { max-width: 980px; margin: 0 auto; }

/* Keep minimized windows to the left of the fixed right-edge action rail. */
.ws-window-dock { right: 3.6rem !important; }

html[data-ws-theme^="classic98"] .ws-desktop-menubar,
html[data-ws-theme^="classic98"] .ws-menu-popup,
html[data-ws-theme^="classic98"] .ws-edge-actions,
html[data-ws-theme^="classic98"] .ws-bottom-commandbar {
    border-radius: 0;
}

html[data-ws-theme^="classic98"] .ws-edge-button,
html[data-ws-theme^="classic98"] .ws-bottom-command,
html[data-ws-theme^="classic98"] .ws-menu-item {
    border-radius: 0;
}

html[data-ws-theme="retro-gamer"] .ws-desktop-menubar,
html[data-ws-theme="retro-gamer"] .ws-menu-popup,
html[data-ws-theme="retro-gamer"] .ws-edge-actions,
html[data-ws-theme="retro-gamer"] .ws-bottom-commandbar {
    border-width: 3px;
}

@media (max-width: 767.98px) {
    .ws-menu-popup {
        top: 64px;
        left: .35rem !important;
        right: .35rem !important;
        max-width: none;
        min-width: 0;
    }

    .ws-edge-actions {
        top: 42%;
    }

    .ws-bottom-commandbar {
        bottom: max(.25rem, env(safe-area-inset-bottom));
        width: calc(100vw - .5rem);
        border-radius: var(--ws-radius-lg);
    }

    .ws-bottom-label { font-size: .7em; }
    .ws-quick-panel { min-width: 0; }
}
