/**
 * Copyright (c) 2014 The xterm.js authors. All rights reserved.
 * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
 * https://github.com/chjj/term.js
 * @license MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * Originally forked from (with the author's permission):
 *   Fabrice Bellard's javascript vt100 for jslinux:
 *   http://bellard.org/jslinux/
 *   Copyright (c) 2011 Fabrice Bellard
 *   The original design remains. The terminal itself
 *   has been extended to include xterm CSI codes, among
 *   other features.
 */.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{-webkit-user-select:text;user-select:text;white-space:pre}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}:root{--primary: #260048;--accent: #00e294;--bg: #f6f4f9;--panel: #ffffff;--border: #e4dfeb;--text: #1d1428;--muted: #7a6f88;--user: #260048;--user-text: #ffffff;--code-bg: #f1edf6;--error: #d6336c;--warn: #e8a317;color-scheme:light}@media (prefers-color-scheme: dark){:root{--bg: #120819;--panel: #1c1026;--border: #2f2140;--text: #ece6f2;--muted: #9a8fab;--user: #3b1466;--code-bg: #24172f;color-scheme:dark}}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}body{font-family:Inter,system-ui,sans-serif;font-size:14px;background:var(--bg);color:var(--text)}button{font:inherit;cursor:pointer}button:disabled{cursor:default;opacity:.5}input,select,textarea{font:inherit;color:inherit;background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:8px 10px;width:100%}input:focus,select:focus,textarea:focus{outline:2px solid var(--accent);outline-offset:-1px}code,pre{font-family:ui-monospace,JetBrains Mono,Menlo,monospace;font-size:12.5px}.muted{color:var(--muted);font-size:12px}.error{color:var(--error);font-size:12px}.link{background:none;border:none;padding:0;color:var(--accent);text-decoration:underline}.btn-primary{background:var(--primary);color:#fff;border:none;border-radius:8px;padding:8px 14px;font-weight:500}.btn-primary:not(:disabled):hover{background:#3a0a68}.btn-ghost{background:transparent;border:1px solid var(--border);border-radius:8px;padding:7px 12px;color:var(--text)}.login-wrap{min-height:100%;display:grid;place-items:center;background:color-mix(in srgb,var(--primary) 80%,transparent);padding:16px}.login-card{background:var(--panel);border-radius:14px;padding:28px;width:min(380px,100%);display:flex;flex-direction:column;gap:12px}.brand{font-weight:600;font-size:18px;display:flex;align-items:center;gap:8px}.brand-mark{color:var(--accent)}.layout{display:flex;height:100%}.placeholder{flex:1;display:grid;place-items:center}.sidebar{width:280px;flex-shrink:0;background:var(--panel);border-right:1px solid var(--border);display:flex;flex-direction:column;padding:16px;gap:16px}.new-session{display:flex;flex-direction:column;gap:8px}.new-session label{display:flex;flex-direction:column;gap:4px;font-size:12px;color:var(--muted)}.session-list{flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:4px}.session-item{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:8px;cursor:pointer}.session-item:hover{background:var(--code-bg)}.session-item.active{background:color-mix(in srgb,var(--accent) 16%,transparent)}.session-text{flex:1;min-width:0}.session-cwd{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500}.icon-btn{background:none;border:none;color:var(--muted);font-size:18px;line-height:1}.icon-btn:hover{color:var(--error)}.dot{width:8px;height:8px;border-radius:50%;flex-shrink:0;background:var(--muted)}.dot-running{background:var(--accent)}.sidebar-footer{display:flex;justify-content:space-between;align-items:center}.chat{flex:1;min-width:0;display:flex;flex-direction:column}.chat-header{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px 20px;border-bottom:1px solid var(--border);background:var(--panel)}.chat-title{font-weight:600}.chat-meta{display:flex;gap:6px;align-items:center;margin-top:4px;flex-wrap:wrap}.chat-id{color:var(--muted);font-size:11px}.pill{font-size:11px;padding:2px 8px;border-radius:999px;background:var(--code-bg);color:var(--muted)}.pill-open,.pill-running{background:color-mix(in srgb,var(--accent) 20%,transparent);color:var(--text)}.pill-closed,.pill-unauthorized,.pill-exited{background:color-mix(in srgb,var(--error) 18%,transparent);color:var(--text)}.chat-body{flex:1;min-height:0;display:flex}.messages{flex:1;min-width:0;overflow-y:auto;padding:20px max(20px,calc((100% - 860px)/2));display:flex;flex-direction:column;gap:12px}.empty{color:var(--muted);text-align:center;margin-top:15vh;line-height:1.6}.msg{display:flex;flex-direction:column;gap:6px}.msg-user{align-items:flex-end}.msg-user .bubble{background:var(--user);color:var(--user-text);padding:10px 14px;border-radius:14px 14px 4px;max-width:80%;white-space:pre-wrap;word-break:break-word}.msg-user.pending .bubble{opacity:.55}.msg-system{align-self:center;font-size:12px;color:var(--muted);font-family:ui-monospace,Menlo,monospace}.markdown{line-height:1.6;word-break:break-word}.markdown>:first-child{margin-top:0}.markdown>:last-child{margin-bottom:0}.markdown pre{background:var(--code-bg);padding:10px 12px;border-radius:8px;overflow-x:auto}.markdown :not(pre)>code{background:var(--code-bg);padding:1px 5px;border-radius:4px}.markdown table{border-collapse:collapse;display:block;overflow-x:auto}.markdown th,.markdown td{border:1px solid var(--border);padding:4px 8px}.thinking summary,.tool summary{cursor:pointer;list-style:none}.thinking summary::-webkit-details-marker,.tool summary::-webkit-details-marker{display:none}.thinking summary{color:var(--muted);font-size:12px;font-style:italic}.thinking-body{white-space:pre-wrap;color:var(--muted);font-size:12.5px;padding:6px 0 0 12px;border-left:2px solid var(--border)}.tool{border:1px solid var(--border);border-radius:8px;background:var(--panel)}.tool summary{display:flex;align-items:center;gap:8px;padding:6px 10px;min-width:0}.tool-dot{width:7px;height:7px;border-radius:50%;flex-shrink:0}.tool-pending .tool-dot{background:var(--warn)}.tool-done .tool-dot{background:var(--accent)}.tool-error .tool-dot{background:var(--error)}.tool-name{font-weight:600;font-size:12.5px}.tool-summary{color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}.tool-body{padding:0 10px 10px}.tool-label{font-size:11px;color:var(--muted);margin:8px 0 4px;text-transform:uppercase;letter-spacing:.04em}.tool-body pre{margin:0;background:var(--code-bg);padding:8px 10px;border-radius:6px;max-height:320px;overflow:auto;white-space:pre-wrap;word-break:break-word}.activity{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:12.5px}.spinner{width:12px;height:12px;border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}.composer{border-top:1px solid var(--border);background:var(--panel);padding:12px max(20px,calc((100% - 860px)/2));display:flex;gap:10px;align-items:flex-end}.composer textarea{resize:none;flex:1}.composer-actions{display:flex;flex-direction:column;gap:6px}.terminal-panel{width:min(48%,760px);flex-shrink:0;border-left:1px solid var(--border);background:#14061f;display:flex;flex-direction:column}.terminal-panel[hidden]{display:none}.terminal-keys{display:flex;flex-wrap:wrap;gap:4px;padding:6px;border-bottom:1px solid #2f2140}.terminal-keys button{background:#24172f;color:#ece6f2;border:1px solid #3a2a4d;border-radius:6px;padding:3px 8px;font-size:12px}.terminal-host{flex:1;min-height:0;padding:6px}@media (max-width: 760px){.layout{flex-direction:column}.sidebar{width:auto;border-right:none;border-bottom:1px solid var(--border);max-height:40vh;overflow-y:auto}.chat-body{flex-direction:column}.terminal-panel{width:auto;height:45vh;border-left:none;border-top:1px solid var(--border)}.messages,.composer{padding-left:16px;padding-right:16px}}
