/* ============================================================
   The shell (UI revision, PatchWork Standard v10): the desktop title bar,
   New and its menu, the account menu, and the phone tab bar with its sheets.
   Built by js/pw-shell.js. Loaded last, so it wins the ties with style.css,
   mobile.css and desktop.css.
   ============================================================ */

/* ─── Desktop title bar ───────────────────────────────────────
   One 46px strip over every screen but the node canvas (there the canvas
   toolbar is the strip). The home screen starts under it, and so does every
   drawer or sheet pinned to the top. Nothing of ours sits in the caption zone:
   .sl-titlebar pads its right end by the caption width (Windows, Linux) or its
   left end by 78px (macOS traffic lights at x 14). */
.pw-titlebar { display: none; }
/* the screen's own actions (PWShell.setActions), at the right end of the bar */
.pw-titlebar-acts { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.pw-titlebar-acts:empty { display: none; }
.pw-titlebar-act {
    display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
    border: 1px solid var(--sl-border); border-radius: var(--sl-r-8);
    background: var(--sl-quiet); color: var(--sl-text-1);
    font: 500 12.5px var(--sl-font-ui); cursor: pointer; -webkit-app-region: no-drag;
}
.pw-titlebar-act:hover { background: var(--sl-quiet-hover); border-color: var(--sl-border-strong); }
.pw-titlebar-act:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: 1px; }
/* The first child of #home-screen, fixed across the whole window (the agent
   dock narrows the home screen, not the strip). Full-window overlays that
   mount in #home-screen later (Generate's player) still cover it. */
.pw-desktop .pw-titlebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
}
.pw-desktop:not(.pw-desktop-mac) .pw-titlebar { --sl-caption-w: max(138px, var(--pw-caption-w, 138px)); }
.pw-desktop .home-screen { padding-top: 46px; box-sizing: border-box; }
/* A page sized to the window (style.css: Settings min-height 100vh, All assets height
   100vh) fits what is left under the strip: Settings' footer (Cancel, Save) and the
   bottom of All assets sat 46px below the window. */
.pw-desktop #home-tab-settings .home-tab-panel,
.pw-desktop #home-settings-container { min-height: calc(100vh - 46px); }
.pw-desktop #home-tab-assets .home-tab-panel.home-assets-page { height: calc(100vh - 46px); }
/* The canvas toolbar behind the home screen is the canvas's own strip. A drag
   area applies in page order, so its buttons punched no-drag holes in this
   strip; an element that is not visible adds no area at all. */
.pw-desktop body.pw-home-up #toolbar .toolbar-row-top { visibility: hidden; }
/* Drawers and docks pinned to the window's right edge start under the strip. */
.pw-desktop body.pw-home-up #agent-chat-panel.agc-dock { top: 46px; }

/* ─── New ─────────────────────────────────────────────────── */
.home-sidebar .sl-rail-new {
    height: var(--sl-h);
    box-sizing: border-box;
}
.home-sidebar .sl-rail-new svg { flex: none; }

.pw-new-menu {
    width: 340px;
    max-width: calc(100vw - 16px);
    z-index: 10500;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    font-family: var(--sl-font-ui);
}
.pw-new-kicker { padding: 6px 10px 4px; }
.pw-new-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: var(--sl-r-8);
    background: none;
    text-align: left;
    font-family: var(--sl-font-ui);
    color: var(--sl-text-1);
    cursor: pointer;
}
.pw-new-item:hover,
.pw-new-item:focus-visible { background: var(--sl-wash); outline: none; }
.pw-new-item:focus-visible { box-shadow: 0 0 0 2px var(--sl-focus); }
.pw-new-item:disabled { opacity: 0.45; cursor: default; }
.pw-new-item:disabled:hover { background: none; }
.pw-new-ic {
    width: 30px;
    height: 30px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--sl-r-8);
    background: var(--sl-quiet);
    color: var(--sl-link);
}
.pw-new-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pw-new-what { font-size: 13.5px; font-weight: 600; }
.pw-new-tool { font-size: 11px; color: var(--sl-text-2); }
.pw-new-small { height: 32px; font-size: 12.5px; }
.pw-new-small-label { flex: 1; min-width: 0; }
.pw-new-small:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--sl-focus); }

/* ─── The account menu ───────────────────────────────────────
   Lives in the rail footer (editor.html); fixed, so the rail's clipping does
   not cut it. Its rows are .home-sidebar-tab, so the rail routes them. */
.pw-account-menu {
    position: fixed;
    min-width: 210px;
    z-index: 10500;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.pw-account-menu[hidden] { display: none; }
.pw-account-menu .sl-menu-item { height: 30px; }
.pw-account-menu .sl-menu-item .sl-navicon { color: var(--sl-text-3); }
.pw-account-menu .sl-menu-item .sl-navicon svg { width: 13px; height: 13px; }
.pw-account-menu .sl-menu-item.is-active { background: var(--sl-selected); color: var(--sl-text-1); }
.pw-account-menu .sl-menu-item.is-active .sl-navicon { color: var(--sl-link); }
.pw-account-menu .sl-menu-item:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--sl-focus); }

/* ─── Phone: the tab bar ─────────────────────────────────────
   Home · Generate · + New · Explore · More, at the bottom. The rail itself
   hides; every other row is in the More sheet, in the rail's groups. */
.pw-tabbar { display: none; }
body.pw-mobile .home-sidebar { display: none !important; }
body.pw-mobile .pw-tabbar {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    height: calc(58px + var(--pw-safe-bottom, env(safe-area-inset-bottom, 0px)));
    padding: 0 6px var(--pw-safe-bottom, env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    align-items: stretch;
    background: var(--sl-panel);
    border-top: 1px solid var(--sl-hairline);
}
body.pw-mobile .home-screen .home-main-area {
    padding-top: var(--pw-safe-top, 0px);
    padding-bottom: calc(58px + var(--pw-safe-bottom, env(safe-area-inset-bottom, 0px)));
    box-sizing: border-box;
}
.pw-tab {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0;
    border: none;
    background: none;
    color: var(--sl-text-2);
    font-family: var(--sl-font-ui);
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
}
.pw-tab-ic { display: inline-flex; }
.pw-tab.is-active { color: var(--sl-text-1); }
.pw-tab.is-active .pw-tab-ic { color: var(--sl-link); }
.pw-tab.is-new .pw-tab-ic {
    width: 40px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--sl-accent);
    color: var(--sl-on-accent);
}
.pw-tab.is-new .pw-tab-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pw-tab:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: -4px; border-radius: 10px; }

/* ─── Phone: sheets (More, New, Profile and settings) ─────── */
.pw-sheet-scrim {
    position: fixed;
    inset: 0;
    z-index: 10400;
    background: var(--sl-scrim);
}
.pw-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10410;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 12px calc(12px + var(--pw-safe-bottom, env(safe-area-inset-bottom, 0px)));
    box-sizing: border-box;
    background: var(--sl-raised);
    border-top: 1px solid var(--sl-border);
    border-radius: 16px 16px 0 0;
    box-shadow: var(--sl-shadow-modal);
    font-family: var(--sl-font-ui);
    color: var(--sl-text-1);
}
.pw-sheet-handle {
    align-self: center;
    width: 44px;
    height: 20px;
    flex: none;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    position: relative;
}
.pw-sheet-handle::before {
    content: '';
    position: absolute;
    left: 6px;
    right: 6px;
    top: 8px;
    height: 4px;
    border-radius: 2px;
    background: var(--sl-border-strong);
}
.pw-sheet-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.pw-sheet-body .sl-menu-label { padding: 10px 10px 4px; }
.pw-sheet-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 12px;
    border: none;
    border-radius: var(--sl-r-10);
    background: none;
    color: var(--sl-text-1);
    font-family: var(--sl-font-ui);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.pw-sheet-row .pw-ic { color: var(--sl-text-2); }
.pw-sheet-row:focus-visible { outline: 2px solid var(--sl-focus); outline-offset: -2px; }
.pw-sheet:focus { outline: none; }
.pw-sheet-row.is-active { background: var(--sl-selected); }
.pw-sheet-row.is-active .pw-ic { color: var(--sl-link); }
.pw-sheet-row:disabled { opacity: 0.45; cursor: default; }
.pw-sheet-row-label { flex: 1; min-width: 0; }
.pw-sheet-row-note { font-family: var(--sl-font-mono); font-size: 11px; font-weight: 500; color: var(--sl-text-2); }
.pw-sheet-cancel { width: 100%; height: 44px; flex: none; justify-content: center; }
/* New, as a sheet: the same rows at touch size. */
.pw-new-menu.is-sheet {
    width: auto;
    max-width: none;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
}
.pw-new-menu.is-sheet .pw-new-item { min-height: 52px; }
.pw-new-menu.is-sheet .pw-new-small { height: 44px; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
    .pw-sheet, .pw-sheet-scrim { transition: none; }
}

/* ─── PageHeader on older page heads ─────────────────────────
   Projects, Renders, Tutorial and Presets keep their old head class beside
   .sl-pagehead; those set a row layout. The component's column wins here. */
.sl-pagehead { align-items: stretch; justify-content: flex-start; flex-wrap: nowrap; }
.sl-pagehead.home-tab-header { margin-bottom: 20px; }
