/**
 * 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,.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.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-0: #0a0e14;--bg-1: #121820;--glass-bg: rgba(255, 255, 255, .06);--glass-strong-bg: rgba(255, 255, 255, .08);--glass-border: rgba(255, 255, 255, .12);--glass-border-strong: rgba(255, 255, 255, .15);--accent: #e1f36b;--green: #32d583;--yellow: #f5c451;--red: #f97066;--terminal: #08090a;color:#fff;background:var(--bg-0);font-family:-apple-system,BlinkMacSystemFont,SF Pro Text,SF Pro Display,system-ui,sans-serif;font-synthesis:none;text-rendering:optimizeLegibility}*{box-sizing:border-box}html{min-width:320px;min-height:100%;background:#111}body{min-width:320px;min-height:100vh;margin:0;background:linear-gradient(170deg,var(--bg-0) 0%,var(--bg-1) 100%);overflow-x:hidden}button,input{font:inherit}button{cursor:pointer;-webkit-tap-highlight-color:transparent}button:focus-visible,input:focus-visible{outline:2px solid rgba(225,243,107,.55);outline-offset:2px}h1,h2,h3,p,pre{margin:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.app-shell{position:relative;display:flex;flex-direction:column;width:100%;min-height:100vh;min-height:100dvh;overflow:hidden;background:linear-gradient(170deg,var(--bg-0) 0%,var(--bg-1) 100%);padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(10px,env(safe-area-inset-bottom))}.app-shell:before{content:"";position:absolute;top:max(10px,env(safe-area-inset-top));left:50%;z-index:3;width:124px;height:36px;pointer-events:none;background:#000;border-radius:999px;transform:translate(-50%)}.app-shell:after{content:"";position:absolute;right:16px;bottom:max(8px,env(safe-area-inset-bottom));left:16px;z-index:3;width:140px;height:5px;margin:0 auto;pointer-events:none;background:#ffffff80;border-radius:999px}.glass{background:var(--glass-bg);border:1px solid var(--glass-border);backdrop-filter:blur(40px) saturate(180%);-webkit-backdrop-filter:blur(40px) saturate(180%)}.glass-strong{background:var(--glass-strong-bg);border:1px solid var(--glass-border-strong);backdrop-filter:blur(60px) saturate(200%);-webkit-backdrop-filter:blur(60px) saturate(200%)}.glass-subtle{background:#ffffff0a;border:1px solid rgba(255,255,255,.08);backdrop-filter:blur(30px) saturate(150%);-webkit-backdrop-filter:blur(30px) saturate(150%)}.glow{color:var(--accent);text-shadow:0 0 20px rgba(225,243,107,.3)}.topbar{z-index:4;display:flex;align-items:center;justify-content:space-between;min-height:76px;padding:38px 20px 14px}.detail-mode>.topbar{display:none}.topbar-brand{display:flex;flex-direction:column;gap:2px}.topbar-brand h1{font-size:22px;font-weight:800;line-height:1;letter-spacing:0}.topbar-brand span{color:#fff6;font-size:11px;font-weight:700;letter-spacing:.04em;text-transform:uppercase}.topbar-actions{display:flex;align-items:center;gap:10px}.icon-btn,.back-btn,.send-btn{display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px;border:0;color:#ffffffb8;transition:transform .15s ease,background .2s ease}.icon-btn{width:44px;height:44px;border-radius:12px;font-size:19px}.icon-btn:active,.session-card:active,.back-btn:active,.send-btn:active,.decision-button:active,.primary-action:active{transform:scale(.98)}.status-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0;background:#ffffff59}.status-online{background:var(--green);box-shadow:0 0 8px #32d58380}.status-connecting,.status-reconnecting,.status-replaying{background:var(--yellow);box-shadow:0 0 8px #f5c45166;animation:pulse 1.5s ease infinite}.status-offline{background:var(--red);box-shadow:0 0 8px #f9706666}@keyframes pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.42;transform:scale(.72)}}.settings-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:50;display:flex;align-items:center;justify-content:center;padding:24px;background:#0006;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px)}.settings-card{display:flex;flex-direction:column;gap:18px;width:100%;max-width:345px;border-radius:24px;padding:28px 24px;animation:slideUp .4s cubic-bezier(.16,1,.3,1)}.settings-brand{text-align:center}.settings-logo{font-size:36px;font-weight:900;line-height:1;letter-spacing:0}.settings-brand p,.settings-hint{color:#ffffff59;font-size:12px;line-height:1.5}.settings-brand p{margin-top:5px;font-weight:700;letter-spacing:.08em;text-transform:uppercase}.settings-hint{text-align:center}.settings-status{display:inline-flex;align-items:center;justify-content:center;gap:8px;color:#ffffff8c;font-size:12px;font-weight:700;text-transform:uppercase}.field{display:flex;flex-direction:column;gap:6px}.field>span{color:#ffffff80;font-size:12px;font-weight:700;letter-spacing:.06em;text-transform:uppercase}.field input,.input-bar input{width:100%;min-height:44px;border:1px solid rgba(255,255,255,.1);color:#fff;outline:none}.field input{height:48px;border-radius:12px;background:#0006;padding:0 16px;font-size:16px}.field input:focus,.input-bar input:focus{border-color:#e1f36b6b}.field input::placeholder,.input-bar input::placeholder{color:#ffffff40}.primary-action{position:relative;min-height:52px;overflow:hidden;border:0;border-radius:14px;background:var(--accent);color:var(--bg-0);font-size:16px;font-weight:800;letter-spacing:0;transition:transform .15s,box-shadow .15s}.primary-action:after,.decision-button:after,.send-btn:after{content:"";position:absolute;top:-20%;right:-20%;bottom:-20%;left:-20%;opacity:0;background:radial-gradient(circle,rgba(255,255,255,.32),transparent 58%);transform:scale(.25);transition:opacity .25s ease,transform .35s ease}.primary-action:active:after,.decision-button:active:after,.send-btn:active:after{opacity:1;transform:scale(1)}@keyframes slideUp{0%{opacity:0;transform:translateY(30px)}to{opacity:1;transform:translateY(0)}}.console-layout{position:relative;z-index:2;display:flex;flex:1;min-height:0;overflow:hidden}.session-list{display:flex;flex:1;flex-direction:column;gap:10px;min-width:0;overflow-y:auto;padding:0 16px calc(24px + env(safe-area-inset-bottom));-webkit-overflow-scrolling:touch}.detail-open .session-list{display:none}.session-list-header,.session-card-top,.session-meta,.approval-header,.session-header{display:flex;align-items:center}.session-list-header{justify-content:space-between;padding:4px 4px 12px}.session-list-header h2{color:#ffffff9e;font-size:15px;font-weight:700}.count-badge{min-width:28px;border-radius:8px;padding:3px 10px;background:#ffffff14;color:#ffffff85;font-size:12px;font-weight:800;text-align:center}.session-items{display:grid;gap:10px}.session-card{position:relative;display:flex;flex-direction:column;gap:10px;width:100%;min-height:82px;overflow:hidden;border-radius:16px;padding:16px;color:inherit;text-align:left;transition:transform .2s cubic-bezier(.16,1,.3,1),border-color .2s,background .2s,box-shadow .2s}.session-card.active{border-color:#e1f36b4d;background:#e1f36b0f;box-shadow:0 0 20px #e1f36b14}.session-card-top{justify-content:space-between;gap:12px}.session-name,.session-id{min-width:0;overflow:hidden;color:#fff;font-size:16px;font-weight:800;letter-spacing:0;text-overflow:ellipsis;white-space:nowrap}.approval-badge{min-width:24px;border-radius:8px;padding:3px 8px;background:var(--red);color:#fff;font-size:11px;font-weight:800;text-align:center;box-shadow:0 0 10px #f970664d}.session-meta{gap:8px}.cli-badge{border-radius:6px;padding:3px 8px;background:#ffffff14;color:#fff9;font-size:11px;font-weight:800;letter-spacing:.04em;text-transform:uppercase}.status-text{display:flex;align-items:center;gap:5px;color:#ffffff80;font-size:12px;font-weight:700}.status-text:before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor;flex-shrink:0}.status-running{color:var(--green)}.status-waiting_approval,.status-starting{color:var(--yellow)}.status-exited,.status-error{color:var(--red)}.status-running:before{animation:pulse 2s ease infinite}.active-session{display:none}.detail-open .active-session{display:flex}.session-view{position:relative;flex:1;flex-direction:column;min-width:0;overflow:hidden}.empty-active{display:none}.session-header{flex-shrink:0;gap:12px;min-height:76px;padding:max(38px,calc(env(safe-area-inset-top) + 24px)) 16px 12px}.back-btn{width:44px;height:44px;border-radius:12px;background:#ffffff0f;color:var(--accent);font-size:34px;line-height:1}.session-header-info{flex:1;min-width:0}.session-header-info h2{overflow:hidden;color:#fff;font-size:17px;font-weight:800;letter-spacing:0;text-overflow:ellipsis;white-space:nowrap}.session-header-info .sub{display:flex;align-items:center;gap:6px;margin-top:4px;color:#fff6;font-size:11px}.connection-badge{flex-shrink:0;border-radius:8px;padding:5px 10px;font-size:11px;font-weight:800}.state-online{background:#32d58326;color:var(--green)}.state-connecting,.state-reconnecting,.state-replaying{background:#f5c45126;color:var(--yellow);animation:badgePulse 1.5s ease infinite}.state-offline{background:#f9706626;color:var(--red)}@keyframes badgePulse{50%{opacity:.58}}.terminal{flex:1;min-height:0;margin:0 12px;overflow-y:auto;border:0;border-radius:12px;background:var(--terminal);color:#dce3e7;padding:14px;font-family:SF Mono,Fira Code,JetBrains Mono,Cascadia Code,monospace;font-size:12.5px;line-height:1.65;-webkit-overflow-scrolling:touch}.terminal.dimmed{opacity:.3}.terminal-empty{color:#ffffff52}.terminal-line{overflow-x:auto;color:#dce3e7;white-space:pre-wrap;word-break:break-word}.stream-stderr{color:#ffb4a8}.stream-user{color:#9ee8d8}.xterm-container{flex:1;min-height:0;margin:0 12px;overflow:hidden;border-radius:12px;background:var(--terminal)}.xterm-container .xterm{height:100%;padding:8px 0}.xterm-container .xterm-helper-textarea{pointer-events:none!important;opacity:0!important;position:absolute!important;left:-9999px!important}.input-bar{display:flex;flex-shrink:0;gap:8px;padding:10px 12px calc(14px + env(safe-area-inset-bottom))}.input-bar input{flex:1;height:44px;border-radius:12px;background:#ffffff0f;padding:0 16px;font-size:16px;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px)}.send-btn{position:relative;width:44px;height:44px;overflow:hidden;border-radius:12px;background:var(--accent);color:var(--bg-0);font-size:30px;font-weight:900}.approval-overlay{position:absolute;top:0;right:0;bottom:0;left:0;z-index:40;display:flex;flex-direction:column;justify-content:flex-start;padding:80px 16px 16px;background:#00000080;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);animation:fadeIn .2s ease}.approval-card{display:flex;flex-direction:column;gap:14px;border-radius:20px;padding:22px 20px;box-shadow:0 20px 60px #0006;animation:bounceIn .5s cubic-bezier(.16,1,.3,1)}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes bounceIn{0%{opacity:0;transform:translateY(-40px) scale(.95)}60%{transform:translateY(6px) scale(1.01)}to{opacity:1;transform:translateY(0) scale(1)}}.approval-header{justify-content:space-between;gap:12px}.approval-header h3{color:#fff;font-size:17px;font-weight:800;letter-spacing:0}.risk-pill{flex-shrink:0;border-radius:8px;padding:4px 10px;font-size:11px;font-weight:800;letter-spacing:.04em;text-transform:uppercase}.risk-pill.low{background:#32d58326;color:var(--green)}.risk-pill.medium{background:#f5c45126;color:var(--yellow)}.risk-pill.high{background:#f9706626;color:var(--red)}.risk-pill.unknown{background:#ffffff14;color:#fff9}.approval-description,.approval-desc{color:#ffffffb3;font-size:14px;line-height:1.5}.raw-prompt{display:grid;gap:10px}.text-button,.raw-toggle{min-height:44px;border:0;background:transparent;color:var(--accent);padding:0;font-size:13px;font-weight:800;text-align:left}.raw-content{overflow-x:auto;border:1px solid rgba(255,255,255,.06);border-radius:10px;background:#0006;color:#fff9;padding:12px;font-family:SF Mono,Fira Code,monospace;font-size:12px;line-height:1.5;white-space:pre-wrap;word-break:break-word}.approval-actions{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:4px}.decision-button{position:relative;min-height:50px;overflow:hidden;border-radius:14px;font-size:15px;font-weight:800;transition:transform .15s ease}.decision-button:disabled{cursor:default;opacity:.58;transform:none}.btn-approve,.decision-button.approve{border:1px solid rgba(50,213,131,.3);background:#2c6948;color:#fff}.btn-deny,.decision-button.deny{border:1px solid rgba(249,112,102,.2);background:#ffffff14;color:var(--red)}.empty-state,.empty-active{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:40px;color:#ffffff59;text-align:center}.empty-icon{display:flex;align-items:center;justify-content:center;width:56px;height:56px;border-radius:16px;background:#ffffff0f;color:var(--accent);font-family:SF Mono,Fira Code,monospace;font-size:22px;font-weight:900}.empty-state h3,.empty-active h3{color:#ffffff8c;font-size:16px;font-weight:800}.empty-state p,.empty-active p{color:#ffffff52;font-size:13px;line-height:1.5}::-webkit-scrollbar{width:4px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#ffffff1a;border-radius:4px}@media (min-width: 1200px){body{display:grid;min-height:100vh;place-items:center;padding:24px;background:#111}.app-shell{width:393px;height:min(852px,calc(100vh - 48px));min-height:720px;border:12px solid #000;border-radius:60px;box-shadow:0 0 0 2px #1f2937,0 30px 80px #00000080}}
