/* Shared shell: left navigation, main conversation and business tabs. */
:root{--conversation-width:280px;--ui-body:15px;--ui-control:14px;--ui-label:13px}
body{font-size:var(--ui-body)}
body .main,body.helper-open .main{margin-left:var(--conversation-width);margin-right:0}
body #alerts{margin-left:var(--conversation-width)}
.topbar .mark{margin-right:auto}
#chat-sidebar{position:fixed;top:var(--topbar-h);bottom:0;left:0;width:var(--conversation-width);display:flex;flex-direction:column;background:#fff;border-right:1px solid var(--line);z-index:35}
.sidebar-account{padding:12px;border-top:1px solid var(--line);flex:none}
.account-settings{display:flex;align-items:center;gap:10px;width:100%;min-height:42px}
.account-settings span:last-child{margin-left:auto}
.sidebar-account .who{display:block;white-space:normal;overflow-wrap:anywhere;font-size:12px;margin-top:8px}
.folder-toggle{display:none}
body .helper{position:relative;inset:auto;width:100%;max-width:none;height:calc(100dvh - var(--topbar-h) - 56px);min-height:320px;transform:none;box-shadow:none;border:0;background:var(--bg);display:flex;z-index:auto;transition:none}
body .helper-scroll{padding:24px max(20px,calc((100% - 860px)/2));min-height:0;scroll-behavior:auto}
body .helper .composer{padding:12px max(20px,calc((100% - 860px)/2)) 20px;background:var(--bg);border-top:0}
body .helper .qchips,body .helper #program,body .helper #rail-ctx-sec{display:none!important}
body .helper .bub,body .helper .rc,body .helper .ph,body .main table,body .main .fin{font-size:var(--ui-body);line-height:1.6}
body .main thead th,body .main .btn,body .helper .btn,body .helper .q{font-size:var(--ui-control)}
body .main .small,body .helper .small,body .main .kv,body .main label{font-size:var(--ui-label)}
body .surface-body{padding:16px 24px 48px;overflow-x:auto}
body.chat-active .surface-body{display:none}
body .main .panel{min-width:0}
.work-bar{position:sticky;top:var(--topbar-h);z-index:20;display:flex;align-items:center;background:var(--bg);border-bottom:1px solid var(--line);padding:8px 12px 0;gap:6px;min-height:48px;box-sizing:border-box}
#work-tabs{display:flex;overflow-x:auto;flex:1;min-width:0}
.work-tab{display:flex;flex:none;border:1px solid var(--line);border-bottom:0;border-radius:7px 7px 0 0;background:#fff;max-width:280px;overflow:hidden}
.work-tab.active{box-shadow:inset 0 3px var(--navy)}
.work-tab button{font:inherit;font-size:14px;border:0;background:transparent;color:var(--ink);padding:10px 12px;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.work-tab button[aria-selected=true]{font-weight:700}
.work-tab .work-close{padding:8px;flex:none;color:#a4adbb;transition:color .15s ease}
.work-tab:hover .work-close,.work-tab .work-close:focus-visible{color:var(--ink)}
.work-bar>.hbtn{margin-bottom:6px}
.work-bar button:focus-visible{outline:2px solid var(--navy);outline-offset:-3px}
#work-context{font-size:13px;color:var(--muted);padding:0 0 8px;overflow-wrap:anywhere}
@media(prefers-reduced-motion:reduce){.work-tab .work-close{transition:none}}
@media(max-width:760px){
 body .main,body.helper-open .main{margin-left:0;margin-right:0}
 body #alerts{margin-left:0}
 #chat-sidebar{display:none;width:min(300px,88vw);box-shadow:8px 0 24px #0002}
 body.folders-open #chat-sidebar{display:flex}
 .folder-toggle{display:inline-flex}
 body .helper-scroll{padding:16px}
 body .helper .composer{padding:12px}
 body .surface-body{padding:14px 12px 36px}
}

/* User-owned folders replace the fixed business menu. */
body .sidenav,body .sidenav.show,body .helper #rail-agents,body .helper .welcome{display:none!important}
#chat-folders{flex:1;min-height:0;overflow:auto;border-bottom:1px solid var(--line);padding:12px 16px}
.chat-folder-heading,.chat-folder-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.chat-folder-heading{margin:4px 0}
.chat-folder-row small{font-size:12px;color:var(--muted)}
.chat-button{font:inherit;font-size:14px;text-align:left;background:transparent;color:var(--ink);border:1px solid var(--line);border-radius:6px;padding:6px 9px;cursor:pointer;overflow-wrap:anywhere}
.chat-button[aria-pressed=true]{background:var(--navybg);font-weight:700;border-color:var(--navy)}
.chat-button:focus-visible{outline:2px solid var(--navy)}
#chat-conversation-list{display:flex;flex-direction:column;gap:4px}
#chat-folder-tools,#chat-members{font-size:13px;margin-top:5px}
#chat-members>div{display:flex;justify-content:space-between;gap:8px;margin:6px 0}
#chat-scope{font-size:13px;font-weight:700;overflow-wrap:anywhere}
#chat-save-status{font-size:12px;color:var(--muted);overflow-wrap:anywhere}
.chat-intro{font-size:15px;line-height:1.7}
.helper .bub{white-space:pre-wrap;overflow-wrap:anywhere}

/* Conversation polish: transcript and composer share one reading flow. */
body .helper{height:auto;min-height:0;display:block}
body .helper-scroll{overflow:visible;padding-bottom:32px}
body .helper .composer{padding:20px 0 0;background:transparent}
body .helper .cin{align-items:flex-end;border-radius:18px;padding:12px;background:#fff}
#cmdin{font:inherit;font-size:15px;line-height:1.6;flex:1;min-width:0;min-height:72px;max-height:280px;resize:vertical;border:0;outline:none;background:transparent;color:var(--ink)}
#cmdin:focus-visible{outline:none}
body .helper .cin:focus-within{border-color:#8796ac;box-shadow:0 0 0 1px rgba(135,150,172,.18)}
@media(forced-colors:active){#cmdin:focus-visible{outline:1px solid Highlight}}
.helper .turn{display:flex;flex-direction:column;align-items:flex-start;margin:16px 0}
.helper .turn:has(>.me),.helper .turn.user-turn{align-items:flex-end}
body .helper .bub{width:fit-content;max-width:90%;border-radius:16px;white-space:pre-wrap;overflow-wrap:anywhere}
body .helper .bub.me{background:#e7edf6;text-align:left;margin-left:auto}
body .helper .bub.ag{background:#fff}
.helper .agrow{max-width:100%;width:100%}
#chat-folder-list .chat-button,#chat-conversation-list .chat-button,#chat-pinned-list .chat-button,#chat-completed-list .chat-button{border:0;background:transparent;box-shadow:none;font-weight:400}
#chat-folder-list .chat-button:hover,.chat-history-row:hover{background:var(--bg)}
#chat-folder-list .chat-button[aria-pressed=true],.chat-history-row:has([aria-pressed=true]){background:var(--navybg);border-radius:6px}
.chat-group-label{font-size:12px;color:var(--muted);margin:14px 0 5px}
.chat-history-row{display:flex;align-items:center;gap:4px;position:relative}
.chat-history-row>button{flex:1;min-width:0}
.chat-history-row summary{cursor:pointer;padding:5px 8px;list-style:none}
.chat-history-actions{position:absolute;right:0;top:100%;z-index:5;background:#fff;border:1px solid var(--line);border-radius:8px;padding:6px;box-shadow:0 6px 20px #0002}
.chat-history-actions button{display:block;width:100%;white-space:nowrap}
#chat-completed{margin-top:16px;font-size:14px}
#chat-completed>summary{cursor:pointer;padding:6px;color:var(--muted)}
#account-menu{position:relative}
#account-menu>summary{font-size:23px;cursor:pointer;list-style:none;padding:4px 8px;color:var(--navy)}
.account-popover{position:absolute;right:0;top:100%;min-width:240px;padding:16px;background:#fff;border:1px solid var(--line);border-radius:10px;box-shadow:0 6px 24px #0002}
.account-popover .who{display:block;white-space:normal;line-height:1.7;margin-bottom:10px}

/* Compact send affordance and menus above the work-tab stacking context. */
body .topbar{z-index:40;overflow:visible}
#account-menu{z-index:42}
.account-popover{z-index:43;max-width:calc(100vw - 32px)}
body .cin .snd{width:28px;height:28px;min-width:28px;padding:0;border:0;border-radius:50%;box-shadow:none;cursor:pointer;flex:none}
body .cin .snd:hover{background:var(--navy2)}
body .cin .snd:focus-visible{outline:2px solid var(--navy);outline-offset:3px}
#work-conversation{padding:0 24px 24px}
#work-conversation[hidden]{display:none}
#work-conversation .helper{border-top:1px solid var(--line)}
#work-conversation .helper-scroll{padding-top:18px}
/* Keep the transcript and reply in the same page flow; no nested transcript scroller. */
#work-conversation .thread{max-height:none;overflow:visible}
#work-conversation .composer{padding-top:8px}
#work-context:empty{display:none}
#work-conversation .cbar{border:0;box-shadow:none;background:transparent;padding:0;margin:0 0 6px;max-width:none}
#work-conversation .cbar>b,#work-conversation .cbar>.small{display:none}
#work-conversation .cbar .stop{font-size:12px;font-weight:400}
.cbar button.stop{font:inherit;background:transparent;border:0;padding:4px 0}
.cbar button.stop:focus-visible{outline:2px solid var(--navy);outline-offset:2px}
@media(max-width:760px){#work-conversation{padding:0 12px 16px}}

/* Folder actions belong to their own row; shared scope remains explicit. */
.folder-heading-icon,.folder-private{display:inline-flex;align-items:center;flex:none}
.chat-folder-row{flex-wrap:nowrap;gap:6px}
.chat-folder-row>.chat-button:first-child{min-width:0;overflow-wrap:anywhere}
#chat-folder-list .folder-edit{display:inline-flex;align-items:center;justify-content:center;flex:none;padding:6px;color:var(--muted)}
#chat-folder-list .folder-edit:hover,#chat-folder-list .folder-edit:focus-visible{color:var(--ink);background:var(--bg)}
#work-conversation .chat-onboarding{display:none}

/* Familiar navigation: shortcuts, folder rows, then indented conversations. */
.sidebar-shortcuts{display:flex;flex-direction:column;gap:4px;margin-bottom:20px}
.sidebar-shortcuts .chat-button{border:0;padding:9px 8px}
.sidebar-shortcuts .chat-button:hover{background:var(--navybg)}
.chat-folder-heading{font-size:12px;color:var(--muted);gap:2px;margin-bottom:8px}
.chat-folder-heading>span{flex:1}
.chat-folder-heading .chat-button{border:0;padding:4px 7px}
.chat-folder-row{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:4px;position:relative;margin:3px 0;align-items:center}
.chat-folder-row>small{font-size:11px}
.chat-folder-row>details>summary{cursor:pointer;list-style:none;padding:5px}
.chat-folder-row>details{position:relative}
.chat-folder-row .chat-history-actions{z-index:6}
#chat-folder-history{grid-column:1/-1;min-width:0;margin:2px 0 10px 13px;padding-left:9px;border-left:1px solid var(--line)}
#chat-folder-history[hidden],#chat-pinned-label[hidden],#chat-completed[hidden]{display:none}
#chat-folder-history .chat-group-label{margin:8px 0 3px}
#chat-completed{margin-top:6px}
body .folder-toggle{display:inline-flex;border:0;background:transparent;font-size:18px}
#sidebar-resize{position:absolute;right:-3px;top:0;bottom:0;width:6px;cursor:col-resize;touch-action:none}
#sidebar-resize:hover,#sidebar-resize:focus-visible{background:var(--line);outline:0}
@media(min-width:761px){body.sidebar-collapsed #chat-sidebar{display:none}body.sidebar-collapsed .main,body.sidebar-collapsed #alerts{margin-left:0}}
@media(max-width:760px){#sidebar-resize{display:none}}
.work-tab .work-pin{padding:6px;font-size:12px;color:var(--muted)}
.work-tab .work-pin[aria-pressed=true]{color:var(--navy)}

.chat-folder-row>button{display:flex;align-items:center;gap:5px;text-align:left}
.folder-row-icon{display:inline-flex;flex:none}
.work-tab .work-pin{display:inline-flex;align-items:center}

/* Familiar folder grouping; ERP work stays in the central workspace. */
.chat-folder-row[data-group]{position:relative;margin-top:34px}
.chat-folder-row[data-group]::before{content:attr(data-group);position:absolute;top:-25px;left:4px;color:var(--muted);font-size:12px;font-weight:600}
.conversation-heading{display:flex;flex-wrap:wrap;align-items:baseline;gap:8px 16px;margin-bottom:16px}
.conversation-heading #chat-scope{font-size:12px;font-weight:400;color:var(--muted)}
#order-progress .rc{margin:12px 0}
#work-context{font-size:12px}

.work-add,.work-rename{border:0;background:transparent;color:var(--muted);padding:6px;cursor:pointer;font:inherit}
.work-add:hover,.work-rename:hover,.chat-rename:hover{color:var(--ink);background:var(--bg)}
.work-add:focus-visible,.work-rename:focus-visible,.chat-rename:focus-visible{outline:2px solid var(--navy);outline-offset:2px}
.chat-history-row .chat-rename{flex:none;padding:4px 6px;color:var(--muted)}
