@layer legacy, theme, base, components, utilities;
@layer legacy {
/* Main conversation surface. Applied after legacy and component styles. */
body .workspace-screen>header{display:flex!important;flex-wrap:wrap;align-items:center;justify-content:space-between}
.chat-heading-identity{flex:1 1 180px;min-width:0;max-width:100%}
body .chat-heading-identity h1{margin:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body .chat-heading-identity .workspace-context{margin:5px 0 0;font-size:11px;color:var(--muted)}
.chat-heading-controls{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex:0 1 auto;min-width:0;max-width:100%}
body .chat-heading-controls .agent-picker{width:150px;max-width:150px;flex:0 1 150px;min-width:0}
body .chat-heading-controls select{width:100%;max-width:150px}
body .chat-heading-controls>button{flex:0 0 32px;width:32px;padding:4px}
@media(max-width:760px){.chat-heading-controls{width:100%;justify-content:flex-start}.chat-heading-identity{flex-basis:100%}body .chat-heading-controls .agent-picker{flex:1 1 0;width:0;max-width:none}body .chat-heading-controls select{max-width:100%}}

body .workspace-screen{background:var(--panel);padding:0;gap:0}
body .workspace-screen>header{background:var(--bg);padding:16px 24px;border-bottom:1px solid var(--line);gap:10px;grid-template-columns:minmax(0,1fr) minmax(110px,170px) minmax(110px,170px) 36px;align-items:center}
body .workspace-screen>header .agent-picker{width:100%;max-width:170px;justify-self:end}
body .workspace-screen>header .agent-picker select{width:100%;max-width:170px;min-width:0;text-overflow:ellipsis;padding:5px 8px;font-size:12px}
body .workspace-screen>header>button{width:36px;max-width:36px;padding:4px;justify-self:end}
body .workspace-tree .workspace-stream-row{display:grid;grid-template-columns:minmax(0,1fr) 36px;align-items:start;margin-left:4px}
body .workspace-tree .workspace-stream-row>button:first-child{display:-webkit-box;width:100%;min-width:0;white-space:normal;overflow-wrap:anywhere;line-height:1.45;-webkit-line-clamp:3;-webkit-box-orient:vertical;padding:8px 10px;text-align:left}
body .workspace-tree .workspace-agent-heading{white-space:normal;overflow-wrap:anywhere;text-align:left;line-height:1.4}
body .workspace-tree summary>button:first-child{-webkit-line-clamp:3;white-space:normal}
body .workspace-tree .workspace-stream-row>button:last-child{align-self:start;margin-top:4px}
body .workspace-screen>header h1{font-size:20px}
body .workspace-screen>.workspace-error:not([hidden]){margin:12px 24px}
body .workspace-content{padding:32px max(24px,calc((100% - 800px)/2));background:var(--panel)}
body .workspace-content .body h2{padding-bottom:8px;border-bottom:1px solid var(--line)}
body .workspace-content .body a{text-underline-offset:3px}
body .workspace-content .body li p{margin:4px 0}
body .workspace-content .bui-code-block>div{border-radius:12px;background:var(--panel)}
body .ui-composer-host{background:var(--panel);width:100%;max-width:none;padding:12px max(24px,calc((100% - 800px)/2)) 24px}
body .workspace-screen .bui-composer{background:var(--bg);border:1px solid var(--line);border-radius:20px;padding:16px 18px;margin:0;box-shadow:0 6px 24px #00000008}
.bui-composer-caption{display:flex;justify-content:space-between;gap:12px;font-size:10px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);padding-bottom:10px}
.bui-composer-caption span:last-child{font-weight:400;letter-spacing:0;text-transform:none}
.bui-composer-caption .ui-folder-choice{margin-left:auto;max-width:50%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:0;background:none;padding:0;font:inherit;font-weight:400;letter-spacing:0;text-transform:none;color:var(--muted);cursor:pointer}.bui-composer-caption .ui-folder-choice:hover,.bui-composer-caption .ui-folder-choice[data-chosen=true]{color:inherit;text-decoration:underline}
body .bui-composer textarea{min-height:76px;padding:4px 0;font-size:15px}
body .bui-composer .ui-composer-toolbar{border-top:1px solid var(--line);padding-top:12px;margin-top:8px}
body .bui-composer button[type=submit]{height:36px;min-width:44px;padding:0 12px;border-radius:10px;gap:8px}
body .bui-composer .ui-send-label{display:none}
body .bui-composer button[type=submit][data-uploading] .ui-send-label{display:inline;white-space:nowrap}
body .bui-composer .ui-composer-hint{font-size:10px}
/* The keyboard hint only fits (and only matters) with a wide window and a keyboard: never let it squeeze into a one-word column. */
@media(max-width:1100px),(pointer:coarse){body .bui-composer .ui-composer-hint{display:none}}
@media(min-width:1200px){}
@media(max-width:760px){body .workspace-screen>header{padding:12px 16px;grid-template-columns:minmax(0,1fr) 36px}body .workspace-screen>header .agent-picker{justify-self:start;max-width:100%;grid-column:1;grid-row:auto}body .workspace-screen>header .agent-picker:nth-of-type(2){grid-column:2;min-width:0}body .workspace-screen>header{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}body .workspace-screen>header>button{grid-column:2;grid-row:1}body .workspace-screen>header .agent-picker select{max-width:100%}body .workspace-screen>header h1{font-size:18px}body .workspace-content{padding:20px 12px}body .ui-composer-host{padding:8px 12px 12px}body .workspace-screen .bui-composer{padding:12px 14px;border-radius:16px}body .bui-composer textarea{min-height:58px}.bui-composer-caption{font-size:9px}}
/* Transcript in the style of PI's TUI: flowing assistant text, tinted user block, compact tool lines. */
body .workspace-content .ui-chat-message{border:0;background:none;box-shadow:none;border-radius:0;padding:0;margin:0 0 14px;max-width:none;line-height:1.65;font-size:14.5px}
body .workspace-content .ui-chat-message.user{background:var(--user);border-radius:6px;padding:8px 14px;margin:18px 0 14px}
body .workspace-content .ui-chat-message.user p{margin:0;white-space:pre-wrap}
body .workspace-content .ui-chat-message.assistant{padding:0 2px}
body .workspace-content .ui-chat-message.toolResult{margin:0 0 8px}
body .workspace-content .tui-tool{display:flex;align-items:baseline;gap:8px;margin:10px 0 2px;font:12.5px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--text);min-width:0}
body .workspace-content .tui-mark{flex:none;width:1.2em;text-align:center;color:var(--accent)}
body .workspace-content .tui-tool.failed,body .workspace-content .tui-tool.failed .tui-mark{color:var(--danger)}
body .workspace-content .tui-tool.running .tui-mark{color:var(--muted)}
body .workspace-content .tui-tool-name{flex:none;font-weight:600}
body .workspace-content .tui-tool-args{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted)}
body .workspace-content .tui-tool-time{flex:none;color:var(--muted)}
body .workspace-content .tui-result{margin:0 0 8px 1.2em;padding-left:10px;border-left:2px solid var(--line)}
body .workspace-content .tui-result.failed{border-left-color:var(--danger)}
body .workspace-content .tui-output,body .workspace-content .tui-thinking pre{margin:0;padding:0;border:0;background:none;white-space:pre-wrap;overflow-wrap:anywhere;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--muted)}
body .workspace-content .tui-result.failed .tui-output{color:var(--danger)}
body .workspace-content .tui-thinking{margin:6px 0;padding-left:10px;border-left:2px solid var(--line);font-style:italic}
body .workspace-content .tui-thinking pre{font:inherit;font-size:13px}
body .workspace-content .tui-thinking strong{font-style:normal;font-weight:600;color:var(--text)}
body .workspace-content .ui-chat-message.thinking-only{margin:0 0 4px}
body .workspace-content .ui-chat-message.thinking-only .tui-thinking{margin:0}
body .workspace-content .tui-more{border:0;background:none;margin:0;overflow:visible;border-radius:0}
body .workspace-content .tui-more summary{display:block;padding:0;background:none;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--accent);cursor:pointer;list-style:none}
body .workspace-content .tui-more summary::-webkit-details-marker{display:none}
body .workspace-content .tui-more[open] summary{display:none}
body .workspace-content .ui-chat-message.assistant .body{margin:0}
@media(max-width:760px){body .workspace-content .ui-chat-message{font-size:14px}body .workspace-content .tui-tool{flex-wrap:wrap}body .workspace-content .tui-tool-args{flex-basis:100%;white-space:normal}}

/* One scroller per region, never a scrollbar inside a scrollable page. Absolutely positioned
   helpers (.sr-only) inside the transcript must be contained by their message, otherwise the
   document grows by the whole transcript height and gets its own scrollbar. */
html,body{overflow:hidden;overscroll-behavior:none}
body .workspace-content,body .ui-chat-message{position:relative}
.ui-app-footer{flex:none;padding:2px 16px 8px;text-align:center;font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--muted)}
[data-webui-version]{user-select:all}
body .workspace-content{overscroll-behavior:contain}
body .workspace-tree{overscroll-behavior:contain;overflow-x:hidden}
/* Base UI positions the Positioner; the legacy `.workspace-menu{position:fixed}` must not pull the popup out of it (it broke end-aligned menus). */
body .ui-action-menu{position:relative}

/* PI-like tool box: call line and result form one tinted panel; success/failure tint the result, palette variables preserved. */
body .workspace-content .tui-tool{background:color-mix(in srgb,var(--text) 7%,transparent);border-radius:6px 6px 0 0;padding:6px 10px;margin:10px 0 0}
body .workspace-content .tui-result{margin:0 0 10px;padding:6px 10px 8px;border-left:0;border-radius:0 0 6px 6px;background:color-mix(in srgb,var(--accent) 14%,transparent)}
body .workspace-content .tui-result.failed{background:color-mix(in srgb,var(--danger) 16%,transparent)}
body .workspace-content .tui-took,body .workspace-content .tui-time{color:var(--muted);font:11.5px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}
body .workspace-content .tui-took{margin-top:6px}
body .workspace-content .tui-time{display:block;margin:0 0 2px;text-align:right}
body .workspace-content .tui-images{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0 0}
body .workspace-content .tui-image-open{all:unset;cursor:pointer;text-decoration:underline dotted;text-underline-offset:3px}
body .workspace-content .tui-image-open:focus-visible{outline:2px solid var(--accent,currentColor);outline-offset:2px;border-radius:4px}
body .workspace-content .tui-image-pic{display:block;max-width:min(100%,420px);max-height:320px;border-radius:6px;object-fit:contain}
body .workspace-content .tui-image:has(.tui-image-pic){border:0;padding:0}
body .workspace-content .tui-image{border:1px dashed var(--line);border-radius:6px;padding:2px 8px;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--muted)}

/* Spacing in the live tail of a chat: the receipt of a message sent while the agent works, and the status line, sit clear of the tool boxes above. */
body .workspace-content .tui-working{margin:16px 0 4px;font-size:13px;color:var(--muted)}
body .workspace-content .message.user.pending-receipt{margin:16px 0 12px;padding:8px 14px;border-radius:6px;white-space:normal}
body .workspace-content .message.user.pending-receipt p{margin:0;white-space:pre-wrap}
body .workspace-content .tui-receipt{display:block;margin:4px 0 0;font-size:12px;color:var(--muted)}
body .workspace-content .tui-receipt-images{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0 0}
body .workspace-content .tui-receipt-images img{display:block;max-width:min(100%,240px);max-height:180px;border-radius:6px;object-fit:contain}
/* Image drafts in the composer: thumbnails in a row, a small round remove button over the corner, a progress bar while uploading. */
.bui-composer [aria-label="Attached images"]{display:flex;flex-wrap:wrap;gap:8px;margin:0 0 8px}
.bui-composer [aria-label="Attached images"]:empty{display:none}
.ui-attachment{position:relative;width:84px;height:84px;border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--panel)}
.ui-attachment img{display:block;width:100%;height:100%;object-fit:cover}
.ui-attachment>button{position:absolute;top:3px;right:3px;width:22px;height:22px;min-height:0;padding:0;border-radius:50%;line-height:1;display:flex;align-items:center;justify-content:center;background:var(--bg);color:var(--text);border:1px solid var(--line)}
.ui-attachment>button[hidden]{display:none!important}
.ui-attachment[data-uploading] img{opacity:.45}
.ui-attachment progress{position:absolute;left:6px;right:6px;bottom:6px;width:auto;height:6px;appearance:none;border:0;border-radius:3px;overflow:hidden;background:var(--line)}
.ui-attachment progress::-webkit-progress-bar{background:var(--line)}
.ui-attachment progress::-webkit-progress-value{background:var(--accent);transition:width .15s}
.ui-attachment progress::-moz-progress-bar{background:var(--accent)}
.ui-attachment .pct{position:absolute;top:50%;left:0;right:0;transform:translateY(-60%);text-align:center;font-size:12px;font-weight:600;color:var(--text)}
@media(prefers-reduced-motion:reduce){.ui-attachment progress::-webkit-progress-value{transition:none}}
/* Messenger-style actions beside a message: quiet icons that appear on hover / keyboard focus, always visible on touch screens. */
body .workspace-content .ui-chat-message{position:relative}
body .workspace-content .message-actions{position:absolute;top:-4px;right:0;display:flex;gap:2px;padding:2px;border:1px solid var(--line);border-radius:8px;background:var(--panel);opacity:0;pointer-events:none;transition:opacity .12s ease-out;z-index:2}
body .workspace-content .ui-chat-message:hover>.message-actions,body .workspace-content .ui-chat-message:focus-within>.message-actions{opacity:1;pointer-events:auto}
@media(hover:none){body .workspace-content .message-actions{opacity:.75;pointer-events:auto}}
body .workspace-content .message-action{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;min-width:0;padding:0;margin:0;border:0;border-radius:6px;background:transparent;color:var(--muted);cursor:pointer;transition:background-color .12s ease-out,color .12s ease-out}
body .workspace-content .message-action:hover{background:var(--user);color:var(--text)}
body .workspace-content .message-action-delete:hover{color:var(--danger)}
body .workspace-content .message-action .copy-done{display:none}
body .workspace-content .message-action[data-done="true"] .copy-idle{display:none}
body .workspace-content .message-action[data-done="true"] .copy-done{display:inline;stroke:var(--accent)}
.clipboard-holder{position:fixed;top:0;left:-9999px;width:1px;height:1px;opacity:0}
body .workspace-content .message-action:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
@media(prefers-reduced-motion:reduce){body .workspace-content .message-actions,body .workspace-content .message-action{transition:none}}
body .workspace-content .message-action svg{flex:none;width:14px;height:14px}
/* The reply to an operator command (e.g. closing an order) is not output of the agent: italic, muted, dashed edge and a mark. */
body .workspace-content .ui-chat-message.command-notice{background:transparent;border:0;border-left:2px dashed var(--line);border-radius:0;box-shadow:none;padding:2px 0 2px 10px}
body .workspace-content .tui-notice{margin:0;font-style:italic;color:var(--muted);white-space:pre-wrap;overflow-wrap:anywhere}
body .workspace-content .tui-notice-mark{display:block;margin:0 0 2px;font:600 10.5px/1.3 ui-monospace,SFMono-Regular,Menlo,monospace;font-style:normal;letter-spacing:.06em;text-transform:uppercase}

/* Bubbles: my messages right, the agent's left, each as a rounded bubble of the existing palette. The action bar sits BESIDE the bubble
   (left of mine, right of the agent's) on wide screens; on narrow ones it stays on the corner. Emojis hang on the bubble's upper edge. */
body .workspace-content .ui-chat-message.user,body .workspace-content .message.user.pending-receipt{width:fit-content;max-width:min(82%,640px);margin:18px 0 14px auto;padding:9px 16px;border-radius:18px 18px 4px 18px}
body .workspace-content .ui-chat-message.assistant.bubble{width:fit-content;max-width:min(92%,720px);margin:0 0 14px;padding:9px 16px;border-radius:18px 18px 18px 4px;background:color-mix(in srgb,var(--text) 7%,transparent)}
body .workspace-content .ui-chat-message.assistant.bubble .body>:first-child{margin-top:0}
body .workspace-content .ui-chat-message.assistant.bubble .body>:last-child{margin-bottom:0}
body .workspace-content .ui-chat-message.has-reactions{margin-top:22px}
body .workspace-content .ui-chat-message.user .tui-time,body .workspace-content .ui-chat-message.bubble .tui-time{text-align:right}
@media(min-width:761px){
  body .workspace-content .ui-chat-message.bubble>.message-actions,body .workspace-content .ui-chat-message.user>.message-actions{top:auto;bottom:0;transform:none}
  body .workspace-content .ui-chat-message.user>.message-actions{right:calc(100% + 6px)}
  body .workspace-content .ui-chat-message.assistant.bubble>.message-actions{right:auto;left:calc(100% + 6px)}
  /* the gap between bubble and bar still counts as hovering the message */
  body .workspace-content .message-actions::before{content:"";position:absolute;inset:-6px -10px;z-index:-1}
}
body .workspace-content .message-reactions{position:absolute;top:-14px;display:flex;gap:2px;z-index:1}
body .workspace-content .ui-chat-message.assistant .message-reactions{right:12px}
body .workspace-content .ui-chat-message.user .message-reactions{left:12px}
body .workspace-content .message-reaction{display:inline-flex;align-items:center;justify-content:center;min-width:26px;height:26px;padding:0 5px;margin:0;border:2px solid var(--panel);border-radius:13px;background:color-mix(in srgb,var(--accent) 55%,var(--bg));font:14px/1 system-ui,sans-serif;color:var(--text);cursor:pointer}
body .workspace-content span.message-reaction{cursor:default}
body .workspace-content button.message-reaction:hover{background:color-mix(in srgb,var(--accent) 75%,var(--bg))}
body .workspace-content .message-reaction:focus-visible,body .workspace-content .reaction-choice:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
body .workspace-content .reaction-picker{position:absolute;top:calc(100% + 4px);z-index:5;display:flex;gap:2px;padding:3px;border:1px solid var(--line);border-radius:999px;background:var(--panel);box-shadow:0 6px 24px #00000026}
body .workspace-content .ui-chat-message.assistant .reaction-picker{left:0}
body .workspace-content .ui-chat-message.user .reaction-picker{right:0}
/* Wide screens: the picker opens right at the action bar (the same side of the bubble, directly above the bar), never below the bubble at the edge of the screen. */
@media(min-width:761px){
  body .workspace-content .ui-chat-message.bubble>.reaction-picker,body .workspace-content .ui-chat-message.user>.reaction-picker{top:auto;bottom:38px}
  body .workspace-content .ui-chat-message.user>.reaction-picker{left:auto;right:calc(100% + 6px)}
  body .workspace-content .ui-chat-message.assistant.bubble>.reaction-picker{right:auto;left:calc(100% + 6px)}
}
body .workspace-content .reaction-choice{width:34px;height:34px;min-width:0;padding:0;margin:0;border:0;border-radius:50%;background:transparent;font:18px/1 system-ui,sans-serif;cursor:pointer;transition:background-color .12s ease-out,transform .12s ease-out}
body .workspace-content .reaction-choice:hover{background:var(--user);transform:scale(1.12)}
body .workspace-content .reaction-choice[aria-checked="true"]{background:color-mix(in srgb,var(--accent) 35%,transparent)}
@media(prefers-reduced-motion:reduce){body .workspace-content .reaction-choice{transition:none}}

/* Reply: the message being answered is a set-off bar above the field (not text inside it); in a sent message it is the same bar above the text. */
.ui-reply-bar{display:flex;align-items:flex-start;gap:8px;margin:0 0 10px;padding:8px 8px 8px 12px;border-left:3px solid var(--accent);border-radius:6px 10px 10px 6px;background:color-mix(in srgb,var(--text) 6%,transparent)}
.ui-reply-bar[hidden]{display:none}
.ui-reply-bar-body{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px}
.ui-reply-bar-label{font-size:11px;font-weight:600;letter-spacing:.02em;color:var(--accent)}
.ui-reply-bar-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.45;color:var(--muted);cursor:pointer}
.ui-reply-bar[data-open="true"] .ui-reply-bar-text{display:block;-webkit-line-clamp:unset;max-height:40vh;overflow:auto;cursor:pointer}
.ui-reply-bar>button{flex:none;width:28px;height:28px;min-height:0;padding:0}
body .workspace-content .message-quote{all:unset;box-sizing:border-box;display:block;width:100%;margin:0 0 6px;padding:5px 10px;border-left:3px solid var(--accent);border-radius:4px 8px 8px 4px;background:color-mix(in srgb,var(--text) 9%,transparent);cursor:pointer}
body .workspace-content .message-quote:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
body .workspace-content .message-quote-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.45;color:var(--muted)}
body .workspace-content .message-quote[aria-expanded="true"] .message-quote-text{display:block;-webkit-line-clamp:unset}

}
