/* Leonardo Desk -- the MDI shell. Every open screen is a same-origin iframe
   inside .dk-area; the desk supplies the window chrome the browser does not,
   because an installed PWA runs in standalone mode and has no tabs of its own.

   The look is LD2's (Story 5701): the icon band, then ONE thin tab row in LD2's
   colors (strip #1A1A1A, the tab in front #2A2A2A, the band's own color, so the
   chrome reads as one piece), then the screens.

   Layout follows the pinned-chrome rule: the shell is the only full-height
   flex column, every chrome row is flex 0 0 auto, and .dk-area is the single
   flex:1 child. Nothing here may scroll the document. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: #E9E9EC; color: #222;
    font-family: "Segoe UI", system-ui, sans-serif; }

.page-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
#lwIconBand, .ct-header { flex: 0 0 auto; }
/* No gap between the band and the tab row (picasso-base gives .lw-nav + * a margin). */
#lwIconBand + .ct-header, .lw-nav + .ct-header { margin-top: 0; }

/* ---- the tab row ------------------------------------------------------- */
.ct-header.dk-strip {
    background: #1A1A1A; color: #E8E8E8;
    display: flex; align-items: flex-end; gap: 4px;
    min-height: 34px; padding: 4px 6px 0;
    border-bottom: 3px solid #2A2A2A;
}
.ct-header [hidden] { display: none !important; }

/* The page name shows only while nothing is open; then the tabs take the row. */
.dk-title { margin: 0 8px 6px 4px; font-size: 13px; font-weight: 600; color: #E8E8E8; white-space: nowrap; }
body:not(.dk-empty) .dk-title { display: none; }

.dk-tabs { flex: 1 1 auto; min-width: 0; display: flex; align-items: flex-end; gap: 2px;
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none; min-height: 30px; }
.dk-tabs::-webkit-scrollbar { display: none; }

.dk-tab {
    flex: 0 1 220px; min-width: 90px; max-width: 220px; height: 30px;
    display: flex; align-items: center; gap: 4px;
    background: transparent; color: #9A9A9A;
    border-radius: 6px 6px 0 0; padding: 0 6px 0 12px;
    font-size: 12.5px; cursor: pointer; white-space: nowrap; user-select: none;
}
.dk-tab:hover { background: #242424; color: #E8E8E8; }
.dk-tab.active { background: #2A2A2A; color: #E8E8E8; }
.dk-tab.min .dk-tab-name { font-style: italic; opacity: .75; }
.dk-tab-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dk-tab-x {
    flex: 0 0 auto; width: 20px; height: 20px; border: none; border-radius: 4px;
    background: transparent; color: inherit; font: inherit; font-size: 14px; line-height: 1;
    cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center;
    opacity: .7;
}
.dk-tab-x:hover { background: rgba(255,255,255,.12); opacity: 1; }
/* The tab menu's button shows on the tab in front only. */
.dk-tab .dk-tab-menu { display: none; font-size: 10px; }
.dk-tab.active .dk-tab-menu { display: inline-flex; }

.ct-header.dk-strip button.dk-tabadd,
.dk-winctl button,
.ct-header.dk-strip button.dk-winbtn {
    flex: 0 0 auto; height: 28px; margin-bottom: 1px;
    background: transparent; color: #C8C8C8; border: none; border-radius: 4px;
    font: inherit; font-size: 13px; line-height: 1; cursor: pointer;
}
.ct-header.dk-strip button.dk-tabadd { width: 32px; font-size: 18px; }
.ct-header.dk-strip button.dk-winbtn { padding: 0 10px; font-size: 12.5px; }
.dk-winctl { flex: 0 0 auto; display: flex; gap: 1px; }
.dk-winctl button { min-width: 32px; padding: 0 8px; font-size: 14px; }
.ct-header.dk-strip button.dk-tabadd:hover,
.dk-winctl button:hover,
.ct-header.dk-strip button.dk-winbtn:hover { background: #2E2E2E; color: #fff; }
#btnCloseOne:hover { background: #C42B1C; color: #fff; }

/* ---- the menus ---------------------------------------------------------- */
.dk-menu {
    position: fixed; z-index: 200; min-width: 210px; background: #fff; color: #222;
    border: 1px solid #B9B9C2; border-radius: 6px; box-shadow: 0 8px 26px rgba(0,0,0,.28);
    padding: 4px; display: flex; flex-direction: column;
}
.dk-menu[hidden], .dk-menu [hidden] { display: none !important; }
.dk-menu button {
    text-align: left; background: transparent; border: none; border-radius: 4px;
    padding: 9px 12px; font: inherit; font-size: 14px; color: #222; cursor: pointer;
}
.dk-menu button:hover:not(:disabled) { background: #ECF4FD; }
.dk-menu button:disabled { color: #A0A0A8; cursor: default; }
.dk-menusep { height: 1px; background: #E2E2E6; margin: 4px 6px; }

/* ---- the desk surface ------------------------------------------------ */
.dk-area { flex: 1; position: relative; overflow: hidden; background: #E9E9EC; }

.dk-win {
    position: absolute; display: flex; flex-direction: column;
    background: #fff; border: 1px solid #B9B9C2; border-radius: 6px;
    box-shadow: 0 8px 26px rgba(0,0,0,.22); overflow: hidden;
}
.dk-win.max { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important;
    border-radius: 0; border-width: 0; box-shadow: none; }
.dk-win[hidden] { display: none !important; }

.dk-titlebar {
    flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
    background: #3C3C3C; color: #fff; padding: 4px 6px; font-size: 12px;
    cursor: move; user-select: none; touch-action: none;
}
.dk-win.focused .dk-titlebar { background: #2A2A2A; }
/* A screen that fills the desk has no title bar: its buttons are on the tab row. */
.dk-win.max .dk-titlebar { display: none; }
.dk-titlebar .dk-wt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-titlebar button {
    flex: 0 0 auto; border: none; background: rgba(255,255,255,.1); color: #fff;
    border-radius: 3px; font: inherit; line-height: 1;
    min-width: 28px; font-size: 13px; padding: 3px 8px; cursor: pointer;
}
.dk-titlebar button:hover { background: rgba(255,255,255,.25); }
.dk-titlebar button.dk-wclose:hover { background: #C42B1C; }

.dk-frame { flex: 1; width: 100%; border: 0; background: #fff; }

.dk-grip {
    position: absolute; right: 0; bottom: 0; width: 18px; height: 18px;
    cursor: nwse-resize; background:
        linear-gradient(135deg, transparent 50%, #9A9AA6 50%, #9A9AA6 60%, transparent 60%,
                        transparent 70%, #9A9AA6 70%, #9A9AA6 80%, transparent 80%);
    touch-action: none;
}
.dk-win.max .dk-grip { display: none; }

/* ---- the picker (also the empty state) ------------------------------- */
/* Above every window (z 5 / 10 / 30): asked for, the picker must never open underneath one. */
.dk-picker { position: absolute; inset: 0; z-index: 60; display: flex; flex-direction: column; background: #F2F2F4; }
.dk-picker[hidden] { display: none !important; }
.dk-pickhead { flex: 0 0 auto; display: flex; align-items: stretch; background: #FFFFFF; border-bottom: 1px solid #D8D8DE; }
.dk-pickhead input.dk-search {
    flex: 1 1 auto; min-width: 0; display: block; width: 100%; box-sizing: border-box;
    margin: 0; border: 0; padding: 12px 16px; font: inherit; font-size: 14px;
    background: #FFFFFF; color: #222; outline: none;
}
.dk-pickhead > .voice-mic-wrap { flex: 1 1 auto; min-width: 0; display: block; }
.dk-pickclose {
    flex: 0 0 auto; border: none; border-left: 1px solid #D8D8DE; background: #F7F7F9; color: #222;
    padding: 0 16px; font: inherit; font-size: 14px; cursor: pointer;
}
.dk-pickclose:hover { background: #ECECF0; }
.dk-pickclose[hidden] { display: none !important; }
.dk-list { flex: 1; overflow: auto; padding: 12px 16px 20px; }
.dk-sec { font-size: 10pt; font-weight: 600; color: #5A5A5A; text-transform: uppercase;
    letter-spacing: .5px; margin: 14px 0 8px; }
.dk-sec:first-child { margin-top: 0; }
.dk-item {
    display: block; width: 100%; text-align: left; background: #FFFFFF;
    border: 1px solid #E0E0E2; border-radius: 4px; color: #0A66C2;
    padding: 9px 12px; margin-bottom: 6px; font: inherit; font-size: 12pt; cursor: pointer;
}
.dk-item:hover { background: #ECF4FD; }
.dk-none { color: #777; font-size: 13px; padding: 6px 2px; }

/* On a phone there is no room to float windows and no pointer to drag them
   with, so a screen fills the desk and the tabs are the switcher. */
.dk-winglyph { display: none; font-size: 18px; }
@media (max-width: 899px) {
    .dk-titlebar, .dk-grip { display: none; }
    /* Tabs keep a readable width and the row scrolls sideways, the way a phone browser's tabs do. */
    .dk-tab { flex: 0 0 auto; width: 128px; min-width: 128px; padding-left: 10px; }
    .ct-header.dk-strip button.dk-winbtn { padding: 0 6px; min-width: 32px; }
    .dk-winword { display: none; }
    .dk-winglyph { display: inline; }
    /* One screen at a time on a phone: Minimize has nothing to step aside for. */
    #btnMinOne { display: none; }
}
