/* WebTerminal — Modern UX with cyberpunk theming */

:root {
    --primary-color: #00f0ff;
    --bg-color: #0a0e27;
    --bg-darker: #050814;
    --text-color: #e0e0e0;
    --text-secondary: #888;
    --danger: #ff4444;
    --success: #00ff88;
    --warning: #ffb000;
    --border-radius: 6px;
    --sidebar-width: 260px;
    --activity-bar-width: 40px;
    --header-height: 36px;
    --status-height: 24px;
}

/* === App Themes === */
body[data-theme="modern-dark"]  { --primary-color: #4da6ff; --bg-color: #1e1e1e; --bg-darker: #121212; font-family: 'Inter', sans-serif; }
body[data-theme="modern-light"] { --primary-color: #0066cc; --bg-color: #ffffff; --bg-darker: #f5f5f5; --text-color: #1a1a1a; --text-secondary: #666; font-family: 'Inter', sans-serif; }
body[data-theme="steampunk"]    { --primary-color: #d4a574; --bg-color: #2b1810; --bg-darker: #1a0f0a; font-family: 'Special Elite', cursive; }
body[data-theme="glass"]        { --primary-color: #ffffff; --bg-color: rgba(255,255,255,0.1); --bg-darker: rgba(10,20,40,0.9); font-family: 'Inter', sans-serif; }
body[data-theme="industrial"]   { --primary-color: #ff6600; --bg-color: #1a1a1a; --bg-darker: #0d0d0d; font-family: 'Roboto Mono', monospace; }
body[data-theme="scifi"]        { --primary-color: #00ff88; --bg-color: #0a1a2a; --bg-darker: #050d14; font-family: 'Share Tech Mono', monospace; }
body[data-theme="matrix"]       { --primary-color: #00ff41; --bg-color: #000; --bg-darker: #000; font-family: 'VT323', monospace; }
body[data-theme="neon-purple"]  { --primary-color: #ff00ff; --bg-color: #1a0033; --bg-darker: #0d001a; font-family: 'Audiowide', sans-serif; }
body[data-theme="amber"]        { --primary-color: #ffb000; --bg-color: #1a0f00; --bg-darker: #0d0800; font-family: 'VT323', monospace; }
body[data-theme="ice-blue"]     { --primary-color: #b3e0ff; --bg-color: #001a2a; --bg-darker: #000d1a; font-family: 'Exo 2', sans-serif; }
body[data-theme="blood-red"]    { --primary-color: #ff0033; --bg-color: #1a0000; --bg-darker: #0d0000; font-family: 'Nosifer', cursive; }
body[data-theme="ocean"]        { --primary-color: #00d4ff; --bg-color: #0a1a2a; --bg-darker: #050d14; font-family: 'Quicksand', sans-serif; }
body[data-theme="dracula"]      { --primary-color: #bd93f9; --bg-color: #282a36; --bg-darker: #1e1f29; font-family: 'Fira Code', monospace; }
body[data-theme="solarized"]    { --primary-color: #b58900; --bg-color: #002b36; --bg-darker: #001f27; font-family: 'Source Sans 3', sans-serif; }
body[data-theme="nord"]         { --primary-color: #88c0d0; --bg-color: #2e3440; --bg-darker: #242831; font-family: 'Inter', sans-serif; }
body[data-theme="tokyo-night"]  { --primary-color: #7aa2f7; --bg-color: #1a1b26; --bg-darker: #13141f; font-family: 'Inter', sans-serif; }
body[data-theme="catppuccin"]   { --primary-color: #89b4fa; --bg-color: #1e1e2e; --bg-darker: #181825; font-family: 'Inter', sans-serif; }
body[data-theme="monokai"]      { --primary-color: #a6e22e; --bg-color: #272822; --bg-darker: #1e1e1b; font-family: 'Fira Code', monospace; }
body[data-theme="gruvbox"]      { --primary-color: #fabd2f; --bg-color: #282828; --bg-darker: #1d2021; font-family: 'Inter', sans-serif; }
body[data-theme="one-dark"]     { --primary-color: #61afef; --bg-color: #282c34; --bg-darker: #21252b; font-family: 'Inter', sans-serif; }
body[data-theme="github-dark"]  { --primary-color: #388bfd; --bg-color: #0d1117; --bg-darker: #010409; font-family: 'Inter', sans-serif; }
body[data-theme="cobalt"]       { --primary-color: #ffc600; --bg-color: #193549; --bg-darker: #0d2535; font-family: 'Roboto Mono', monospace; }
body[data-theme="palenight"]    { --primary-color: #82aaff; --bg-color: #292d3e; --bg-darker: #1e2132; font-family: 'Inter', sans-serif; }
body[data-theme="night-owl"]    { --primary-color: #7fdbca; --bg-color: #011627; --bg-darker: #010e1a; font-family: 'Fira Code', monospace; }

/* Per-theme title fonts (decorative fonts only for logos/titles) */
body[data-theme="future"] .header-logo,
body[data-theme="future"] .welcome-title,
body[data-theme="future"] .login-title { font-family: 'Orbitron', sans-serif; }

body[data-theme="blood-red"] .header-logo,
body[data-theme="blood-red"] .welcome-title,
body[data-theme="blood-red"] .login-title { font-family: 'Nosifer', cursive; }

body[data-theme="neon-purple"] .login-title,
body[data-theme="neon-purple"] .welcome-title { font-family: 'Audiowide', sans-serif; }

* { margin: 0; padding: 0; box-sizing: border-box; }
button, input, select, textarea { font-family: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

body {
    font-family: 'Rajdhani', 'Exo 2', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-darker); color: var(--text-color);
    height: 100vh; overflow: hidden;
}

/* === Login === */
.login-screen {
    display: flex; align-items: center; justify-content: center;
    height: 100vh; background: var(--bg-darker);
}
.login-box {
    background: var(--bg-color); border: 1px solid var(--primary-color);
    border-radius: var(--border-radius); padding: 2.5rem; width: 340px;
    box-shadow: 0 0 30px rgba(0,240,255,0.15);
}
.login-title {
    color: var(--primary-color); font-size: 1.8rem; text-align: center;
    margin-bottom: 0.25rem; text-shadow: 0 0 10px var(--primary-color);
}
.login-subtitle { color: var(--text-secondary); text-align: center; margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-box input {
    width: 100%; padding: 0.6rem 0.8rem; margin-bottom: 0.75rem;
    background: var(--bg-darker); border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px; color: var(--text-color); font-size: 0.95rem;
}
.login-box input:focus { outline: 2px solid var(--primary-color); outline-offset: -2px; border-color: var(--primary-color); }
.login-box button {
    width: 100%; padding: 0.65rem; background: transparent;
    border: 1px solid var(--primary-color); color: var(--primary-color);
    font-size: 1rem; cursor: pointer; border-radius: 4px; transition: all 0.2s; margin-top: 0.5rem;
}
.login-box button:hover { background: var(--primary-color); color: var(--bg-darker); }
.login-error { color: var(--danger); text-align: center; margin-top: 0.75rem; font-size: 0.85rem; min-height: 1.2em; }

/* === App layout === */
.app-container { display: flex; flex-direction: column; height: 100vh; }

/* === Header (slim) === */
.header {
    display: flex; align-items: center; height: var(--header-height);
    padding: 0 0.5rem; background: var(--bg-color);
    border-bottom: 1px solid var(--primary-color); z-index: 600; gap: 0.5rem;
}
.header-left { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.header-logo { color: var(--primary-color); font-size: 1rem; text-shadow: 0 0 6px var(--primary-color); }
.header-workspace {
    font-size: 0.75rem; color: var(--text-secondary); max-width: 150px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-right { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }
.header-btn {
    background: none; border: 1px solid rgba(255,255,255,0.15);
    color: var(--primary-color); padding: 0.15rem 0.45rem; cursor: pointer;
    border-radius: 3px; font-size: 0.8rem; line-height: 1;
}
.header-btn:hover { background: var(--primary-color); color: var(--bg-darker); }
.header-btn:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 1px; }

/* === Tab bar === */
.tab-bar {
    flex: 1; display: flex; align-items: center; gap: 2px;
    overflow-x: auto; scrollbar-width: none; min-width: 0;
}
.tab-bar::-webkit-scrollbar { display: none; }
.term-tab {
    display: flex; align-items: center; gap: 4px;
    padding: 0.15rem 0.5rem; background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08); border-radius: 3px;
    color: var(--text-secondary); font-size: 0.72rem; cursor: pointer;
    white-space: nowrap; flex-shrink: 0; transition: all 0.1s;
}
.term-tab:hover { background: rgba(255,255,255,0.06); color: var(--text-color); }
.term-tab.active { background: rgba(255,255,255,0.08); color: var(--primary-color); border-color: var(--primary-color); box-shadow: 0 0 6px rgba(0,240,255,0.15); }
.term-tab .tab-close {
    background: none; border: none; color: inherit; cursor: pointer;
    font-size: 0.65rem; opacity: 0; padding: 0 2px; line-height: 1;
}
.term-tab:hover .tab-close, .term-tab.active .tab-close { opacity: 0.6; }
.term-tab .tab-close:hover { opacity: 1; color: var(--danger); }

/* === Main content === */
.main-content { flex: 1; display: flex; overflow: hidden; position: relative; }

/* === Activity bar === */
.activity-bar {
    width: var(--activity-bar-width); background: var(--bg-color);
    border-right: 1px solid rgba(255,255,255,0.08);
    display: flex; flex-direction: column; align-items: center;
    padding: 0.3rem 0; gap: 2px; flex-shrink: 0;
}
.activity-btn {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; border-radius: 4px;
    color: var(--text-secondary); cursor: pointer; font-size: 0.9rem;
    transition: all 0.1s; position: relative;
}
.activity-btn:hover { color: var(--primary-color); background: rgba(255,255,255,0.05); }
.activity-btn.active { color: var(--primary-color); }
.activity-btn.active::before {
    content: ''; position: absolute; left: -1px; top: 4px; bottom: 4px;
    width: 2px; background: var(--primary-color); border-radius: 1px;
}
.activity-btn:focus-visible { outline: 2px solid var(--primary-color); outline-offset: -2px; }
.activity-spacer { flex: 1; }

/* === Side panel === */
.side-panel {
    width: var(--sidebar-width); min-width: 180px; max-width: 500px;
    background: var(--bg-color); border-right: 1px solid rgba(255,255,255,0.08);
    display: flex; flex-direction: column; overflow: hidden; position: relative;
}
.side-panel-resize {
    position: absolute; top: 0; right: -3px; width: 6px; height: 100%;
    cursor: col-resize; z-index: 10;
}
.side-panel-resize:hover, .side-panel-resize.dragging { background: var(--primary-color); opacity: 0.4; }
.panel-content { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.4rem 0.6rem; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.panel-title { font-size: 0.78rem; color: var(--primary-color); text-transform: uppercase; letter-spacing: 0.5px; }
.panel-btn {
    background: none; border: 1px solid rgba(255,255,255,0.12);
    color: var(--primary-color); cursor: pointer; border-radius: 3px;
    padding: 0.1rem 0.35rem; font-size: 0.75rem;
}
.panel-btn:hover { background: rgba(255,255,255,0.06); }
.panel-btn:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 1px; }
.panel-filter {
    padding: 0.3rem 0.4rem; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.panel-filter input {
    width: 100%; padding: 0.25rem 0.4rem; background: var(--bg-darker);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 3px;
    color: var(--text-color); font-size: 0.75rem;
}
.panel-filter input:focus { outline: none; border-color: var(--primary-color); }

/* === Breadcrumb === */
.breadcrumb {
    padding: 0.2rem 0.4rem; overflow-x: auto; white-space: nowrap;
    font-size: 0.7rem; color: var(--text-secondary); scrollbar-width: none;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.breadcrumb::-webkit-scrollbar { display: none; }
.breadcrumb-seg { cursor: pointer; color: var(--text-secondary); }
.breadcrumb-seg:hover { color: var(--primary-color); }
.breadcrumb-seg.active { color: var(--text-color); cursor: default; }
.breadcrumb-sep { color: rgba(255,255,255,0.2); margin: 0 2px; }

/* === File tree === */
.file-tree { flex: 1; overflow-y: auto; padding: 0.15rem 0; }
.tree-item {
    display: flex; align-items: center; padding: 0.18rem 0.4rem;
    cursor: pointer; font-size: 0.78rem; white-space: nowrap;
}
.tree-item:hover { background: rgba(255,255,255,0.04); }
.tree-indent { flex-shrink: 0; }
.tree-arrow { width: 14px; text-align: center; font-size: 0.55rem; color: var(--text-secondary); flex-shrink: 0; }
.tree-arrow-spacer { width: 14px; flex-shrink: 0; }
.file-icon { margin-right: 4px; font-size: 0.75rem; flex-shrink: 0; }
.file-name { overflow: hidden; text-overflow: ellipsis; }
.tree-item.directory .file-name { color: var(--primary-color); }
.tree-item.file .file-name { color: var(--text-color); }
.tree-empty { padding: 1rem; color: var(--text-secondary); font-size: 0.78rem; text-align: center; }

/* === Context menu === */
.context-menu {
    position: fixed; background: var(--bg-color); border: 1px solid var(--primary-color);
    border-radius: 4px; z-index: 1000; min-width: 160px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.ctx-item {
    padding: 0.35rem 0.75rem; font-size: 0.78rem; cursor: pointer; color: var(--text-color);
}
.ctx-item:hover { background: rgba(255,255,255,0.06); color: var(--primary-color); }

/* === Settings panel === */
.settings-section { padding: 0.5rem 0.6rem; border-bottom: 1px solid rgba(255,255,255,0.06); }
.settings-heading { font-size: 0.7rem; color: var(--primary-color); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.4rem; font-weight: 500; }
.settings-label { display: block; font-size: 0.72rem; color: var(--text-secondary); margin: 0.3rem 0 0.15rem; }
.settings-section select, .settings-section input[type="text"] {
    width: 100%; padding: 0.3rem 0.4rem; background: var(--bg-darker);
    border: 1px solid rgba(255,255,255,0.12); border-radius: 3px;
    color: var(--text-color); font-size: 0.75rem;
}
.settings-section select:focus, .settings-section input:focus { outline: none; border-color: var(--primary-color); }
.settings-row { display: flex; gap: 4px; align-items: center; }
.settings-row input[type="text"] { flex: 1; }
.settings-btn {
    padding: 0.25rem 0.5rem; background: none; border: 1px solid rgba(255,255,255,0.15);
    color: var(--primary-color); border-radius: 3px; cursor: pointer; font-size: 0.75rem;
}
.settings-btn:hover { background: rgba(255,255,255,0.06); }
.settings-value { font-size: 0.75rem; color: var(--text-color); min-width: 36px; text-align: center; }
.settings-action-btn {
    width: 100%; padding: 0.3rem 0.5rem; background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 4px;
    color: var(--text-color); cursor: pointer; font-size: 0.75rem;
    text-align: left; margin-bottom: 4px;
}
.settings-action-btn:hover { background: rgba(255,255,255,0.06); color: var(--primary-color); border-color: var(--primary-color); }
.shortcuts-table { display: flex; flex-direction: column; gap: 2px; }
.shortcut-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.72rem; padding: 0.15rem 0; }
.shortcut-row span { color: var(--text-color); }
.shortcut-row kbd {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 3px; padding: 0.05rem 0.35rem; font-size: 0.65rem;
    color: var(--text-secondary); font-family: inherit;
}
.workspace-list { max-height: none; overflow-y: auto; margin-top: 0.3rem; flex: 1; }
.workspace-item {
    padding: 0.3rem 0.4rem; cursor: pointer; font-size: 0.72rem; border-radius: 3px;
}
.workspace-item:hover { background: rgba(255,255,255,0.04); }
.workspace-item.active { color: var(--primary-color); background: rgba(255,255,255,0.06); }
.ws-name { font-weight: 500; }
.ws-path { font-size: 0.65rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-section-label { font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; padding: 0.5rem 0.35rem 0.15rem; }

/* === Quick launch === */
.quick-launch {
    display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 0.35rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.quick-launch button {
    padding: 0.25rem 0.35rem; background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 3px;
    color: var(--primary-color); cursor: pointer; font-size: 0.72rem;
}
.quick-launch button:hover { background: var(--primary-color); color: var(--bg-darker); }

/* === Profiles === */
.profiles-list { flex: 1; overflow-y: auto; padding: 0.15rem 0; }
.profile-entry {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.35rem 0.5rem; cursor: pointer; font-size: 0.78rem;
}
.profile-entry:hover { background: rgba(255,255,255,0.04); }
.profile-info { flex: 1; overflow: hidden; }
.pname { color: var(--text-color); font-weight: 500; }
.pdetail { color: var(--text-secondary); font-size: 0.68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcmd { color: var(--primary-color); font-size: 0.62rem; font-family: 'Fira Code', monospace; opacity: 0.7; }
.profile-badges { display: flex; gap: 3px; margin-top: 2px; }
.badge { font-size: 0.58rem; padding: 0 4px; border-radius: 2px; background: rgba(255,255,255,0.06); color: var(--text-secondary); }
.badge.auto { color: var(--success); background: rgba(0,255,136,0.1); }
.profile-actions { display: flex; gap: 4px; flex-shrink: 0; }
.profile-actions button { background: none; border: none; cursor: pointer; font-size: 0.72rem; opacity: 0.4; }
.profile-actions button:hover { opacity: 1; }
.profile-form { padding: 0.4rem; border-top: 1px solid rgba(255,255,255,0.08); display: flex; flex-direction: column; gap: 0.3rem; }
.profile-form input, .profile-form select {
    padding: 0.3rem 0.4rem; background: var(--bg-darker);
    border: 1px solid rgba(255,255,255,0.12); border-radius: 3px;
    color: var(--text-color); font-size: 0.75rem;
}
.profile-form input:focus, .profile-form select:focus { outline: none; border-color: var(--primary-color); }
.profile-row { display: flex; gap: 0.4rem; align-items: center; font-size: 0.72rem; color: var(--text-secondary); }
.profile-row label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.profile-row input[type="number"] { padding: 0.2rem 0.35rem; background: var(--bg-darker); border: 1px solid rgba(255,255,255,0.12); border-radius: 3px; color: var(--text-color); font-size: 0.72rem; }
.profile-form button {
    padding: 0.3rem; background: transparent; border: 1px solid var(--primary-color);
    color: var(--primary-color); border-radius: 3px; cursor: pointer; font-size: 0.75rem;
}
.profile-form button:hover { background: var(--primary-color); color: var(--bg-darker); }

/* === Terminals container === */
.terminals-container { flex: 1; position: relative; overflow: hidden; background: var(--bg-darker); }

/* === Welcome screen === */
.welcome-screen {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: var(--bg-darker); z-index: 1;
}
.welcome-content { text-align: center; max-width: 400px; }
.welcome-title {
    color: var(--primary-color); font-size: 2rem; margin-bottom: 1.5rem;
    text-shadow: 0 0 20px var(--primary-color);
}
.welcome-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; }
.welcome-btn {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.6rem 1rem; background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.12); border-radius: 6px;
    color: var(--text-color); cursor: pointer; font-size: 0.85rem; transition: all 0.15s;
}
.welcome-btn:hover { border-color: var(--primary-color); color: var(--primary-color); background: rgba(255,255,255,0.05); }
.welcome-btn kbd {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 3px; padding: 0.1rem 0.4rem; font-size: 0.7rem; color: var(--text-secondary);
}
.welcome-recent { margin-top: 1rem; text-align: left; }
.welcome-recent h3 { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.5px; }
.welcome-ws-item {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.5rem;
    cursor: pointer; border-radius: 4px; font-size: 0.8rem; color: var(--text-color);
}
.welcome-ws-item:hover { background: rgba(255,255,255,0.04); color: var(--primary-color); }
.welcome-ws-item .ws-icon { font-size: 0.85rem; }
.welcome-tip { color: var(--text-secondary); font-size: 0.75rem; margin-top: 1.5rem; font-style: italic; }

/* === Terminal window === */
.terminal-window {
    position: absolute; display: flex; flex-direction: column;
    background: var(--bg-darker); border: 2px solid var(--primary-color);
    border-radius: 8px; min-width: 350px; min-height: 220px;
    resize: both; overflow: hidden; pointer-events: auto;
    box-shadow: 0 0 20px rgba(0,240,255,0.12);
}
.terminal-window.focused { box-shadow: 0 0 25px rgba(0,240,255,0.3); border-color: var(--primary-color); }
.terminal-win-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.2rem 0.5rem; background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--primary-color); cursor: move; user-select: none;
}
.terminal-win-title {
    font-size: 0.72rem; color: var(--primary-color); text-transform: uppercase;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px;
}
.terminal-win-controls { display: flex; gap: 0.25rem; align-items: center; }
.terminal-win-controls button {
    background: none; border: none; color: var(--primary-color);
    cursor: pointer; font-size: 0.75rem; padding: 0.05rem 0.25rem; border-radius: 3px;
}
.terminal-win-controls button:hover { background: rgba(255,255,255,0.08); }
.terminal-win-controls select {
    background: var(--bg-darker); border: 1px solid var(--primary-color);
    color: var(--primary-color); padding: 0.05rem 0.2rem; border-radius: 3px;
    font-size: 0.65rem; cursor: pointer; max-width: 85px;
}
.terminal-xterm-container { flex: 1; overflow: hidden; }
.terminal-xterm-container .xterm { height: 100%; }
.terminal-search-bar {
    display: flex; gap: 4px; padding: 3px 6px;
    background: rgba(0,0,0,0.5); border-top: 1px solid rgba(255,255,255,0.1);
}
.terminal-search-bar input {
    flex: 1; background: var(--bg-darker); border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-color); padding: 2px 6px; font-size: 0.72rem; border-radius: 3px;
}
.terminal-search-bar input:focus { outline: none; border-color: var(--primary-color); }
.terminal-search-bar button {
    background: none; border: 1px solid rgba(255,255,255,0.08);
    color: var(--primary-color); cursor: pointer; border-radius: 3px; padding: 1px 5px; font-size: 0.62rem;
}
.terminal-search-bar button:hover { background: rgba(255,255,255,0.06); }

/* === Code viewer === */
.code-viewer {
    position: absolute; top: 0; right: 0; width: 50%; height: 100%;
    background: var(--bg-darker); border-left: 2px solid var(--primary-color);
    display: flex; flex-direction: column; z-index: 500;
}
.code-viewer-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.3rem 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 0.78rem; color: var(--primary-color);
}
.code-viewer-header button {
    background: none; border: 1px solid rgba(255,255,255,0.12);
    color: var(--primary-color); cursor: pointer; border-radius: 3px;
    padding: 0.1rem 0.35rem; font-size: 0.75rem; margin-left: 4px;
}
.code-viewer-header button:hover { background: rgba(255,255,255,0.06); }
.code-content {
    flex: 1; background: var(--bg-darker); color: var(--text-color); border: none;
    padding: 0.5rem; font-family: 'Cascadia Code','Fira Code','Consolas',monospace;
    font-size: 13px; line-height: 1.5; resize: none; tab-size: 4;
}
.code-content:focus { outline: none; }

/* === Command Palette === */
.command-palette {
    position: fixed; inset: 0; z-index: 900; display: flex;
    align-items: flex-start; justify-content: center; padding-top: 12vh;
}
.palette-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.palette-box {
    position: relative; width: 460px; max-width: 90vw;
    background: var(--bg-color); border: 1px solid var(--primary-color);
    border-radius: var(--border-radius); box-shadow: 0 0 40px rgba(0,240,255,0.15);
    overflow: hidden; animation: palette-in 0.12s ease-out;
}
@keyframes palette-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.palette-box input {
    width: 100%; padding: 0.65rem 0.9rem; background: var(--bg-darker);
    border: none; border-bottom: 1px solid rgba(255,255,255,0.08);
    color: var(--text-color); font-size: 0.9rem;
}
.palette-box input:focus { outline: none; }
.palette-section { padding: 0.2rem 0; }
.palette-section-label { padding: 0.2rem 0.75rem; font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.palette-list { max-height: 320px; overflow-y: auto; }
.palette-item {
    padding: 0.4rem 0.75rem; cursor: pointer; font-size: 0.82rem;
    color: var(--text-color); display: flex; justify-content: space-between; align-items: center;
}
.palette-item:hover, .palette-item.selected { background: rgba(255,255,255,0.06); color: var(--primary-color); }
.palette-hint { font-size: 0.65rem; color: var(--text-secondary); }
.palette-hint kbd {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 3px; padding: 0.05rem 0.3rem; font-size: 0.6rem; font-family: inherit;
}
.palette-category { font-size: 0.6rem; color: var(--text-secondary); margin-right: 0.5rem; text-transform: uppercase; }

/* === Toast === */
.toast-container {
    position: fixed; bottom: 2rem; right: 1rem; z-index: 950;
    display: flex; flex-direction: column; gap: 0.4rem;
}
.toast {
    padding: 0.45rem 0.85rem; border-radius: 4px; font-size: 0.78rem;
    animation: toast-in 0.2s ease; border: 1px solid; display: flex; align-items: center; gap: 0.5rem;
}
.toast-close { background: none; border: none; color: inherit; cursor: pointer; margin-left: auto; font-size: 1rem; opacity: 0.6; }
.toast-close:hover { opacity: 1; }
.toast.info    { background: rgba(0,240,255,0.1); border-color: var(--primary-color); color: var(--primary-color); }
.toast.success { background: rgba(0,255,136,0.1); border-color: var(--success); color: var(--success); }
.toast.error   { background: rgba(255,68,68,0.1); border-color: var(--danger); color: var(--danger); }
.toast.warning { background: rgba(255,176,0,0.1); border-color: var(--warning); color: var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* === Command History Popup === */
.history-popup {
    position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
    width: 400px; max-height: 250px; background: var(--bg-color);
    border: 1px solid var(--primary-color); border-radius: var(--border-radius);
    z-index: 700; overflow-y: auto; box-shadow: 0 0 20px rgba(0,240,255,0.1);
}
.history-list { padding: 0.2rem 0; }
.history-item {
    padding: 0.25rem 0.65rem; cursor: pointer; font-size: 0.78rem;
    font-family: 'Cascadia Code','Fira Code','Consolas',monospace;
    color: var(--text-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item:hover { background: rgba(255,255,255,0.06); color: var(--primary-color); }

/* === Folder Picker Modal === */
.folder-picker {
    position: fixed; inset: 0; z-index: 950; display: flex;
    align-items: center; justify-content: center;
}
.folder-picker-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.folder-picker-box {
    position: relative; width: 480px; max-width: 90vw; max-height: 70vh;
    background: var(--bg-color); border: 1px solid var(--primary-color);
    border-radius: var(--border-radius); box-shadow: 0 0 40px rgba(0,240,255,0.15);
    display: flex; flex-direction: column; overflow: hidden;
}
.folder-picker-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.45rem 0.65rem; border-bottom: 1px solid rgba(255,255,255,0.08);
    color: var(--primary-color); font-size: 0.82rem;
}
.folder-picker-header button {
    background: none; border: 1px solid rgba(255,255,255,0.12);
    color: var(--primary-color); cursor: pointer; border-radius: 3px;
    padding: 0.1rem 0.35rem; font-size: 0.78rem;
}
.folder-picker-header button:hover { background: rgba(255,255,255,0.06); }
.folder-picker-path {
    display: flex; gap: 4px; padding: 0.35rem 0.45rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.folder-picker-path button {
    padding: 0.2rem 0.45rem; background: transparent; border: 1px solid rgba(255,255,255,0.12);
    color: var(--primary-color); border-radius: 3px; cursor: pointer; font-size: 0.78rem;
}
.folder-picker-path button:hover { background: rgba(255,255,255,0.06); }
.folder-picker-path input {
    flex: 1; padding: 0.2rem 0.45rem; background: var(--bg-darker);
    border: 1px solid rgba(255,255,255,0.12); border-radius: 3px;
    color: var(--text-color); font-size: 0.75rem;
}
.folder-picker-path input:focus { outline: none; border-color: var(--primary-color); }
.picker-dir-list { flex: 1; overflow-y: auto; min-height: 200px; }
.picker-dir-item {
    padding: 0.3rem 0.65rem; cursor: pointer; font-size: 0.8rem;
    color: var(--primary-color); display: flex; align-items: center; gap: 6px;
}
.picker-dir-item:hover { background: rgba(255,255,255,0.04); }
.picker-dir-item .dir-icon { font-size: 0.78rem; }
.folder-picker-footer {
    padding: 0.45rem; border-top: 1px solid rgba(255,255,255,0.08);
    display: flex; justify-content: flex-end;
}
.folder-picker-footer button {
    padding: 0.35rem 0.9rem; background: transparent; border: 1px solid var(--primary-color);
    color: var(--primary-color); border-radius: 4px; cursor: pointer; font-size: 0.8rem;
}
.folder-picker-footer button:hover { background: var(--primary-color); color: var(--bg-darker); }

/* === Status bar === */
.status-bar {
    display: flex; justify-content: space-between; align-items: center;
    height: var(--status-height); padding: 0 0.5rem;
    background: var(--bg-color); border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.7rem; color: var(--text-secondary); z-index: 300;
}
.status-left, .status-right { display: flex; align-items: center; gap: 0.4rem; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-dot.connected { background: var(--success); box-shadow: 0 0 4px var(--success); }
.status-dot.disconnected { background: var(--danger); box-shadow: 0 0 4px var(--danger); }
.status-dot.reconnecting { background: var(--warning); box-shadow: 0 0 4px var(--warning); }
.status-sep { color: rgba(255,255,255,0.15); }
.status-btn {
    background: none; border: none; color: var(--text-secondary);
    cursor: pointer; font-size: 0.7rem; padding: 0 0.2rem;
}
.status-btn:hover { color: var(--primary-color); }
.status-item { color: var(--text-secondary); }

/* === Scrollbar === */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* === Focus visible === */
*:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 1px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 1px var(--primary-color); }

/* === Admin user list === */
.admin-user-list { display: flex; flex-direction: column; gap: 2px; }
.admin-user-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.25rem 0.35rem; border-radius: 3px; font-size: 0.72rem;
    background: rgba(255,255,255,0.02);
}
.admin-user-row:hover { background: rgba(255,255,255,0.04); }
.admin-user-info { display: flex; align-items: center; gap: 0.3rem; }
.admin-user-info .username { color: var(--text-color); font-weight: 500; }
.admin-user-info .badge { font-size: 0.58rem; }
.admin-user-actions { display: flex; gap: 2px; }
.admin-user-actions button {
    background: none; border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-secondary); cursor: pointer; border-radius: 2px;
    padding: 0.1rem 0.3rem; font-size: 0.62rem;
}
.admin-user-actions button:hover { color: var(--primary-color); border-color: var(--primary-color); }
.admin-user-actions button.danger:hover { color: var(--danger); border-color: var(--danger); }

/* === Code viewer highlighted view === */
.code-highlighted {
    flex: 1; overflow: auto; margin: 0; border-radius: 0;
    background: var(--bg-darker); font-size: 13px; line-height: 1.5;
}
.code-highlighted code { font-family: 'Cascadia Code','Fira Code','Consolas',monospace; }

/* === Loading overlay === */
.loading-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.loading-content {
    display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
    color: var(--primary-color); font-size: 0.85rem;
}
.loading-spinner {
    width: 32px; height: 32px; border: 2px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary-color); border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === CodeMirror integration === */
.CodeMirror {
    height: 100% !important;
    font-family: 'Cascadia Code','Fira Code','Consolas',monospace !important;
    font-size: 13px;
    background: var(--bg-darker) !important;
}
.CodeMirror-scroll { height: 100%; }

/* === Header restore bar === */
.header-restore {
    height: 6px; background: var(--primary-color); cursor: pointer;
    text-align: center; font-size: 0.5rem; line-height: 6px;
    color: var(--bg-darker); opacity: 0.6; transition: opacity 0.15s;
}
.header-restore:hover { opacity: 1; height: 14px; line-height: 14px; font-size: 0.65rem; }

/* === UI font scaling === */
:root { --ui-font-scale: 1; }
body { font-size: calc(0.875rem * var(--ui-font-scale)); }

/* === High contrast mode === */
body.high-contrast {
    --primary-color: #ffffff;
    --text-color: #ffffff;
    --text-secondary: #cccccc;
    --bg-color: #000000;
    --bg-darker: #000000;
}
body.high-contrast .terminal-window { border-color: #ffffff; }
body.high-contrast .header { border-bottom-color: #ffffff; }

/* === Onboarding tour === */
.tour-overlay {
    position: fixed; inset: 0; z-index: 1100; pointer-events: none;
}
.tour-backdrop {
    position: absolute; inset: 0; background: rgba(0,0,0,0.65); pointer-events: all;
}
.tour-spotlight {
    position: absolute; border-radius: 6px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.65), 0 0 0 3px var(--primary-color);
    pointer-events: none; transition: all 0.25s ease;
}
.tour-tooltip {
    position: absolute; background: var(--bg-color); border: 1px solid var(--primary-color);
    border-radius: var(--border-radius); padding: 0.75rem 1rem; max-width: 280px;
    box-shadow: 0 0 20px rgba(0,240,255,0.2); pointer-events: all; z-index: 1101;
}
.tour-tooltip h3 { color: var(--primary-color); font-size: 0.85rem; margin-bottom: 0.35rem; }
.tour-tooltip p { color: var(--text-color); font-size: 0.78rem; line-height: 1.4; margin-bottom: 0.5rem; }
.tour-tooltip-footer { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.tour-step-count { font-size: 0.68rem; color: var(--text-secondary); }
.tour-btn {
    padding: 0.25rem 0.65rem; background: transparent; border: 1px solid var(--primary-color);
    color: var(--primary-color); border-radius: 3px; cursor: pointer; font-size: 0.75rem;
}
.tour-btn:hover { background: var(--primary-color); color: var(--bg-darker); }
.tour-btn-skip { border-color: rgba(255,255,255,0.2); color: var(--text-secondary); }
.tour-btn-skip:hover { background: rgba(255,255,255,0.08); color: var(--text-color); }

/* === Settings accordion === */
.settings-section { padding: 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.settings-heading {
    font-size: 0.72rem; color: var(--primary-color); text-transform: uppercase;
    letter-spacing: 0.5px; font-weight: 500; cursor: pointer;
    padding: 0.5rem 0.6rem; display: flex; justify-content: space-between; align-items: center;
    user-select: none;
}
.settings-heading:hover { background: rgba(255,255,255,0.03); }
.settings-heading::after { content: '▶'; font-size: 0.55rem; opacity: 0.5; transition: transform 0.15s; }
.settings-heading.open::after { transform: rotate(90deg); }
.settings-body { display: none; padding: 0.4rem 0.6rem 0.5rem; }
.settings-body.open { display: block; }
