/**
 * 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{--bg: #0b0e14;--panel: #11151f;--panel2: #161b27;--border: #232a3a;--fg: #c5cdda;--muted: #7a869c;--accent: #5aa9ff;--danger: #ff6b6b;--ok: #6bd968;font-family:ui-sans-serif,system-ui,-apple-system,sans-serif}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg)}button{font:inherit;color:var(--fg);background:var(--panel2);border:1px solid var(--border);border-radius:6px;padding:6px 12px;cursor:pointer}button:hover{border-color:var(--accent)}button.primary{background:var(--accent);color:#04101f;border-color:var(--accent);font-weight:600}button.danger{color:var(--danger)}input,textarea,select{font:inherit;color:var(--fg);background:var(--bg);border:1px solid var(--border);border-radius:6px;padding:6px 8px;width:100%}textarea{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.app{display:grid;grid-template-columns:320px 1fr;height:100vh}.sidebar{background:var(--panel);border-right:1px solid var(--border);display:flex;flex-direction:column;min-height:0}.sidebar header{padding:12px;border-bottom:1px solid var(--border);display:flex;gap:8px;align-items:center}.sidebar .filter{padding:8px 12px}.sessions{overflow-y:auto;flex:1}.session{padding:10px 12px;border-bottom:1px solid var(--border);cursor:pointer}.session:hover{background:var(--panel2)}.session.active{background:var(--panel2);border-left:3px solid var(--accent)}.session .name{font-weight:600}.session .meta{color:var(--muted);font-size:12px;margin-top:2px}.group-label{color:var(--muted);font-size:11px;text-transform:uppercase;padding:10px 12px 4px;letter-spacing:.5px}.main{display:flex;flex-direction:column;min-width:0;min-height:0}.toolbar{padding:8px 12px;border-bottom:1px solid var(--border);display:flex;gap:8px;align-items:center}.toolbar .spacer{flex:1}.terminal-wrap{flex:1;min-height:0;padding:6px;background:#000}.terminal-wrap .xterm{height:100%}.overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;display:flex;align-items:center;justify-content:center}.modal{background:var(--panel);border:1px solid var(--border);border-radius:10px;padding:18px;width:560px;max-height:86vh;overflow-y:auto}.modal h2{margin-top:0}.field{margin:10px 0}.field label{display:block;color:var(--muted);font-size:12px;margin-bottom:4px}.row{display:flex;gap:8px}.perm-stack{position:absolute;right:14px;bottom:14px;display:flex;flex-direction:column;gap:10px;max-width:420px}.perm-card{background:var(--panel);border:1px solid var(--danger);border-radius:10px;padding:12px;box-shadow:0 6px 24px #0006}.perm-card .tool{font-weight:700}.perm-card pre{background:var(--bg);border:1px solid var(--border);border-radius:6px;padding:8px;overflow-x:auto;max-height:160px;font-size:12px}.perm-card .actions{display:flex;gap:8px;margin-top:8px}.feed{position:absolute;left:14px;bottom:14px;width:360px;max-height:40vh;overflow-y:auto;background:#11151ff2;border:1px solid var(--border);border-radius:10px;padding:10px;font-size:12px}.feed .evt{padding:4px 0;border-bottom:1px solid var(--border)}.banner{padding:8px 12px;background:#3a2a12;color:#ffcf8a;border-bottom:1px solid var(--border)}.center{display:flex;align-items:center;justify-content:center;height:100vh;flex-direction:column;gap:14px}.gh-dock{position:absolute;top:48px;right:0;bottom:0;width:340px;overflow-y:auto;background:#11151ff7;border-left:1px solid var(--border);padding:6px 12px 16px;font-size:13px}.gh-panel .hint{color:var(--muted);font-size:12px;padding:4px 0}.gh-panel .muted{color:var(--muted)}.gh-list{display:flex;flex-direction:column}.gh-row{display:flex;align-items:center;gap:6px;padding:5px 0;border-bottom:1px solid var(--border);color:inherit;text-decoration:none;font-size:12px}.gh-row:hover{color:#cdd6f4}.gh-row .spacer{flex:1}.gh-row button{padding:2px 6px;font-size:11px}.dot{width:8px;height:8px;border-radius:50%;background:var(--muted);display:inline-block;flex:none}.dot.success{background:#43d17a}.dot.failure,.dot.timed_out,.dot.cancelled{background:#e5534b}.dot.in_progress,.dot.queued,.dot.pending{background:#e0a13a}.tabs{display:flex;gap:4px;margin-left:12px}.tab{padding:4px 12px;background:transparent;border:1px solid transparent;border-radius:6px}.tab.active{background:var(--panel2);border-color:var(--border);color:var(--accent)}.stream{display:flex;flex-direction:column;flex:1;min-height:0}.stream-scroll{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px}.stream-trunc{text-align:center;color:var(--muted);font-size:12px}.msg{display:flex}.msg.user{justify-content:flex-end}.msg.user .bubble{background:var(--accent);color:#04101f;padding:8px 12px;border-radius:12px 12px 2px;max-width:80%;white-space:pre-wrap}.msg.assistant .md{max-width:90%;line-height:1.55}.md pre{background:#05070c;border:1px solid var(--border);border-radius:8px;padding:10px;overflow-x:auto}.md code{background:#05070c;padding:1px 5px;border-radius:4px;font-family:ui-monospace,monospace;font-size:.9em}.md pre code{background:none;padding:0}.md h1,.md h2,.md h3{margin:.4em 0}.md a{color:var(--accent)}.sidechain{border-left:2px solid #4a3a6a;padding-left:12px;margin-left:4px}.sidechain-label{color:#b08cff;font-size:11px;text-transform:uppercase;letter-spacing:.5px;margin-bottom:4px}.tool-card{border:1px solid var(--border);border-radius:8px;background:var(--panel2);overflow:hidden}.tool-card.err{border-color:var(--danger)}.tool-head{display:flex;align-items:center;gap:8px;width:100%;text-align:left;background:none;border:none;border-radius:0;padding:8px 10px}.tool-status{width:14px;color:var(--ok)}.tool-card.err .tool-status{color:var(--danger)}.tool-name{font-weight:600;white-space:nowrap}.tool-summary{color:var(--muted);font-family:ui-monospace,monospace;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}.tool-caret{color:var(--muted)}.tool-detail{padding:8px 10px;border-top:1px solid var(--border)}.tool-section-label{color:var(--muted);font-size:11px;text-transform:uppercase;margin:4px 0}.tool-detail pre{background:#05070c;border:1px solid var(--border);border-radius:6px;padding:8px;overflow-x:auto;max-height:320px;font-size:12px;white-space:pre-wrap}.tool-detail pre.err{color:#ffb4b4}.thinking{color:var(--muted)}.thinking-head{background:none;border:none;color:var(--muted);padding:2px 0}.thinking-body{background:#05070c;border:1px solid var(--border);border-radius:6px;padding:8px;font-size:12px;white-space:pre-wrap;font-style:italic}.prompt-input{position:relative;border-top:1px solid var(--border);padding:10px 12px;background:var(--panel)}.prompt-input.disabled{color:var(--muted);text-align:center}.prompt-row{display:flex;gap:8px;align-items:flex-end}.prompt-row textarea{resize:none;flex:1;max-height:240px}.attach-btn{cursor:pointer;padding:6px 8px;border:1px solid var(--border);border-radius:6px}.send{white-space:nowrap}.chips{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}.chip{background:var(--panel2);border:1px solid var(--border);border-radius:14px;padding:3px 8px;font-size:12px}.chip button{background:none;border:none;color:var(--muted);padding:0 0 0 6px}.suggestions{position:absolute;bottom:100%;left:12px;right:12px;background:var(--panel);border:1px solid var(--border);border-radius:8px;max-height:260px;overflow-y:auto;margin-bottom:4px;box-shadow:0 -6px 24px #0006}.sug{display:flex;gap:10px;padding:6px 10px;cursor:pointer}.sug.active{background:var(--panel2)}.sug-label{font-family:ui-monospace,monospace}.sug-hint{color:var(--muted);font-size:12px}@media(max-width:720px){.app{grid-template-columns:1fr}.sidebar{display:none}}
