/* B8 document views share layout; B4 keeps original identities and library scopes. */
.document-panel{position:fixed;inset:0;margin:auto;width:min(760px,calc(100vw - 24px));height:max-content;max-height:88dvh;box-sizing:border-box;border:1px solid #838a91;border-radius:14px;background:#f4f4ef;color:#202624;padding:12px;overflow:hidden}
.document-panel[open]{display:flex;flex-direction:column;gap:8px}
.document-panel::backdrop{background:#071b2466}
.document-panel>header{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none}
.desk-panel-title{font-size:15px;font-weight:700;line-height:1.2}
.document-panel button,.document-panel input{box-sizing:border-box;font:inherit;touch-action:manipulation}
.document-panel button{min-height:32px;padding:6px 8px;border:1px solid #838a91;border-radius:8px;background:#fff;color:#202624;cursor:pointer}
.document-panel>nav{display:flex;gap:6px;flex:none}
.document-panel>nav button{flex:1;min-width:0;font-size:13px}
.document-panel [aria-pressed=true]{background:#175c53;color:#fff}
.document-panel .desk-panel-toggle{display:flex;align-items:center;gap:7px;flex:1;min-width:0;min-height:24px;margin:0;border:0;background:transparent;padding:0;text-align:left}
.document-panel .desk-panel-toggle:disabled{opacity:1;cursor:default}
.document-body{overflow:auto;min-width:0;min-height:0;flex:1;overscroll-behavior:contain}
.document-content[hidden],[hidden]#rulesPanel,.document-body>section[hidden]{display:none}
.document-status{font-size:12px;line-height:1.35;overflow-wrap:anywhere;margin:6px 0}
.document-upload-section,.document-choose-section{margin:8px 0;border:1px solid #b9bcb5;border-radius:9px}
.document-upload-section>summary,.document-choose-section>summary{padding:8px;font-size:12px;cursor:pointer}
.document-upload{display:grid;gap:8px;padding:8px;border-top:1px solid #b9bcb5}
.document-upload-section:not([open]) .document-upload,.document-choose-section:not([open]) .document-candidates{display:none}
.document-upload input{display:block;max-width:100%;min-width:0;width:100%;margin-top:7px}
.document-upload.drag-over{outline:2px solid #175c53}
.document-candidates{padding:0 8px 8px}
.document-items,.document-candidates{display:grid;grid-template-columns:minmax(0,1fr);gap:3px;min-width:0}
.library-item{min-width:0;margin:0;border-bottom:1px solid #d4dad5}
.library-item>summary{min-height:30px;box-sizing:border-box;padding:6px 3px;cursor:pointer;font-size:13px;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;list-style-position:inside}
.library-item[open]>summary{white-space:normal;overflow-wrap:anywhere}
.document-details{display:grid;min-width:0;gap:7px;padding:0 6px 10px 17px;overflow-wrap:anywhere}
details.library-item:not([open])>.document-details{display:none}
.document-details small{color:#4c5954;line-height:1.35}
.document-details button{width:100%;font-size:12px}
#deskPanels{display:contents}
#documentSearchDesktop{display:none}
.search-panel form{display:grid;gap:8px}
.search-panel input[type=search]{width:100%;min-height:36px;padding:6px}
.search-scopes{display:flex;flex-wrap:wrap;gap:8px 14px;font-size:13px}
.search-scopes label{display:flex;align-items:center;gap:4px}
#documentSearchResults{overflow:auto;min-height:0}
.search-places details{display:inline-block}
.search-places ul{margin:4px 0;padding-left:22px}
.search-panel .document-details select{min-height:34px;max-width:100%;font:inherit}
@media(min-width:768px){
 #deskPanels{position:fixed;top:max(8px,env(safe-area-inset-top));right:12px;bottom:8px;width:min(320px,calc(25% - 24px));z-index:7;display:grid;align-content:start;align-items:start;overflow:auto;padding:0 2px 14px;box-sizing:border-box}
 #documentSearchDesktop{display:block;width:100%;min-height:34px;border:1px solid #838a91;border-radius:9px;background:#f4f4ef;color:#202624;text-align:left;padding:5px 10px;cursor:pointer}
 #deskPanels>.desk-panel{position:relative;inset:auto;margin:0;width:100%;height:auto;max-height:100%;min-height:44px;flex:0 1 auto;box-sizing:border-box;overflow:hidden;padding:10px;border-radius:14px;background:#f4f4ef}
 #deskPanels>.desk-panel[open],#deskPanels>#notepadPanel{display:flex;flex-direction:column;gap:7px}
 #deskPanels>.desk-panel:not(.desk-expanded)>.desk-panel-body,#deskPanels>.document-panel:not(.desk-expanded)>nav{display:none}
 #deskPanels .document-close,#deskPanels #notepadClose{display:none}
 #deskPanels .desk-panel-toggle{display:flex;align-items:center;gap:7px;font:inherit;flex:1;min-height:24px;min-width:0;background:transparent;border:0;padding:0;text-align:left;cursor:pointer}
 #deskPanels .desk-panel-toggle::before{content:'▸';color:#175c53}
 #deskPanels .desk-panel-toggle[aria-expanded=true]::before{content:'▾'}
 #deskPanels .desk-panel-body{flex:1;min-height:0;overflow:auto}
 #deskPanels>.desk-panel,#documentSearchDesktop{flex:none}
 #deskPanels{container-type:size;--desk-gap:8px;--desk-search-height:34px;--desk-third:calc((100cqh - 2 * var(--desk-gap))/3);--desk-note-height:calc(var(--desk-third) - var(--desk-search-height) - var(--desk-gap));gap:var(--desk-gap);grid-template-rows:max(44px,calc((100% - 2 * var(--desk-gap))/3 - var(--desk-search-height) - var(--desk-gap))) var(--desk-search-height) auto auto}
 #documentSearchDesktop{block-size:var(--desk-search-height)}
 #deskPanels>.desk-panel.desk-expanded{block-size:var(--desk-third)}
 #deskPanels>#notepadPanel.desk-expanded{block-size:auto;max-block-size:max(44px,var(--desk-note-height))}
 #deskPanels>.document-panel{padding:7px;gap:4px}
 #deskPanels .document-panel>header{gap:4px;padding-bottom:3px}
 #deskPanels .document-panel>nav button,#deskPanels .folder-toolbar button{min-height:25px;padding:2px 5px}
 #deskPanels .document-panel .document-add,#deskPanels .document-panel .document-select,#deskPanels .document-panel .document-move{min-width:27px;min-height:27px;padding:0 4px}
 #deskPanels>.desk-panel:not(.desk-expanded)>.document-add-actions{display:none}
 #deskPanels>#notepadPanel:not(.desk-expanded) :is(#notepadEdit,#notepadHighlight){display:none}
 #deskPanels .notepad-content{padding-top:0}
}
@media(max-width:767px){
 .document-panel{position:fixed;inset:0;margin:0;width:100vw;height:100dvh;max-width:none;max-height:none;border:0;border-radius:0;padding:14px max(14px,env(safe-area-inset-right)) max(14px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left))}
 .document-panel input,.document-panel textarea{font-size:16px}
}

#libraryMenuBtn{display:none}html.developer-app #libraryMenuBtn{display:block}
.desk-content button[data-desk-open="drawer"]{--desk-bg:#ecf0f3;--desk-hover:#dfe6ed;--desk-active:#d1dce5;--desk-accent:#526779;--desk-icon-bg:#d8e2ea}
.desk-content button[data-desk-open="drawer"] .desk-icon{color:var(--desk-accent);background:var(--desk-icon-bg)}

.desk-content button.desk-search-item{height:64px;--desk-bg:#e1eaf7;--desk-hover:#d2e0f4;--desk-active:#c5d7ee;--desk-accent:#294f91;--desk-icon-bg:#c6d5f0}
.desk-content button.desk-search-item .desk-icon{flex-basis:42px;width:42px;height:42px;border-radius:12px;color:#294f91;background:#c6d5f0}
.desk-content button.desk-search-item .desk-icon svg{width:27px;height:27px}
.document-panel button:disabled{background:#e5e7e9;color:#777e83;border-color:#cfd3d6;cursor:not-allowed;opacity:1;box-shadow:none}
.search-group{display:grid;min-width:0;max-width:100%;gap:6px;padding:8px;border:1px solid #d4dad5;border-radius:9px;background:#f0f1ed}
.search-group>strong{font-size:12px;color:#39443f}
@media(max-width:767px){
 .document-panel{left:0;right:0;width:100%;max-width:100vw;min-width:0;box-sizing:border-box;overflow-x:hidden}
 .search-panel>*{min-width:0;max-width:100%;box-sizing:border-box}
 .search-panel header,.search-panel form,#documentSearchResults,.search-panel .library-item,.search-panel .document-details,.search-panel .search-group{min-width:0;max-width:100%;box-sizing:border-box}
 #documentSearchResults{overflow-x:hidden}
 .search-panel .document-details,.search-panel .search-group{grid-template-columns:minmax(0,1fr)}
 .search-panel .document-details>*,.search-panel .search-group>*{min-width:0;max-width:100%;box-sizing:border-box}
 .search-panel .search-group select{width:100%;font-size:16px}
 .search-panel .document-details button{white-space:normal;overflow-wrap:anywhere}
}
.document-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:5px}
.document-panel .document-name{min-width:0;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:13px;font-weight:650;border-color:transparent;background:transparent}
.document-panel .document-name:hover{text-decoration:underline}
.document-panel .document-menu{min-width:36px;font-weight:700}
.document-panel .document-details[hidden]{display:none}
.document-panel .document-open{background:#245e8d;border-color:#245e8d;color:white}
.document-panel .document-remove{background:#954b50;border-color:#954b50;color:white}
.document-row:has(.document-drag){grid-template-columns:auto minmax(0,1fr) auto}
.document-panel .document-drag{min-width:32px;padding:4px;cursor:grab;touch-action:none;user-select:none;color:#4c5954}
.document-panel .document-drag:disabled{opacity:.45;cursor:default}
.library-item.drag-pending,.library-item.dragging{background:#dceaf4}
.library-item.dragging .document-drag{cursor:grabbing}
.library-folders,.folder-list{display:grid;gap:4px;min-width:0}
.folder-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:5px;font-size:12px}
.folder-toolbar strong{min-width:0;overflow-wrap:anywhere}
.document-row:has(input[type=checkbox]){grid-template-columns:auto minmax(0,1fr) auto}
.folder-icon{position:relative;display:inline-block;width:15px;height:10px;margin-right:7px;vertical-align:baseline;border:1px solid #a87924;border-radius:2px;background:#f2c351}
.folder-icon::before{content:"";position:absolute;left:0;top:-4px;width:7px;height:3px;border:1px solid #a87924;border-bottom:0;border-radius:2px 2px 0 0;background:#f2c351}
.folder-dialog{width:min(420px,calc(100vw - 24px))}
.folder-dialog form,.folder-dialog form>div{display:grid;gap:8px;min-width:0;overflow-wrap:anywhere}
.folder-dialog select,.folder-dialog input:not([type=radio]){width:100%;min-width:0;min-height:36px;font-size:16px}
.folder-dialog form>p:empty{display:none}
.folder-dialog label{display:flex;gap:6px;align-items:flex-start}
.folder-dialog p{margin:0}

.folder-context{display:flex;align-items:center;gap:6px;padding:3px 5px;border:1px solid #d6ad50;border-left-width:3px;border-radius:6px;background:#fff3d4;color:#35290f;min-width:0}
.document-panel .folder-context>button{display:flex;align-items:center;gap:5px;min-height:26px;padding:0 5px;flex:1;min-width:0;text-align:left;font-size:13px;color:#35290f;border-color:transparent;background:transparent}
.folder-context-heading:hover strong{text-decoration:underline}
.folder-back-arrow{color:#244d72;flex:none}
.document-panel .folder-name{display:flex;align-items:center;gap:5px}
.folder-name .folder-icon{flex:none;margin-right:0}
.folder-title{overflow:hidden;text-overflow:ellipsis}
.document-count{font-size:11px;font-weight:400;white-space:nowrap;color:#4c5954}
.document-status:empty,.document-select[hidden],.document-move[hidden],.folder-toolbar:empty{display:none}
.folder-context-heading .folder-icon{flex:none}
.folder-context-heading strong{min-width:0;overflow-wrap:anywhere}

@media(max-width:767px){
 .document-panel:modal{top:var(--document-viewport-top,0px);bottom:auto;height:var(--document-viewport-height,100dvh)}
 .document-panel.folder-dialog:modal{
  top:calc(var(--document-viewport-top,0px) + max(10px,env(safe-area-inset-top)));
  left:12px;right:12px;width:auto;height:max-content;
  max-height:calc(var(--document-viewport-height,100dvh) - max(10px,env(safe-area-inset-top)) - 10px);
  border:1px solid #838a91;border-radius:14px;padding:12px;overflow:auto;overscroll-behavior:contain
 }
}

#deskPanels>#notepadPanel,#notepadPanel.open{background:var(--notepad-paper,#f4f4ef);border:1px solid var(--notepad-edge,#838a91);border-radius:2px 2px 14px 2px;box-shadow:2px 6px 12px #14201666}
#notepadPanel.has-notes{--notepad-paper:#fff0ab;--notepad-edge:#ddc578;--notepad-fold:#e1c068;--notepad-input-bg:#fff9d4}
#notepadPanel::after{content:'';position:absolute;right:0;bottom:0;width:13px;height:13px;background:linear-gradient(135deg,var(--notepad-paper,#f4f4ef) 45%,var(--notepad-fold,#bfc2b9) 52%,var(--notepad-paper,#f4f4ef));border-radius:2px 0 12px 0;pointer-events:none}
#deskPanels>#libraryPanel,#libraryPanel{background:#f9f5eb}
#deskPanels>#drawerPanel,#drawerPanel{background:#ecf0f3}
#libraryPanel>header,#drawerPanel>header{border-bottom:1px solid #aeb6b9;padding-bottom:5px}
.collection-icon{font-size:20px;width:27px;text-align:center;flex:none}
.drawer-icon{position:relative;width:23px;height:17px;border:1px solid #63727d;border-radius:2px;background:linear-gradient(#546879 0 35%,#a6b4bf 36% 100%)}
.drawer-icon::after{content:'';position:absolute;left:7px;top:9px;width:8px;height:3px;background:#fff;border-radius:1px}
.document-add-actions{display:grid;gap:5px}
.document-add-actions[hidden]{display:none}
.document-add-actions button{text-align:left}
.document-add{min-width:36px}
@media(max-width:767px){.document-panel .document-add{min-width:44px;min-height:44px}}
.document-type-icon{display:inline-grid;place-items:center;vertical-align:middle;line-height:1;width:1.55em;height:1.55em;margin-inline-end:6px;border-radius:3px;font-size:10px;font-weight:750;color:white;background:#5b6e7d}
.file-word{background:#215ca8}.file-sheet{background:#187143}.file-pdf{background:#bc282e;font-size:8px;width:1.95em}.file-slides{background:#a24422}

.document-upload-section:not([open]),.document-choose-section:not([open]){display:none}
.document-type-icon::before{content:attr(data-file-label)}
.file-file::before{content:'▤'}

.document-link-address{overflow-wrap:anywhere}
.folder-dialog input+input{margin-top:6px}

.desktop-upload-dialog{width:min(540px,calc(100vw - 32px));max-height:calc(100dvh - 32px);overflow:auto}
.desktop-upload-dialog header{display:flex;justify-content:space-between;align-items:center;gap:12px;border-bottom:1px solid #d4dad5;padding-bottom:10px}
.desktop-upload-dialog .upload-destination{margin:12px 0;color:#39443f;overflow-wrap:anywhere}
.desktop-upload-dialog .document-upload{gap:14px;padding:14px;border:1px dashed #838a91;border-radius:8px}
.desktop-upload-dialog .document-upload label{display:block}
.desktop-upload-dialog .document-upload button{justify-self:start;min-height:36px}
.desktop-upload-dialog .upload-status:not(:empty){margin-top:12px}
