/**
 * 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}*{box-sizing:border-box;margin:0;padding:0}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;-webkit-tap-highlight-color:transparent;overscroll-behavior:none}.app-layout{display:flex;flex-direction:column;height:100vh;height:100dvh}.top-bar{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;background:#1a1a2e;color:#fff;flex-shrink:0;font-size:14px}.top-bar button{padding:4px 10px;font-size:13px;border:1px solid #555;background:transparent;color:#ccc;border-radius:4px;cursor:pointer}.top-bar button:hover{background:#333;color:#fff}.top-menu-btn{display:none;font-size:18px;padding:4px 8px!important;border:none!important}.top-title{font-size:14px;font-weight:600}.sidebar-header{display:flex;justify-content:space-between;align-items:flex-start;padding:10px 8px 6px;border-bottom:1px solid #ddd;margin-bottom:6px}.sidebar-title{font-size:14px;font-weight:700;color:#1a1a2e}.sidebar-phone{font-size:11px;color:#999;margin-top:2px}.sidebar-logout-btn{font-size:11px;padding:4px 10px;border:1px solid #ccc;background:#fff;border-radius:4px;cursor:pointer;color:#c00}.sidebar-logout-btn:hover{background:#fee}padding: 4px 10px; font-size: 13px; border: 1px solid #555; background: transparent; color: #ccc; border-radius: 4px; cursor: pointer; } .top-bar button:hover{background:#333;color:#fff}.main-area{display:flex;flex:1;overflow:hidden}.sidebar-panel{width:260px;min-width:200px;flex-shrink:0;overflow-y:auto;-webkit-overflow-scrolling:touch;border-right:1px solid #ddd;background:#f5f5f5}.server-tree{padding:8px}.server-tree-header{display:flex;justify-content:space-between;align-items:center;padding:4px 0;margin-bottom:4px}.server-tree-header h3{font-size:14px}.server-item{display:flex;align-items:center;gap:6px;padding:6px 8px;cursor:pointer;border-radius:6px;font-size:13px;min-height:36px}.server-item:hover{background:#e8e8e8}.server-item:active{background:#ddd}.status-dot{width:8px;height:8px;border-radius:50%;display:inline-block;flex-shrink:0}.status-dot.online{background:#4caf50;box-shadow:0 0 4px #4caf5080}.status-dot.offline{background:#ccc}.server-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.server-delete-btn{font-size:11px;padding:2px 6px;border:1px solid #ccc;background:#fff;border-radius:3px;cursor:pointer;color:#c00;flex-shrink:0}.server-delete-btn:hover{background:#fee}.session-list{padding-left:20px;list-style:none}.session-item{display:flex;align-items:center;justify-content:space-between;padding:6px 8px;cursor:pointer;border-radius:6px;font-size:13px;min-height:36px}.session-item:hover{background:#ddd}.session-item:active{background:#ccc}.session-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.session-actions{flex-shrink:0;margin-left:4px}.session-kill-btn{font-size:11px;padding:2px 8px;border:1px solid #ccc;background:#fff;border-radius:4px;cursor:pointer;color:#c00;min-height:28px}.session-kill-btn:hover{background:#fee}.session-placeholder{padding:6px 8px;font-size:12px;color:#999;font-style:italic}.create-session-btn{width:100%;margin-top:4px;padding:6px;font-size:12px;border:1px dashed #aaa;background:transparent;border-radius:6px;cursor:pointer;color:#555;min-height:32px}.create-session-btn:hover{background:#e8e8e8;border-color:#888}.add-server-btn{width:100%;margin-top:8px;padding:8px;font-size:13px;border:1px solid #ccc;background:#fff;border-radius:6px;cursor:pointer;min-height:36px}.add-server-btn:hover{background:#e8e8e8}.terminal-area{flex:1;display:flex;flex-direction:column;min-width:0}.terminal-tabs{display:flex;background:#2d2d2d;padding:4px 4px 0;gap:2px;overflow-x:auto;flex-shrink:0;-webkit-overflow-scrolling:touch}.terminal-tabs::-webkit-scrollbar{height:2px}.terminal-tab{padding:6px 10px;background:#1a1a2e;color:#ccc;border-radius:4px 4px 0 0;cursor:pointer;font-size:12px;display:flex;align-items:center;gap:6px;white-space:nowrap;flex-shrink:0;min-height:30px}.terminal-tab.active{background:#1e1e1e;color:#fff}.terminal-tab .close-btn{cursor:pointer;color:#888;font-size:16px;line-height:1;width:20px;height:20px;display:flex;align-items:center;justify-content:center}.terminal-tab .close-btn:active{color:#f44}.tab-status-dot{width:6px;height:6px;border-radius:50%;display:inline-block;flex-shrink:0}.tab-status-dot.tab-status-connected{background:#4caf50}.tab-status-dot.tab-status-connecting{background:#ff9800;animation:pulse 1s infinite}.tab-status-dot.tab-status-disconnected{background:#f44336}@keyframes pulse{0%,to{opacity:1}50%{opacity:.4}}.terminal-container{flex:1;background:#1e1e1e;min-height:0;overflow:hidden}.terminal-container .xterm{height:100%;padding:0}.terminal-container .xterm-viewport{overflow-y:auto!important;-webkit-overflow-scrolling:touch;overscroll-behavior:contain}.dialog-overlay{position:fixed;top:0;left:0;right:0;bottom:0;z-index:100;background:#00000080;display:flex;align-items:center;justify-content:center;padding:16px}.dialog{background:#fff;padding:20px;border-radius:10px;width:100%;max-width:380px;max-height:90vh;overflow-y:auto}.dialog h3{font-size:16px;margin-bottom:12px}.dialog input{width:100%;padding:10px;margin:6px 0;border:1px solid #ddd;border-radius:6px;font-size:15px}.dialog button{margin:4px;padding:10px 18px;font-size:14px;border:none;border-radius:6px;cursor:pointer;min-height:40px}.dialog button:active{opacity:.8}.dialog .btn-primary{background:#1a73e8;color:#fff}.dialog .btn-secondary{background:#eee;color:#333}.dialog .btn-danger{background:#e53935;color:#fff}.dialog .btn-group{display:flex;justify-content:flex-end;gap:6px;margin-top:12px}.sidebar-close-btn{display:none;position:absolute;top:8px;right:8px;width:32px;height:32px;border-radius:50%;border:none;background:#eee;color:#555;font-size:14px;cursor:pointer;z-index:1;align-items:center;justify-content:center}.sidebar-close-btn:active{background:#ddd}.sidebar-toggle{display:none;position:fixed;bottom:16px;right:16px;z-index:61;width:48px;height:48px;border-radius:50%;background:#1a73e8;color:#fff;border:none;font-size:20px;cursor:pointer;box-shadow:0 2px 8px #0000004d;align-items:center;justify-content:center;transition:transform .15s ease,background .15s ease}.sidebar-toggle:active{background:#1557b0;transform:scale(.95)}.server-detail{padding:12px;border-bottom:1px solid #e0e0e0;background:#fafafa;animation:slideDown .15s ease}@keyframes slideDown{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}.server-detail-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}.server-detail-header h3{font-size:15px;margin:0}.server-detail-status{display:flex;align-items:center;gap:6px;font-size:13px;font-weight:600;margin-bottom:10px}.server-detail-status.online{color:#2e7d32}.server-detail-status.offline{color:#999}.status-dot-lg{width:10px;height:10px;border-radius:50%;display:inline-block}.server-detail-status.online .status-dot-lg{background:#4caf50;box-shadow:0 0 6px #4caf5080}.server-detail-status.offline .status-dot-lg{background:#ccc}.server-detail-table{width:100%;font-size:12px;border-collapse:collapse}.server-detail-table td{padding:3px 6px}.server-detail-table td:first-child{color:#888;white-space:nowrap;width:80px}.server-detail-table code{font-size:11px;background:#eee;padding:1px 4px;border-radius:3px}.server-detail-actions{margin-top:10px;display:flex;gap:6px}.badge{font-size:11px;padding:2px 8px;border-radius:10px;display:inline-flex;align-items:center;gap:4px}.badge-online{background:#e8f5e9;color:#2e7d32}.badge-offline{background:#f5f5f5;color:#999}.muted{color:#999}.server-item{display:flex;align-items:center;gap:6px;padding:6px 8px;cursor:pointer;border-radius:6px;font-size:13px;min-height:36px;-webkit-user-select:none;user-select:none}.server-item.selected{background:#e3f2fd;font-weight:600}.server-info{flex:1;overflow:hidden}.server-info-name{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.server-info-meta{font-size:10px;color:#999;margin-top:1px}.session-expand-toggle{cursor:pointer;font-size:10px;width:16px;display:inline-block;flex-shrink:0;-webkit-user-select:none;user-select:none;text-align:center}.window-list{padding-left:26px;list-style:none;margin-bottom:4px}.window-item{display:flex;align-items:center;gap:4px;padding:3px 4px;font-size:12px;color:#555}.window-status{font-size:8px}.window-status.active{color:#4caf50}.window-status:not(.active){color:#ccc}.window-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.windows-loading,.windows-empty{padding-left:26px;font-size:11px;color:#999;font-style:italic}.empty-state{flex:1;display:flex;align-items:center;justify-content:center;color:#888;font-size:14px;padding:24px;text-align:center}.login-container{max-width:380px;margin:60px auto;padding:24px}.login-container h1{font-size:20px;margin-bottom:16px}.login-container input{display:block;width:100%;padding:10px;margin-bottom:8px;border:1px solid #ddd;border-radius:6px;font-size:15px}.login-container button{padding:10px 18px;font-size:14px;border:none;border-radius:6px;cursor:pointer;min-height:40px;margin-right:6px;margin-bottom:6px}.login-container button:active{opacity:.8}.login-mode-tabs{display:flex;gap:0;margin-bottom:14px}.login-mode-tabs button{flex:1;padding:8px;font-size:13px;border:1px solid #ddd;background:#f5f5f5;color:#666;border-radius:0;margin:0}.login-mode-tabs button:first-child{border-radius:6px 0 0 6px}.login-mode-tabs button:last-child{border-radius:0 6px 6px 0}.login-mode-tabs button.active-mode{background:#1a73e8;color:#fff;border-color:#1a73e8}@media(max-width:768px){.main-area{position:relative}.sidebar-panel{position:fixed;top:0;left:0;bottom:0;z-index:60;width:280px;max-width:85vw;transform:translate(-100%);transition:transform .2s ease;box-shadow:2px 0 12px #0003}.sidebar-panel.open{transform:translate(0)}.sidebar-panel .server-tree{padding-top:12px}.sidebar-backdrop{display:none;position:fixed;top:0;left:0;right:0;bottom:0;z-index:59;background:#0006}.sidebar-backdrop.open{display:block}.sidebar-toggle,.sidebar-close-btn{display:flex}.top-menu-btn{display:block}.server-item,.session-item{padding:8px 10px;min-height:42px;font-size:14px}.session-kill-btn{padding:4px 10px;min-height:32px;font-size:12px}.create-session-btn{min-height:38px}.add-server-btn{min-height:42px}.terminal-tab{padding:8px 12px;font-size:13px;min-height:34px}.top-bar{display:none}.dialog{max-width:100%;margin:0;border-radius:12px 12px 0 0}.dialog-overlay{align-items:flex-end}.login-container{margin:20px auto;padding:16px}}.kb-toggle{position:absolute;top:4px;right:8px;z-index:10;width:36px;height:28px;padding:0;font-size:16px;border:1px solid #555;border-radius:4px;background:#252525d9;color:#aaa;cursor:pointer;display:flex;align-items:center;justify-content:center;-webkit-tap-highlight-color:transparent}.kb-toggle:active{background:#555;color:#fff}.kb-keyboard{position:absolute;bottom:0;left:0;right:0;z-index:5;padding:2px;background:#1e1e1ef2;border-top:1px solid #444;display:flex;flex-direction:column;gap:2px}.kb-row{display:flex;gap:2px;justify-content:center}.kb-key{min-width:22px;height:28px;padding:0 3px;font-size:10px;font-family:monospace;border:1px solid #444;border-radius:3px;background:#2a2a2a;color:#ccc;cursor:pointer;display:flex;align-items:center;justify-content:center;-webkit-tap-highlight-color:transparent;user-select:none;-webkit-user-select:none;transition:background .05s}.kb-key:active{background:#555;color:#fff}.kb-key.kb-wide{min-width:40px}.kb-key.kb-accent{background:#3a3a3a;color:#ff9800;border-color:#555}.kb-key.kb-accent:active{background:#555}.terminal-container .xterm-viewport{overflow-y:auto!important}@media(max-width:768px){.kb-key{min-width:26px;height:34px;font-size:11px}.kb-key.kb-wide{min-width:46px}.kb-toggle{width:40px;height:32px;top:6px;right:6px}}@media(max-width:400px){.top-bar{font-size:12px;padding:6px 8px}.terminal-tab{padding:6px 8px;font-size:11px}.terminal-tab .close-btn{width:18px;height:18px}}
