/* New modes follow the existing compact controls, workflow columns and saved rows. */
#generate .generationModeTabs,.savedSpaceTabs,.analysisModeTabs{display:flex;gap:4px;width:fit-content;max-width:100%;padding:4px;margin-bottom:20px;border-radius:12px;background:#efedf5;flex-wrap:wrap}
.generationModeTabs button,.savedSpaceTabs button,.analysisModeTabs button{min-height:40px;border:0;border-radius:8px;background:transparent;padding:10px 20px;text-align:center;font-size:14px;font-weight:650;color:#746c82}
.generationModeTabs b,.analysisModeTabs b{font-size:14px;font-weight:650}.generationModeTabs small,.analysisModeTabs small{display:none}
.generationModeTabs button[aria-pressed=true],.savedSpaceTabs button[aria-pressed=true],.analysisModeTabs button[aria-pressed=true]{background:#fff;color:var(--p);box-shadow:0 2px 8px #29203c0d}
.generationModeTabs button:disabled,.analysisModeTabs button:disabled{opacity:.5;cursor:default}
.generationModeTabs button:focus-visible,.savedSpaceTabs button:focus-visible,.analysisModeTabs button:focus-visible{outline:3px solid #b9aff2;outline-offset:2px}
#worksheetGenerationSpace{grid-template-columns:minmax(310px,400px) minmax(0,1fr);gap:18px;align-items:start}#worksheetResultsHost{display:contents}#worksheetForm{max-width:none;padding:0;min-width:0}#worksheetForm h3{margin:0;font-size:16px}#worksheetForm p,.worksheetNote{color:var(--muted);font-size:13px;line-height:1.6}#worksheetForm .stepHead{gap:9px;margin-bottom:12px;align-items:center}#worksheetForm .stepNum{width:27px;height:27px}#worksheetForm .label{font-size:14px;margin:0 0 8px}#worksheetForm input:not([type=checkbox]):not([type=file]):not([type=hidden]){width:100%;min-width:0;padding:11px 12px;font-size:14px}
.worksheetDrop{display:flex;flex-direction:column;align-items:flex-start;justify-content:space-between;gap:12px;min-height:110px;text-align:left;border:2px dashed #c9c5e4;border-radius:14px;padding:15px;background:#faf9fe;cursor:pointer;margin:0}.worksheetDrop b{font-size:17px;line-height:1.6}.worksheetDrop span{display:block;font-size:14px;color:#8c929f;line-height:1.6}.worksheetDrop:hover{border-color:var(--p);background:var(--ps)}.worksheetDrop:focus-visible,.worksheetCropDialog button:focus-visible{outline:3px solid #b9aff2;outline-offset:3px}
.worksheetImages{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-top:12px}.worksheetImages:empty{display:none}.worksheetPage{min-width:0;padding:8px;border:1px solid var(--line);border-radius:10px}.worksheetPage img{width:100%;height:65px;object-fit:contain}.worksheetPage span{display:block;font-size:11px;overflow-wrap:anywhere;line-height:1.5}.worksheetPage button{font-size:11px;padding:4px 7px;margin-top:6px;min-height:28px}.worksheetInputActions{display:flex;gap:4px;margin-left:auto;flex:none}.worksheetInputActions button{min-height:27px;font-size:11px;padding:3px 7px;white-space:nowrap}
#worksheetForm .worksheetRatioField{min-width:0;margin:0}.worksheetRatioSlider{position:relative;height:4px;margin:16px 9px 10px;touch-action:none;cursor:pointer}.worksheetRatioRail{height:4px;border-radius:99px;background:linear-gradient(to right,#bdb5e9 0 var(--simple-end,20%),#8c7ddd var(--simple-end,20%) var(--caution-end,70%),#6558e8 var(--caution-end,70%) 100%)}.worksheetRatioHandle{position:absolute;top:50%;transform:translate(-50%,-50%);width:18px;height:18px;min-height:18px;min-width:18px;padding:0;border:2px solid var(--p);border-radius:50%;background:#fff;box-shadow:0 1px 4px #29203c22;cursor:grab;touch-action:none;z-index:1}.worksheetRatioHandle:active{cursor:grabbing}.worksheetRatioHandle:focus-visible{outline:3px solid #b9aff2;outline-offset:3px;z-index:2}.worksheetRatioSlider:before{content:'';position:absolute;inset:-12px -9px}.worksheetRatioLabels>span{white-space:normal;word-break:keep-all}.worksheetRatioLabels output{font-weight:650;color:var(--p)}#worksheetRatioTotal{font-size:12px!important;margin:8px 0 0!important;line-height:1.4!important}
.worksheetCandidates{display:grid;gap:8px;margin-top:12px}.worksheetCandidates:empty{display:none}.worksheetCandidate{min-width:0;border:1px solid var(--line);border-radius:10px;padding:12px}.worksheetCandidateHead{display:flex;gap:8px;align-items:center}.worksheetCandidateHead input[type=checkbox]{width:16px;min-height:16px;margin:0;flex:none}.worksheetCandidateHead b{font-size:13px;min-width:0;flex:1;overflow-wrap:anywhere}.worksheetCandidateHead button{padding:5px 8px;font-size:11px;min-height:30px;white-space:nowrap}.worksheetCandidate>details{margin-top:10px}.worksheetCandidate>details>summary{font-size:12px;cursor:pointer;color:#746c82}.worksheetCandidate>details>small{display:block;margin-top:10px;font-size:11px;color:var(--muted);overflow-wrap:anywhere}.worksheetCandidate img{display:block;max-width:100%;max-height:240px;object-fit:contain;margin:12px auto}.worksheetCandidate textarea{width:100%;min-height:110px;font-size:13px;line-height:1.7}.worksheetWarning{color:#a04e4e!important}.worksheetCandidate>label{display:flex;align-items:flex-start;gap:6px;font-size:12px;line-height:1.6}.worksheetCandidate>label input{width:16px;min-height:16px;flex:none;margin:2px 0 0}
.worksheetCropDialog{width:min(850px,calc(100vw - 30px));max-height:90dvh;overflow:auto;border:1px solid var(--line);border-radius:16px;padding:22px}.worksheetCropDialog::backdrop{background:#17192366}.worksheetCropDialog canvas{width:100%;touch-action:none;cursor:crosshair}.worksheetCropDialog p{font-size:13px;color:var(--muted)}
.worksheetFooter{display:grid;gap:12px;border-top:1px solid var(--line);padding:15px 18px;margin:0}.worksheetQuote{display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:12px;color:var(--muted)}.worksheetQuote strong{font-size:13px;color:var(--p)}.worksheetFooter>.primary{justify-self:center;width:auto;min-width:0;min-height:52px;padding:14px 24px;font-size:16px;font-weight:750}.worksheetFooter button:disabled{opacity:.45;cursor:not-allowed}.worksheetStatus{font-size:13px;color:var(--muted);line-height:1.6;overflow-wrap:anywhere}.worksheetStatus:empty{display:none}#worksheetInputStatus{margin:10px 0 0}#worksheetRunStatus:not(:empty){padding:0 18px 15px;margin:0}
#savedWorksheetsSpace .savedSearchBar>div input{flex:1;width:100%;min-width:0}#savedWorksheetsSpace .savedListHeading:has(.actions.hidden){display:none}#worksheetPrint{min-height:52px;padding:15px 26px;border:1px solid var(--p);border-radius:12px;background:var(--p);color:#fff;font-size:16px;font-weight:800;line-height:1.4;box-shadow:0 5px 14px #6558e833}#worksheetPrint:not(:disabled):hover{background:#5547d5;border-color:#5547d5}#worksheetPrint:focus-visible{outline:3px solid #b7abec;outline-offset:3px}#worksheetPrint:disabled{background:#c5bee9;border-color:#c5bee9;box-shadow:none;opacity:1}#worksheetSavedStatus:empty{display:none}.worksheetMoveDialog{width:min(440px,calc(100vw - 32px));padding:26px;border:1px solid var(--line);border-radius:16px;color:var(--ink)}.worksheetMoveDialog::backdrop{background:#17192366}.worksheetMoveDialog h3{font-size:19px;margin:0 0 12px}.worksheetMoveDialog p{font-size:14px;color:var(--muted);line-height:1.65}.worksheetMoveDialog select{width:100%}.worksheetMoveDialog .actions{justify-content:flex-end;margin-top:20px}
.worksheetList{min-width:0}.worksheetSaved .savedPostTitle{font-size:15px;overflow-wrap:anywhere;white-space:normal}.worksheetCompletion{flex:none;white-space:nowrap;font-size:11px;border-radius:99px;padding:4px 8px;background:#f3f1f8;color:#716987}.worksheetCompletion.done{background:#edf8f2;color:#267a55}.worksheetSavedBody{padding:0 22px 22px}.worksheetSavedMeta{font-size:12px;color:var(--muted);line-height:1.8;padding-top:16px}.worksheetSavedBody>.actions{gap:8px;flex-wrap:wrap;margin:12px 0 20px}.worksheetSavedBody>.actions button{font-size:13px;min-height:38px}.worksheetSavedItem{border-top:1px solid var(--line);padding:18px 0;min-width:0;overflow-wrap:anywhere}.worksheetSavedItem h4{font-size:14px;margin:0 0 14px}.worksheetSavedItem>.problem{font-size:15px}.worksheetSavedItem details{margin-top:14px}.worksheetSavedItem details>summary{font-size:13px;cursor:pointer}.worksheetSavedItem .answer{font-size:14px;line-height:1.65;white-space:pre-line;padding-top:12px}.worksheetSavedItem .answer strong{display:block}.worksheetSavedItem mjx-container{max-width:100%;overflow-x:auto;overflow-y:hidden}.worksheetList>.empty{padding:40px 24px;min-height:120px;text-align:center;font-size:14px;color:var(--muted)}
#generate [hidden],#saved [hidden],.worksheetCropDialog [hidden]{display:none!important}
@media(max-width:1050px){#worksheetGenerationSpace{grid-template-columns:1fr}}
@media(max-width:640px){.generationModeTabs button,.analysisModeTabs button,.savedSpaceTabs button{padding:10px 14px}.worksheetSaved>summary{padding:16px;gap:8px;flex-wrap:wrap}.worksheetSaved .savedPostTitle{flex-basis:calc(100% - 86px)}.worksheetSaved .savedCreatedDate{order:2}.worksheetSaved .savedPostChevron{order:1}.worksheetSavedBody{padding:0 16px 18px}.worksheetSavedBody>.actions button{flex:1}#worksheetPrint{width:100%;min-height:52px;margin-top:6px}}
.worksheetImages{max-height:200px;overflow:auto;overscroll-behavior:contain}.worksheetCandidates{max-height:320px;overflow:auto;overscroll-behavior:contain}

@media(max-width:600px){.worksheetFooter>.primary{min-width:0;padding:13px 18px;font-size:15px}}
@media(max-width:760px){#worksheetForm .stepNum{width:34px;height:34px}}

/* Small alignment adjustments shared by both modes. */
.generationModeTabs button,.analysisModeTabs button,.savedSpaceTabs button{display:inline-flex;align-items:center;justify-content:center;min-height:42px;line-height:20px}.generationModeTabs b,.analysisModeTabs b{display:block;line-height:20px}
#generate .stepHead{align-items:center}
#generate #imageDrop,#generate #worksheetDrop{align-items:center;justify-content:center;text-align:center;gap:12px}
#generate #imageDrop b,#generate #worksheetDrop b{display:block;width:100%;text-align:center;word-break:keep-all;text-wrap:balance}
#generate #imageDrop span,#generate #worksheetDrop span{display:block;width:100%;text-align:center;word-break:keep-all;text-wrap:balance}
#generate .rangeTicks{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:center;line-height:1.5;gap:4px}
#generate .rangeTicks>span:first-child{text-align:left}#generate .rangeTicks>span:nth-child(2){text-align:center}#generate .rangeTicks>span:last-child{text-align:right}
.worksheetRatioLabels output{display:inline-block;min-width:4ch;text-align:right;font-variant-numeric:tabular-nums}
.worksheetInputActions button,.analysisActions button{display:inline-flex;align-items:center;justify-content:center}.worksheetInputActions button{line-height:18px}
#analyze .analysisDropIcon{display:grid;place-items:center;line-height:1;font-size:23px;margin:0 auto 14px}
#analyze .analysisDrop b,#analyze .analysisDrop span{word-break:keep-all;text-wrap:balance}
#saved .savedPost>summary{align-items:center}#saved .savedSelectTarget{margin-top:12px}#saved .savedFolders nav small,.worksheetCompletion{font-variant-numeric:tabular-nums}

/* Saved library: separate controls, search, folders and content without changing order. */
#saved .savedTop{margin-bottom:14px}
#saved .savedTop>div:empty{display:none}
#saved .savedTop>.actions{width:100%;margin:0;gap:8px;align-items:center;justify-content:flex-end}
#saved .savedSearchBar{margin:0 0 18px;padding:14px 16px;border:1px solid #dde1ec;border-radius:12px;background:#fff}
#saved .savedSearchBar>label{font-size:13px;font-weight:650;color:#555c70;margin-bottom:10px}
#saved .savedSearchBar>div{min-width:0}
#saved .savedSearchBar input{min-width:0;flex:1}
#saved .savedSearchBar button{flex:none}
#saved .savedWorkspace{gap:18px;align-items:start}
#saved .savedFolders{border-color:#dde1ec;border-radius:12px}
#saved .savedListPanel{min-width:0;padding:14px 16px 0;border:1px solid #dde1ec;border-radius:12px;background:#fff}
#saved .savedListHeading{padding-bottom:12px;margin-bottom:12px;border-bottom:1px solid var(--line)}
#saved .savedDateGroup>h3{padding:10px 12px;border:1px solid #e9ebf2;border-radius:8px;background:#f7f8fc}
#saved .savedDateGroup:last-child{margin-bottom:0}
#saved .savedPostBody .savedCardActions,#saved .worksheetSavedBody>.actions{margin:14px 0 20px;padding:12px;border:1px solid #e3e6ef;border-radius:10px;background:#f8f9fc}
#saved .savedListPanel .recordPager:empty{display:none}
@media(max-width:640px){
 #saved .savedTop>.actions{gap:8px}
 #saved .savedSearchBar{padding:12px}
 #saved .savedSearchBar>div{gap:8px}
 #saved .savedSearchBar button{padding:10px;font-size:13px}
 #saved .savedListPanel{padding:10px 12px 0}
 #saved .savedWorkspace{gap:12px}
}
@media print{#saved .savedTop,#saved .savedSearchBar,#saved .savedFolders{display:none!important}#saved .savedListPanel{padding:0;border:0}}

/* Uploaded originals replace the empty drop-zone instructions, as in multiple analysis. */
#worksheetDropEmpty{width:100%;text-align:center}#worksheetDropEmpty>span{margin-top:12px}
#worksheetDrop .worksheetDropPreview{display:grid;width:100%;gap:8px;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));max-height:320px;overflow:auto;overscroll-behavior:contain}
#worksheetDrop .worksheetDropPreview:empty{display:none}#worksheetDrop .worksheetPreviewPage{min-width:0;align-self:center}
#worksheetDrop .worksheetPreviewPage img{display:block;width:100%;height:220px;max-height:280px;object-fit:contain;margin:0 auto}
#generate #worksheetDrop.hasImages{justify-content:flex-start;padding:16px}
.worksheetAttachments{display:grid;gap:6px;margin-top:10px;max-height:160px;overflow:auto}.worksheetAttachments:empty{display:none}
.worksheetAttachments .worksheetPage{display:flex;align-items:center;flex-wrap:wrap;gap:8px;border:0;padding:0}
.worksheetAttachments .worksheetPage>span{flex:1;min-width:0;font-size:12px;color:var(--muted)}.worksheetAttachments .worksheetPage>button{margin:0;flex:none}
.worksheetAttachments .worksheetPage>.worksheetWarning{flex-basis:100%}
.worksheetSelectionHead{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:4px;font-size:13px}.worksheetSelectionHead>div{display:flex;gap:6px}.worksheetSelectionHead button{font-size:11px;padding:5px 8px;min-height:30px}.worksheetResultPicker{display:flex;align-items:center;gap:10px;margin:0 0 14px}.worksheetResultPicker label{font-size:13px;white-space:nowrap}.worksheetResultPicker select{flex:1;min-width:0;padding:9px 12px;border:1px solid var(--line);border-radius:9px;background:#fff;color:var(--text)}.worksheetSourceDialog{width:min(760px,calc(100vw - 30px));max-height:90dvh;overflow:auto;border:1px solid var(--line);border-radius:16px;padding:20px}.worksheetSourceDialog::backdrop{background:#17192366}.worksheetSourceHead{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px}.worksheetSourceHead h3{margin:0;font-size:16px}.worksheetSourceDialog img{display:block;max-width:100%;max-height:60dvh;object-fit:contain;margin:auto}.worksheetSourceText{white-space:pre-wrap;line-height:1.8;margin-top:16px;font-size:14px;overflow-wrap:anywhere}
