/* Shared Studio chat: neutral surfaces, local brand light, stable composer. */
#workspaceAiChat .cg-chat-preset-group{padding:5px 9px 3px;color:var(--cg-text-secondary);font-size:11px}
#workspaceAiChat .cg-chat-preset-menu{max-height:min(420px,65vh);overflow-y:auto;overflow-x:hidden}
#workspaceAiChat .cg-chat-preset-modified{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:4px;margin-top:6px;font-size:11px;color:var(--cg-text-secondary)}
#workspaceAiChat .cg-chat-preset-modified button{border:0;background:transparent;color:var(--cg-brand);font-size:11px;padding:2px 0}
#workspaceAiChat .cg-preset-dialog{box-sizing:border-box;width:min(540px,calc(100vw - 24px));max-height:calc(100dvh - 32px);margin:auto;padding:0;border:1px solid var(--cg-line);border-radius:var(--cg-radius-lg);background:var(--cg-panel);color:var(--cg-text);font:13px/1.6 var(--cg-font);overflow:auto;color-scheme:dark}
#workspaceAiChat .cg-preset-dialog::backdrop{background:color-mix(in srgb,var(--cg-bg) 65%,transparent)}
#workspaceAiChat .cg-preset-dialog *{box-sizing:border-box}
#workspaceAiChat .cg-preset-dialog button{display:inline-flex;align-items:center;justify-content:center;padding:6px 10px;border:1px solid var(--cg-line);border-radius:var(--cg-radius-md);background:var(--cg-surface-2);font:inherit;color:inherit;cursor:pointer}
#workspaceAiChat .cg-preset-dialog-head,#workspaceAiChat .cg-preset-dialog-actions{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}
#workspaceAiChat .cg-preset-dialog-head{border-bottom:1px solid var(--cg-line);position:sticky;top:0;background:var(--cg-panel);z-index:1}
#workspaceAiChat .cg-preset-dialog-head h3{margin:0;font-size:14px;font-weight:500}
#workspaceAiChat .cg-preset-dialog-head button{border:0;background:transparent;font-size:12px;color:var(--cg-text-secondary)}
#workspaceAiChat .cg-preset-dialog-body{padding:4px 16px 12px}
#workspaceAiChat .cg-preset-dialog-body h4{font-size:12px;font-weight:500;color:var(--cg-text-secondary);margin:16px 0 4px}
#workspaceAiChat .cg-preset-subtitle{font-size:11px;color:var(--cg-text-secondary);margin:8px 0}
#workspaceAiChat .cg-preset-list-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 0;border-bottom:1px solid var(--cg-line)}
#workspaceAiChat .cg-preset-list-row>div:first-child{min-width:0;overflow-wrap:anywhere}
#workspaceAiChat .cg-preset-list-row small{display:block}
#workspaceAiChat .cg-preset-row-actions{display:flex;gap:6px;flex-shrink:0}
#workspaceAiChat .cg-preset-row-actions button{font-size:11px;padding:4px 8px}
#workspaceAiChat .cg-preset-dialog-actions{justify-content:flex-end;flex-wrap:wrap;border-top:1px solid var(--cg-line);position:sticky;bottom:0;background:var(--cg-panel)}
#workspaceAiChat .cg-preset-dialog .cg-preset-primary{background:var(--cg-brand);color:var(--cg-brand-ink);border-color:var(--cg-brand)}
#workspaceAiChat .cg-preset-dialog .cg-preset-danger{color:var(--cg-danger)}
#workspaceAiChat .cg-preset-dialog .cg-preset-delete{color:var(--cg-text-secondary)}
#workspaceAiChat .cg-preset-dialog .cg-preset-delete:hover{color:var(--cg-danger)}
#workspaceAiChat .cg-preset-field{display:grid;gap:5px;margin-top:12px;font-size:12px}
#workspaceAiChat .cg-preset-field input,#workspaceAiChat .cg-preset-field textarea{font:inherit;color:var(--cg-text);width:100%;min-width:0;padding:8px 10px;border:1px solid var(--cg-line);border-radius:var(--cg-radius-md);background:var(--cg-surface-2);resize:vertical}
#workspaceAiChat .cg-preset-output{border-top:1px solid var(--cg-line);margin-top:16px;padding-top:12px;font-size:12px}
#workspaceAiChat .cg-preset-output summary{cursor:pointer;color:var(--cg-text-secondary)}
#workspaceAiChat .cg-preset-check{display:flex;align-items:center;gap:8px;margin:12px 0}
#workspaceAiChat .cg-preset-check input{accent-color:var(--cg-brand)}
#workspaceAiChat .cg-preset-dialog-status{padding:0 16px;font-size:12px;color:var(--cg-warn);overflow-wrap:anywhere}
#workspaceAiChat .cg-preset-discard{margin-right:auto}
.has-ai-chat { padding:0!important;overflow:hidden!important; }
#workspaceAiChat {display:flex;flex-direction:column;min-height:0;height:100%;position:relative;background:var(--cg-panel);color:var(--cg-text);font:13px/1.6 var(--cg-font);}
#workspaceAiChat [hidden]{display:none!important}
#workspaceAiChat button,#workspaceAiChat select,#workspaceAiChat textarea{font:inherit;color:inherit}
#workspaceAiChat svg{width:16px;height:16px;flex-shrink:0}
#workspaceAiChat .cg-chat-button{display:inline-flex;align-items:center;gap:6px;padding:6px 9px;border:1px solid var(--cg-line);border-radius:var(--cg-radius-md);background:var(--cg-surface-2);cursor:pointer;max-width:100%;text-align:left}
#workspaceAiChat button:hover{background:var(--cg-surface-2);border-color:var(--cg-brand-line)}
#workspaceAiChat button:focus-visible,#workspaceAiChat textarea:focus-visible,#workspaceAiChat select:focus-visible{outline:2px solid var(--cg-accent-blue);outline-offset:2px}
#workspaceAiChat button:disabled{opacity:.45;cursor:default}
#workspaceAiChat .cg-chat-head{display:flex;align-items:center;gap:8px;position:absolute;top:0;left:0;right:0;z-index:1;padding:20px 16px 0;border:0;pointer-events:none}
#workspaceAiChat .cg-chat-head>svg{color:var(--cg-brand)}
#workspaceAiChat .cg-chat-head>button{margin-left:auto;font-size:11px;background:transparent}
#workspaceAiChat .cg-chat-settings{width:28px;height:28px;padding:0;justify-content:center;border:0;background:transparent;color:var(--cg-text-secondary)}
#workspaceAiChat .cg-chat-settings span:not(.cg-chat-help-tip){display:none}
#workspaceAiChat .cg-chat-settings:hover{color:var(--cg-text);background:var(--cg-surface-2)}
#workspaceAiChat .cg-chat-scroll{flex:1;min-height:0;overflow:auto;scrollbar-width:thin;overflow-anchor:none}
#workspaceAiChat .cg-chat-welcome{padding:28px 16px 20px;text-align:center;background:radial-gradient(ellipse 240px 175px at 50% 95px,var(--cg-ai-welcome-glow),transparent)}
#workspaceAiChat .cg-chat-orb{width:44px;height:44px;display:grid;place-items:center;margin:0 auto 16px;border-radius:var(--cg-radius-lg);color:var(--cg-brand-ink);background:linear-gradient(145deg,var(--cg-brand-hover),var(--cg-brand));box-shadow:0 0 44px var(--cg-brand-glow)}
#workspaceAiChat .cg-chat-orb svg{width:24px;height:24px}
#workspaceAiChat h2{font-size:20px;line-height:1.4;font-weight:500;margin:0 0 10px;color:var(--cg-brand)}
#workspaceAiChat .cg-chat-welcome>p{font-size:12px;color:var(--cg-text-secondary);margin:0 0 24px}
#workspaceAiChat .cg-chat-preset-heading{font-size:12px;text-align:left;color:var(--cg-text-secondary);margin-bottom:10px}
#workspaceAiChat .cg-chat-welcome>button{display:flex;width:100%;margin:6px 0;padding:8px 12px;font-size:12px;background:var(--cg-surface-2)}
#workspaceAiChat .cg-chat-welcome>button svg{color:var(--cg-text-secondary)}
#workspaceAiChat .cg-chat-history{padding:48px 16px 12px;display:grid;gap:12px}
#workspaceAiChat .cg-chat-message{display:grid;gap:6px}
#workspaceAiChat .cg-chat-user{padding:9px 10px;background:var(--cg-surface-2);border:1px solid var(--cg-line);border-radius:var(--cg-radius-md);margin-left:auto;max-width:min(88%,420px);overflow-wrap:anywhere}
#workspaceAiChat .cg-chat-message{justify-items:stretch}
#workspaceAiChat .cg-chat-message .cg-chat-answer{justify-self:start;width:100%;max-width:78ch;min-width:0;box-sizing:border-box;}
#workspaceAiChat .cg-chat-source{background:transparent;border:0;padding:0;font-size:11px;color:var(--cg-text-secondary);display:inline-flex;align-items:center;gap:5px;margin:0 0 4px;flex-wrap:wrap}
#workspaceAiChat .cg-chat-user p,#workspaceAiChat .cg-chat-answer p{white-space:pre-wrap;margin:5px 0;overflow-wrap:anywhere}
#workspaceAiChat .cg-chat-image-button{display:inline-flex;align-items:center;padding:0;border:0;background:transparent;cursor:pointer;vertical-align:middle}
#workspaceAiChat .cg-chat-image-button img{display:block;width:56px;height:34px;border-radius:var(--cg-radius-sm);object-fit:cover;opacity:.92}
#workspaceAiChat .cg-chat-image-button:hover img{opacity:1;outline:1px solid var(--cg-accent-blue)}
#workspaceAiChat .cg-chat-answer{padding:12px;border:1px solid var(--cg-line);border-radius:var(--cg-radius-md);background:var(--cg-surface)}
#workspaceAiChat .cg-chat-answer-title{display:flex;align-items:center;gap:6px;font-size:12px}
#workspaceAiChat .cg-chat-answer-title>svg{color:var(--cg-brand)}
#workspaceAiChat .cg-chat-answer-title>span{min-width:0;overflow-wrap:anywhere}
#workspaceAiChat .cg-chat-actions{display:flex;align-items:center;gap:2px;flex:0 0 auto;margin-left:auto}
#workspaceAiChat .cg-chat-actions .cg-chat-answer-action{position:relative;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;min-width:28px;padding:0;border:0;border-radius:var(--cg-radius-sm);background:transparent;color:var(--cg-text-secondary);cursor:pointer}
#workspaceAiChat .cg-chat-actions .cg-chat-answer-action:hover{background:var(--cg-surface-2);color:var(--cg-text)}
#workspaceAiChat .cg-chat-answer-action-tip{position:absolute;right:0;top:calc(100% + 4px);padding:5px 8px;border:1px solid var(--cg-line);border-radius:var(--cg-radius-sm);background:var(--cg-panel);color:var(--cg-text);font-size:11px;line-height:1.5;white-space:nowrap;visibility:hidden;pointer-events:none;z-index:12;transition:none}
#workspaceAiChat .cg-chat-answer-action:hover .cg-chat-answer-action-tip,
#workspaceAiChat .cg-chat-answer-action:focus-visible .cg-chat-answer-action-tip{visibility:visible}
#workspaceAiChat .cg-chat-save-actions{display:flex;gap:6px;margin-top:8px}
#workspaceAiChat .cg-chat-composer-wrap{flex-shrink:0;padding:12px 16px 10px;background:var(--cg-panel);position:relative;isolation:isolate}
@keyframes cg-chat-breathe{0%,100%{opacity:.45;transform:translate(-38px,4px) scale(.9)}50%{opacity:.9;transform:translate(12px,-12px) scale(1.1)}}
#workspaceAiChat .cg-chat-tools{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:10px}
#workspaceAiChat .cg-chat-tools button{font-size:11px;background:var(--cg-panel);padding:6px 8px}
#workspaceAiChat .cg-chat-composer>.cg-chat-preset-select{display:block;width:max-content;max-width:100%;margin:0 0 6px;padding:2px 20px 2px 0;font-size:11px;background:transparent;border:0;border-radius:0;color:var(--cg-text-secondary);font-weight:500;cursor:pointer}
#workspaceAiChat .cg-chat-composer{padding:12px;border:1px solid transparent;border-radius:var(--cg-radius-lg);background:linear-gradient(var(--cg-surface),var(--cg-surface)) padding-box,radial-gradient(ellipse 290px 160px at 100% 100%,var(--cg-brand-line),var(--cg-line) 100%) border-box;box-shadow:10px 14px 40px -20px var(--cg-brand-glow)}
#workspaceAiChat .cg-chat-composer-wrap:before{content:"";position:absolute;right:4px;bottom:34px;width:min(360px,85%);height:180px;background:radial-gradient(ellipse at 65% 65%,var(--cg-ai-input-glow),var(--cg-brand-dim) 38%,transparent 72%);filter:blur(24px);pointer-events:none;z-index:-1;animation:cg-chat-breathe 5s ease-in-out infinite}
#workspaceAiChat .cg-chat-attachment{display:flex;align-items:center;gap:8px;padding:8px 34px 8px 10px;margin:0 0 10px;border:1px solid var(--cg-line);border-radius:var(--cg-radius-md);background:var(--cg-surface-2);font-size:12px;position:relative;min-height:40px}
#workspaceAiChat .cg-chat-attachment img{width:60px;height:40px;object-fit:contain;border-radius:var(--cg-radius-sm);flex:0 0 auto}
#workspaceAiChat .cg-chat-attachment>div{flex:1;min-width:0;overflow-wrap:anywhere}
#workspaceAiChat .cg-chat-attachment-remove{position:absolute;top:5px;right:5px;width:22px;height:22px;padding:0;justify-content:center;border:0;background:transparent;color:var(--cg-text-secondary);border-radius:var(--cg-radius-sm)}
#workspaceAiChat .cg-chat-attachment-remove:hover{color:var(--cg-text);background:var(--cg-surface)}
#workspaceAiChat small{font-size:11px;color:var(--cg-text-secondary)}
#workspaceAiChat .cg-chat-icon-button{padding:4px;background:transparent;border:0}
#workspaceAiChat .cg-chat-icon-button span{display:none}
#aiChatInput{width:100%;display:block;resize:none;min-height:60px;max-height:150px;padding:0;background:transparent;border:0;outline-offset:2px;box-shadow:none;font-size:13px}
#workspaceAiChat .cg-chat-send-row{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:8px}
#workspaceAiChat .cg-chat-send{background:var(--cg-brand);color:var(--cg-brand-ink);border:0;width:34px;height:32px;justify-content:center;padding:0;flex-shrink:0}
#workspaceAiChat .cg-chat-send:hover{background:var(--cg-brand-hover)}
#workspaceAiChat .cg-chat-foot{display:block;text-align:center;margin-top:10px}
#workspaceAiChat .cg-chat-replace{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px;font-size:11px;color:var(--cg-accent-blue)}
#workspaceAiChat .cg-chat-replace button{font-size:11px;padding:4px 8px}
#workspaceAiChat .cg-chat-new-reply{position:absolute;bottom:280px;left:50%;transform:translateX(-50%);z-index:2;width:28px;height:28px;padding:0;border-radius:50%;justify-content:center}
#workspaceAiChat .cg-chat-new-reply svg{width:14px;height:14px;transform:rotate(180deg)}
#workspaceAiChat .cg-chat-new-reply span{display:none}
#workspaceAiChat .cg-chat-inspector{border-top:1px solid var(--cg-line);margin:0 16px 12px}
#workspaceAiChat .cg-chat-inspector summary{padding:10px 0;cursor:pointer;color:var(--cg-text-secondary);font-size:12px}
#workspaceAiChat #inspectorBody{height:auto;display:block;overflow:visible;padding:0;min-height:0}
#workspaceAiChat #inspectDetail{height:auto;min-height:0;overflow:visible;display:block}
#workspaceAiChat #inspectShotHead{margin-bottom:12px}
#workspaceAiChat #inspectDescShell{min-height:100px;height:auto}
#workspaceAiChat #inspectDesc{height:auto;min-height:120px}
#workspaceAiChat #btn-inspector-ai,#workspaceAiChat .inspector-ai-advanced{display:none!important}
.cg-chat-crop-overlay{position:absolute;inset:0;z-index:90;cursor:crosshair;touch-action:none;background:var(--cg-bg)}
.cg-chat-crop-overlay>img{width:100%;height:100%;object-fit:contain;pointer-events:none}
.cg-chat-crop-selection{position:absolute;border:2px solid var(--cg-accent-blue);background:var(--cg-accent-blue-dim);pointer-events:none}
.cg-chat-crop-hint{position:absolute;left:50%;top:12px;transform:translateX(-50%);display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:8px;max-width:calc(100% - 24px);padding:7px 10px 7px 14px;border:1px solid var(--cg-line);border-radius:var(--cg-radius-lg);background:color-mix(in srgb,var(--cg-panel) 88%,transparent);backdrop-filter:blur(12px);color:var(--cg-text);font:12px/1.5 var(--cg-font);white-space:nowrap;cursor:default;box-shadow:0 4px 16px #0003}
.cg-chat-crop-escape{display:flex;align-items:center;gap:5px;color:var(--cg-text-secondary)}
.cg-chat-crop-escape kbd{font:12px/1.5 var(--cg-font);padding:1px 5px;border:1px solid var(--cg-line);border-radius:4px}
.cg-chat-crop-hint>button{display:grid;place-items:center;width:24px;height:24px;padding:0;border:0;border-radius:var(--cg-radius-sm);background:transparent;color:var(--cg-text-secondary);cursor:pointer}
.cg-chat-crop-hint>button:hover{background:var(--cg-surface-2);color:var(--cg-text)}
.cg-chat-crop-overlay svg{width:16px;height:16px}
@media(prefers-reduced-motion:reduce){#workspaceAiChat .cg-chat-composer-wrap:before{animation:none;opacity:.65}}

/* Composer controls follow the image, instruction, request order. */
#workspaceAiChat .cg-chat-composer{position:relative;padding-top:10px}
#workspaceAiChat .cg-chat-settings{position:absolute;top:10px;right:12px;width:auto;height:26px;padding:3px 8px;gap:5px;border:1px solid var(--cg-line);border-radius:var(--cg-radius-md);background:var(--cg-surface-2);font-size:11px}
#workspaceAiChat .cg-chat-settings span{display:inline}
#workspaceAiChat .cg-chat-attachment{width:fit-content;max-width:calc(100% - 90px);box-sizing:border-box;min-width:min(180px,100%)}
#workspaceAiChat .cg-chat-attachment>div{flex:0 1 auto}
#workspaceAiChat .cg-chat-entry{min-height:90px}
#workspaceAiChat .cg-chat-entry #aiChatInput{width:100%;min-height:90px;max-height:240px;line-height:1.85;padding:0;overflow:auto}
#workspaceAiChat .cg-chat-picker{position:relative}
#workspaceAiChat .cg-chat-picker>button{font-size:11px;padding:4px 8px;gap:8px}
#workspaceAiChat .cg-chat-preset-menu{position:absolute;bottom:calc(100% + 8px);left:0;min-width:160px;max-width:240px;padding:5px;border:1px solid var(--cg-line);border-radius:var(--cg-radius-lg);background:var(--cg-panel);box-shadow:0 8px 28px #0005;z-index:10}
#workspaceAiChat .cg-chat-preset-menu button{display:flex;width:100%;border:0;border-radius:var(--cg-radius-md);background:transparent;font-size:12px}
#workspaceAiChat .cg-chat-preset-menu button[aria-selected="true"]{color:var(--cg-brand);background:var(--cg-brand-dim)}
#workspaceAiChat .cg-chat-preset-menu[popover]{position:fixed;inset:auto;margin:0;min-width:min(160px,calc(100vw - 16px));box-sizing:border-box;color:var(--cg-text)}
#workspaceAiChat .cg-chat-preset-section+.cg-chat-preset-section{border-top:1px solid var(--cg-line);margin-top:4px;padding-top:4px}
#workspaceAiChat .cg-chat-personal-presets{max-height:132px;overflow-y:auto;scrollbar-width:thin}
#workspaceAiChat .cg-chat-preset-footer{border-top:1px solid var(--cg-line);margin-top:4px;padding-top:4px}
#workspaceAiChat .cg-chat-preset-menu .cg-chat-preset-save{font-size:11px;color:var(--cg-text-secondary)}
#workspaceAiChat .cg-chat-send{display:grid;place-items:center;gap:0}
#workspaceAiChat .cg-chat-send span{display:none}
#workspaceAiChat .cg-chat-send svg{display:block;margin:0}



#workspaceAiChat #aiChatInput::placeholder{font-size:11px;font-weight:400;color:color-mix(in srgb,var(--cg-text-secondary) 72%,var(--cg-panel));opacity:1}

#workspaceAiChat .cg-chat-send-row{position:relative}
#workspaceAiChat .cg-chat-send-tooltip{position:absolute;right:0;bottom:calc(100% + 8px);max-width:100%;padding:6px 9px;border:1px solid var(--cg-line);border-radius:var(--cg-radius-md);background:var(--cg-panel);color:var(--cg-text-secondary);font-size:11px;line-height:1.5;box-shadow:0 4px 14px #0003;visibility:hidden;pointer-events:none;z-index:12;overflow-wrap:anywhere}
#workspaceAiChat .cg-chat-send-row:has(.cg-chat-send:hover) .cg-chat-send-tooltip,
#workspaceAiChat .cg-chat-send-row:has(.cg-chat-send:focus-visible) .cg-chat-send-tooltip{visibility:visible}

#workspaceAiChat.cg-chat-has-history .cg-chat-head{position:static;flex-shrink:0;padding:12px 16px;background:var(--cg-panel)}
#workspaceAiChat.cg-chat-has-history .cg-chat-history{padding-top:12px}
#workspaceAiChat .cg-chat-instruction summary{font-size:11px;color:var(--cg-text-secondary);cursor:pointer;padding:3px 0;overflow-wrap:anywhere}
#workspaceAiChat .cg-chat-instruction p{padding-top:5px}

#workspaceAiChat .cg-chat-tools .cg-chat-settings{position:static;margin-left:auto;width:auto;height:auto;padding:6px 8px;font-size:11px}
#workspaceAiChat .cg-chat-attachment{max-width:100%}

#workspaceAiChat .cg-chat-source-head{display:flex;align-items:center;gap:9px;min-width:0;margin-bottom:6px}
#workspaceAiChat .cg-chat-source-head .cg-chat-image-button{flex:0 0 auto}
#workspaceAiChat .cg-chat-source-head .cg-chat-source{display:flex;flex-direction:column;align-items:flex-start;gap:1px;min-width:0;margin:0;line-height:1.5;white-space:normal;text-align:left}
#workspaceAiChat .cg-chat-source-title{color:var(--cg-text);overflow-wrap:anywhere}
#workspaceAiChat .cg-chat-source-head small{display:block;font-size:10px;white-space:nowrap}


/* Zoom participates in layout; compensate the root height so all controls fit its host. */
#workspaceAiChat{height:100%;zoom:1}


.cg-chat-crop-hint>button{display:block;width:auto;height:auto;padding:5px 9px;white-space:nowrap}
.cg-chat-crop-hint>button.cg-chat-crop-confirm{background:var(--cg-brand);color:var(--cg-on-brand,#111)}
.cg-chat-crop-hint>button:disabled{opacity:.45;cursor:default}

.cg-chat-crop-hint>span{white-space:normal;text-align:center}

#workspaceAiChat .cg-chat-picker{display:flex;align-items:center;flex-wrap:wrap;gap:5px}
#workspaceAiChat #aiChatLoadPreset{color:var(--cg-text-secondary);font-size:11px}

/* Shared conversation/instruction scrollbar: 6px lane, 4px rounded visible handle. */
#workspaceAiChat {
  --cg-chat-scroll-thumb: color-mix(in srgb,var(--cg-text-secondary) 28%,transparent);
  --cg-chat-scroll-thumb-hover: color-mix(in srgb,var(--cg-text-secondary) 52%,transparent);
}
#workspaceAiChat :is(.cg-chat-scroll,#aiChatInput,.cg-chat-discussion-preview) { scrollbar-width:auto; scrollbar-color:auto; scrollbar-gutter:stable; }
#workspaceAiChat :is(.cg-chat-scroll,#aiChatInput,.cg-chat-discussion-preview)::-webkit-scrollbar { width:6px; height:6px; background:transparent; }
#workspaceAiChat :is(.cg-chat-scroll,#aiChatInput,.cg-chat-discussion-preview)::-webkit-scrollbar-track { background:transparent; }
#workspaceAiChat :is(.cg-chat-scroll,#aiChatInput,.cg-chat-discussion-preview)::-webkit-scrollbar-thumb {
  min-height:32px;
  border:1px solid transparent;
  border-radius:999px;
  background:var(--cg-chat-scroll-thumb);
  background-clip:padding-box;
}
#workspaceAiChat :is(.cg-chat-scroll,#aiChatInput,.cg-chat-discussion-preview)::-webkit-scrollbar-thumb:hover { background-color:var(--cg-chat-scroll-thumb-hover); }
#workspaceAiChat :is(.cg-chat-scroll,#aiChatInput,.cg-chat-discussion-preview)::-webkit-scrollbar-button { display:none; width:0; height:0; }
#workspaceAiChat :is(.cg-chat-scroll,#aiChatInput,.cg-chat-discussion-preview)::-webkit-scrollbar-corner { background:transparent; }
@supports not selector(::-webkit-scrollbar) {
  #workspaceAiChat :is(.cg-chat-scroll,#aiChatInput,.cg-chat-discussion-preview) { scrollbar-width:thin; scrollbar-color:var(--cg-chat-scroll-thumb) transparent; }
}

/* Fit the actual panel height without scaling text or hiding actions. */
#workspaceAiChat .cg-chat-scroll{position:relative;isolation:isolate;flex:1 1 0;min-height:0}
#workspaceAiChat .cg-chat-composer-wrap{flex:0 0 auto;border-top:0;z-index:2}
#workspaceAiChat .cg-chat-welcome{padding-top:var(--cg-chat-welcome-top,24px);padding-bottom:24px}
#workspaceAiChat .cg-chat-welcome>p{margin-bottom:var(--cg-chat-welcome-gap,32px)}
#workspaceAiChat .cg-chat-entry{min-height:0}
#workspaceAiChat .cg-chat-entry #aiChatInput,
#workspaceAiChat.cg-chat-compact .cg-chat-entry #aiChatInput:placeholder-shown{min-height:var(--cg-chat-input-min,72px);max-height:var(--cg-chat-input-max,120px)}
#workspaceAiChat.cg-chat-compact .cg-chat-orb{width:32px;height:32px;margin-bottom:8px}
#workspaceAiChat.cg-chat-compact .cg-chat-welcome{padding-bottom:12px}
#workspaceAiChat.cg-chat-compact h2{font-size:18px;margin-bottom:6px}
#workspaceAiChat.cg-chat-compact .cg-chat-welcome>p{margin-top:0}
#workspaceAiChat.cg-chat-compact .cg-chat-composer-wrap{padding:8px 12px}
#workspaceAiChat.cg-chat-compact .cg-chat-tools{margin-bottom:6px}
#workspaceAiChat.cg-chat-compact .cg-chat-tools button{padding:4px 6px}
#workspaceAiChat.cg-chat-compact .cg-chat-composer{padding:8px}
#workspaceAiChat.cg-chat-compact .cg-chat-attachment{min-height:0;padding:4px 28px 4px 6px;margin-bottom:6px;gap:6px}
#workspaceAiChat.cg-chat-compact .cg-chat-attachment img{width:40px;height:28px}
#workspaceAiChat.cg-chat-compact .cg-chat-attachment>div{line-height:1.35}
#workspaceAiChat.cg-chat-compact .cg-chat-foot{margin-top:6px}

/* The image header disappears when there is no new attachment. */
#workspaceAiChat .cg-chat-composer-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;min-width:0;margin-bottom:8px}
#workspaceAiChat .cg-chat-composer-head .cg-chat-attachment{flex:0 1 auto;min-width:0;max-width:100%;margin-bottom:0}
#workspaceAiChat .cg-chat-composer-head .cg-chat-attachment>div>div,
#workspaceAiChat .cg-chat-composer-head .cg-chat-attachment small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#workspaceAiChat .cg-chat-picker{flex:1 1 auto;min-width:0}
#workspaceAiChat .cg-chat-picker>button{max-width:100%;overflow-wrap:anywhere}
#workspaceAiChat.cg-chat-narrow .cg-chat-welcome{padding-left:12px;padding-right:12px}
#workspaceAiChat.cg-chat-narrow h2{font-size:18px;line-height:1.4}
#workspaceAiChat.cg-chat-narrow .cg-chat-orb{width:32px;height:32px;margin-bottom:10px}
#workspaceAiChat.cg-chat-narrow .cg-chat-welcome>button{padding:6px 8px}
#workspaceAiChat.cg-chat-narrow .cg-chat-composer-wrap{padding-left:10px;padding-right:10px}
#workspaceAiChat.cg-chat-narrow .cg-chat-tools{gap:4px}
#workspaceAiChat.cg-chat-narrow .cg-chat-tools button{padding:4px 6px;min-height:28px}
#workspaceAiChat.cg-chat-narrow .cg-chat-composer{padding:8px}
#workspaceAiChat.cg-chat-narrow .cg-chat-attachment{padding:4px 26px 4px 6px;gap:6px;min-height:0}
#workspaceAiChat.cg-chat-narrow .cg-chat-attachment img{width:40px;height:28px}
#workspaceAiChat.cg-chat-narrow .cg-chat-attachment>div{line-height:1.4}
#workspaceAiChat.cg-chat-narrow .cg-chat-entry #aiChatInput{line-height:1.65}
#workspaceAiChat.cg-chat-narrow .cg-chat-history{padding-left:12px;padding-right:12px}
#workspaceAiChat.cg-chat-extra-narrow h2{font-size:16px}
#workspaceAiChat.cg-chat-extra-narrow .cg-chat-tools{column-gap:4px;row-gap:5px}



/* The prior image stays available without occupying a permanent thumbnail card. */
#workspaceAiChat .cg-chat-discussion-preview{margin:0 0 8px;min-width:0;color:var(--cg-text-secondary);font-size:12px;overflow:auto}
#workspaceAiChat .cg-chat-discussion-preview summary{cursor:pointer;overflow-wrap:anywhere}
#workspaceAiChat .cg-chat-discussion-preview summary:focus-visible{outline:2px solid var(--cg-accent-blue);outline-offset:2px}
#workspaceAiChat .cg-chat-discussion-preview img{display:block;max-width:100%;max-height:var(--cg-chat-preview-height,120px);object-fit:contain;margin-top:8px;border-radius:var(--cg-radius-sm)}


#workspaceAiChat .cg-chat-picker>button svg{display:block;width:12px;height:12px;flex:0 0 12px;align-self:center}
/* The separator adjusts the entire composer; the input gets the remaining space. */
#workspaceAiChat .cg-chat-composer-head:has(.cg-chat-attachment[hidden]){display:none}
#workspaceAiChat .cg-chat-composer-wrap{box-sizing:border-box;display:flex;flex-direction:column;min-height:0}
#workspaceAiChat .cg-chat-composer{display:flex;flex-direction:column;min-height:0;box-sizing:border-box}
#workspaceAiChat .cg-chat-tools,#workspaceAiChat .cg-chat-replace,#workspaceAiChat .cg-chat-discussion-preview,#workspaceAiChat .cg-chat-composer-head,#workspaceAiChat .cg-chat-send-row{flex-shrink:0}
#workspaceAiChat .cg-chat-entry{min-width:0}
#workspaceAiChat .cg-chat-entry #aiChatInput{box-sizing:border-box}
#workspaceAiChat .cg-chat-splitter{position:relative;flex:0 0 12px;cursor:row-resize;touch-action:none;user-select:none;z-index:3;outline-offset:-2px;background:var(--cg-panel)}
#workspaceAiChat .cg-chat-splitter:before{content:"";position:absolute;inset:5px 0 auto;height:1px;background:var(--cg-line)}
#workspaceAiChat .cg-chat-splitter:after{content:"";position:absolute;left:calc(50% - 18px);top:4px;width:36px;height:3px;border-radius:var(--cg-radius-sm);background:var(--cg-text-secondary);opacity:.55}
#workspaceAiChat .cg-chat-splitter:hover:after,#workspaceAiChat .cg-chat-splitter:focus-visible:after,#workspaceAiChat.cg-chat-dragging .cg-chat-splitter:after{opacity:1}
#workspaceAiChat .cg-chat-splitter:focus-visible{outline:2px solid var(--cg-accent-blue)}
#workspaceAiChat.cg-chat-dragging{cursor:row-resize;user-select:none}
#workspaceAiChat.cg-chat-manual-split .cg-chat-composer{flex:1 1 0;overflow:visible}
#workspaceAiChat.cg-chat-manual-split .cg-chat-entry{flex:1 1 0;min-height:0}
#workspaceAiChat.cg-chat-manual-split .cg-chat-entry #aiChatInput,
#workspaceAiChat.cg-chat-manual-split.cg-chat-compact .cg-chat-entry #aiChatInput:placeholder-shown{height:100%;min-height:0;max-height:none}


#workspaceAiChat.cg-chat-narrow .cg-chat-answer{padding:10px}

/* Keep export beside capture tools; per-turn icons share the answer heading. */
#workspaceAiChat .cg-chat-tools .cg-chat-export{margin-left:auto}
#workspaceAiChat .cg-chat-picker>.cg-chat-settings{position:static;flex:0 0 28px;width:28px;height:28px;min-width:28px;padding:0;gap:0;border:0;background:transparent;justify-content:center}
#workspaceAiChat .cg-chat-picker>.cg-chat-settings>span:not(.cg-chat-help-tip){display:none}
#workspaceAiChat .cg-chat-picker>.cg-chat-settings>svg{width:16px;height:16px;flex:0 0 16px}
#workspaceAiChat .cg-chat-actions .cg-chat-delete-turn{margin-left:4px}
#workspaceAiChat .cg-chat-actions .cg-chat-delete-turn:hover:not(:disabled){color:var(--cg-danger)}
#workspaceAiChat.cg-chat-short .cg-chat-attachment{padding:2px 26px 2px 6px;margin-bottom:2px;font-size:11px}
#workspaceAiChat.cg-chat-short .cg-chat-attachment img{width:36px;height:24px}
#workspaceAiChat.cg-chat-short .cg-chat-attachment>div,#workspaceAiChat.cg-chat-short .cg-chat-attachment small{font-size:11px;line-height:1.2}
#workspaceAiChat.cg-chat-short .cg-chat-composer-wrap{padding:4px 12px}
#workspaceAiChat.cg-chat-short .cg-chat-composer{padding:4px}
#workspaceAiChat.cg-chat-short .cg-chat-tools{margin-bottom:4px}
#workspaceAiChat.cg-chat-short .cg-chat-tools button{padding:2px 6px;line-height:1.3;min-height:24px}
#workspaceAiChat #aiChatOlder{display:flex;margin:8px auto;font-size:11px}

#workspaceAiChat .cg-chat-discussion-divider { margin:16px 0; border-top:1px solid var(--cg-line); }

/* Immediate help stays inside the viewport; no browser title delay. */
#workspaceAiChat .cg-chat-help-tip{position:fixed;right:auto;bottom:auto;max-width:min(300px,calc(100vw - 16px));box-sizing:border-box;width:max-content;padding:6px 9px;border:1px solid var(--cg-line);border-radius:var(--cg-radius-sm);background:var(--cg-panel);color:var(--cg-text);font-size:11px;font-weight:400;line-height:1.5;white-space:normal;text-align:left;visibility:hidden;pointer-events:none;z-index:2147483647;transition:none;animation:none}
#workspaceAiChat .cg-chat-help-tip.is-visible{visibility:visible}

#workspaceAiChat .cg-chat-writeback-receipt{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:10px;padding-top:8px;border-top:1px solid var(--cg-line);font-size:11px;color:var(--cg-text-secondary)}
#workspaceAiChat .cg-chat-writeback-receipt button{border:0;background:transparent;padding:2px 4px;font-size:11px}
.cg-chat-samples{flex-basis:100%;min-width:0;font-size:11px;color:var(--cg-text-secondary)}
.cg-chat-sample-strip{display:flex;gap:6px;overflow-x:auto;max-height:100px}
.cg-chat-sample-strip figure{margin:4px 0;flex:0 0 74px}
.cg-chat-sample-strip figure img{width:74px;height:42px;object-fit:contain}
.cg-chat-sample-strip figcaption{font-size:10px}
.cg-chat-attachment:has(.cg-chat-samples){flex-wrap:wrap}
.cg-chat-apply-answer{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:10px}
.cg-chat-apply-answer select,#aiChatSampleCount{background:var(--cg-surface-2);color:var(--cg-text);border:1px solid var(--cg-line);border-radius:6px;font:inherit;font-size:11px;padding:5px;max-width:100%}
.cg-chat-desk .cg-chat-tools{flex-wrap:wrap}
.cg-chat-desk .cg-chat-tools{display:flex;gap:6px;align-items:center}
.cg-chat-desk .cg-chat-tools .cg-chat-button{padding:5px 7px;flex:0 1 auto;font-size:11px}
.cg-chat-desk #aiChatSampleCount{max-width:66px}


#workspaceAiChat .cg-chat-shot-picker{display:inline-flex;align-items:center;border:1px solid var(--cg-line);border-radius:6px;background:var(--cg-panel);flex-shrink:0}
#workspaceAiChat .cg-chat-shot-picker[hidden]{display:none}
#workspaceAiChat .cg-chat-shot-picker #aiChatShot{border:0;background:transparent;border-radius:5px 0 0 5px}
#workspaceAiChat .cg-chat-shot-picker #aiChatSampleCount{border:0;border-left:1px solid var(--cg-line);border-radius:0 5px 5px 0;background:transparent;margin:0;min-height:28px}


#workspaceAiChat .cg-chat-help-tip[popover]{margin:0;inset:auto;overflow:visible}


#workspaceAiChat .cg-chat-head > #sbDeskHistoryScope { pointer-events: auto; margin-left: auto; }
#workspaceAiChat .cg-chat-head > #sbDeskHistoryScope[hidden] { display: none; }


#workspaceAiChat .cg-chat-sampling-state { flex: 1 0 100%; color: var(--cg-text-secondary); font-size: 11px; }
#workspaceAiChat .cg-chat-sampling-state span { display: block; overflow-wrap: anywhere; }
#workspaceAiChat .cg-chat-sampling-state button { margin-top: 6px; }

#workspaceAiChat .cg-chat-attachment:has(.cg-chat-sampling-state) { flex-wrap: wrap; }

/* Input actions stay neutral; the attachment card identifies prepared content. */
#workspaceAiChat #aiChatFrame:hover,#workspaceAiChat #aiChatCrop:hover{border-color:var(--cg-line)}

/* Shared frame/shot credit quote: quiet footer, price next to the submit action. */
#workspaceAiChat .cg-chat-credit-price{font-size:12px;color:var(--cg-brand);white-space:nowrap;margin-left:auto}
#workspaceAiChat .cg-chat-credit-footer{display:flex;gap:8px;align-items:baseline;flex-wrap:wrap;margin-top:8px;font-size:11px;color:var(--cg-text-secondary)}
#workspaceAiChat .cg-chat-credit-footer details[open]{flex-basis:100%}
#workspaceAiChat .cg-chat-credit-footer p{margin:8px 0;line-height:1.7}
#workspaceAiChat .cg-chat-credit-balance{margin-left:auto}
#workspaceAiChat .cg-chat-billing-receipt{display:block;margin-top:8px;color:var(--cg-text-secondary)}
#workspaceAiChat .cg-chat-sample-change{padding:0 0 0 8px;margin:0;border:0;background:transparent;font-size:11px;text-decoration:underline;color:var(--cg-text-secondary)}
#workspaceAiChat .cg-chat-send-row{flex-wrap:wrap}
#workspaceAiChat .cg-chat-picker{flex:1 0 120px;min-width:0;max-width:100%}
#workspaceAiChat .cg-chat-picker>button{flex-shrink:0;white-space:nowrap;overflow-wrap:normal}
#workspaceAiChat .cg-chat-picker>button>span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* A top-layer shade stays inside the AI column, leaving a hole for the preset trigger. */
#workspaceAiChat .cg-chat-preset-shade{position:fixed;inset:auto;margin:0;padding:0;border:0;border-radius:0;background:color-mix(in srgb,var(--cg-bg) 44%,transparent);backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);z-index:20}
#workspaceAiChat .cg-chat-preset-shade[hidden]{display:none}
#workspaceAiChat .cg-chat-preset-shade::backdrop{background:transparent;pointer-events:none}
#workspaceAiChat .cg-chat-preset-group{margin:4px 4px 8px;padding:6px 8px;border-radius:var(--cg-radius-sm);background:var(--cg-surface-2);color:var(--cg-text-secondary);font-size:11px;font-weight:500;letter-spacing:.03em}
#workspaceAiChat .cg-chat-preset-section [role="option"]{padding-left:16px}
#workspaceAiChat .cg-chat-preset-section+.cg-chat-preset-section{margin-top:8px;padding-top:8px}
#workspaceAiChat .cg-chat-preset-empty{margin:0;padding:4px 8px 8px;color:var(--cg-text-secondary);font-size:12px}
#workspaceAiChat .cg-chat-preset-footer{margin-top:8px;padding-top:8px}
/* Studio timeline and desk share a dedicated monitor-style title row. */
:is(.inspector-ai-card,#sbDeskChatHost) #workspaceAiChat .cg-chat-head{
  position:relative;inset:auto;flex:0 0 34px;min-height:34px;height:34px;
  padding:6px 10px;gap:6px;border-bottom:1px solid var(--cg-line);
  background:var(--cg-surface-2);font-size:12px;line-height:20px;
  pointer-events:auto;box-sizing:border-box;
}
:is(.inspector-ai-card,#sbDeskChatHost) #workspaceAiChat .cg-chat-head>svg{width:14px;height:14px;color:var(--cg-text-secondary)}
:is(.inspector-ai-card,#sbDeskChatHost) #workspaceAiChat .cg-chat-history{padding-top:12px}
/* One right-hand tool surface in both Studio views. */
:is(.inspector-ai-card,#sbDeskChatHost) #workspaceAiChat .cg-chat-head{padding:0 10px}
#workspaceAiChat .cg-tool-tabs{display:flex;align-self:stretch;gap:18px;min-width:0}
#workspaceAiChat .cg-tool-tabs button{display:inline-flex;align-items:center;gap:6px;background:transparent;border:0;border-bottom:2px solid transparent;border-radius:0;padding:5px 0;font-size:12px;color:var(--cg-text-secondary);white-space:nowrap}
#workspaceAiChat .cg-tool-tabs button[aria-selected=true]{border-bottom-color:var(--cg-brand);color:var(--cg-text)}
#workspaceAiChat .cg-tool-tabs #studioToolAiTab svg{color:var(--cg-brand)}
#workspaceAiChat .cg-tool-tabs svg{width:14px;height:14px}
#workspaceAiChat.cg-monitor-active>:not(.cg-chat-head):not(.sb-monitor){display:none!important}
#workspaceAiChat.cg-monitor-active .cg-chat-head>#sbDeskHistoryScope{display:none!important}
#workspaceAiChat>.sb-monitor{width:100%;height:0;flex:1 1 0;min-height:0;align-self:stretch;border:0;border-radius:0}
#workspaceAiChat>.sb-monitor>.sb-monitor-head{display:none}

#workspaceAiChat .sb-monitor-actions .sb-monitor-export-primary{color:var(--cg-on-brand,#101010);background:var(--cg-brand);border-color:var(--cg-brand)}
#workspaceAiChat .sb-monitor-actions .sb-monitor-export-primary svg{color:inherit}
#workspaceAiChat .sb-monitor-actions{flex-shrink:0}
#workspaceAiChat .sb-monitor-colors{min-height:0;flex:1;overflow-y:auto}

#workspaceAiChat #studioToolAiTab[data-unread=true]::after{content:'';width:5px;height:5px;border-radius:50%;background:var(--cg-brand)}
/* Only timeline uses tool tabs; desk retains the separate monitor beside the viewer. */
html.cutgo-mode-desk #workspaceAiChat #studioToolMonitorTab{display:none}
html.cutgo-mode-desk #workspaceAiChat #studioToolAiTab{border-bottom:0;color:var(--cg-text);cursor:default}
#workspaceAiChat .sb-monitor-data>.sb-monitor-colors{flex:0 0 auto}
#workspaceAiChat>.sb-monitor>.sb-monitor-colors{flex:0 0 auto;overflow:hidden}

/* Writeback and confirmed billing share one secondary metadata row. */
#workspaceAiChat .cg-chat-writeback-receipt .cg-chat-writeback-label,
#workspaceAiChat .cg-chat-writeback-receipt .cg-chat-billing-receipt{font-size:11px;font-weight:400;line-height:1.5;color:var(--cg-text-secondary)}
#workspaceAiChat .cg-chat-writeback-receipt .cg-chat-billing-receipt{display:inline;margin:0 0 0 auto}

/* Routine success needs only its billing receipt; exceptions remain explicit. */
#workspaceAiChat .cg-chat-writeback-receipt{border:0;padding-top:0;margin-top:8px}
#workspaceAiChat .cg-chat-billing-receipt{font-size:11px;font-weight:400;line-height:1.5}
#workspaceAiChat .cg-chat-writeback-receipt .cg-chat-billing-receipt{margin:0}
