/* ─────────────────────────────────────────────────────────────────────────────
   CloviShell — Design System
   CloviTek UI Kit · Dark Terminal Theme
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --brand:          #7c3aed;
  --brand-light:    #a78bfa;
  --brand-dark:     #5b21b6;
  --cyan:           #06b6d4;
  --green:          #10b981;
  --amber:          #f59e0b;
  --red:            #ef4444;

  --bg:             #0a0a0f;
  --surface:        #111118;
  --surface2:       #1a1a24;
  --surface3:       #22222f;
  --border:         rgba(255,255,255,0.07);
  --border-active:  rgba(124,58,237,0.4);

  --text:           #f1f0ff;
  --muted:          #9ca3af;
  --muted2:         #6b7280;

  --topbar-h:       52px;
  --statusbar-h:    28px;
  --sidebar-w:      240px;
  --sidebar-collapsed-w: 48px;
  --ai-panel-w:     400px;

  --radius-panel:   12px;
  --radius-btn:     8px;
  --radius-input:   6px;

  --font-ui:        'Inter', system-ui, sans-serif;
  --font-heading:   'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --transition:     0.15s ease;
}

/* ── Reset / Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #58a6ff; }

/* ── Typography ────────────────────────────────────────────────────────────── */
h1, h2, h3, .logo-name, .login-logo-name {
  font-family: var(--font-heading);
  font-weight: 800;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 24px;
  min-height: 48px;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 14px;
  transition: background var(--transition), box-shadow var(--transition);
  width: 100%;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(124,58,237,0.4);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-weight: 500;
  font-size: 13px;
  transition: background var(--transition), color var(--transition);
  width: 100%;
}
.btn-secondary:hover { background: var(--surface3); color: var(--text); }

.btn-sm { padding: 6px 14px; font-size: 13px; width: auto; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.btn-icon:hover { background: var(--surface3); color: var(--text); }
.btn-icon:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(124,58,237,0.4); }

.btn-icon-sm { padding: 4px 7px; font-size: 12px; }

.btn-ai {
  background: rgba(124,58,237,0.12);
  border-color: rgba(124,58,237,0.3);
  color: var(--brand-light);
}
.btn-ai:hover {
  background: rgba(124,58,237,0.22);
  border-color: var(--brand-light);
  color: #fff;
}
.btn-ai.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.ai-sparkle { font-size: 16px; color: #a78bfa; }
.btn-ai { color: #c4b5fd; font-weight: 700; }

/* ── Inputs ────────────────────────────────────────────────────────────────── */
input, select, textarea {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 2px rgba(124,58,237,0.15);
}
input::placeholder, textarea::placeholder { color: var(--muted2); }

/* ── Login overlay ─────────────────────────────────────────────────────────── */
#login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 40% 30%, rgba(124,58,237,0.18) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(6,182,212,0.10) 0%, transparent 55%),
              var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  background: rgba(17,17,24,0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: var(--radius-panel);
  box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04) inset;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.login-logo-icon {
  width: 44px;
  height: 44px;
  background: var(--brand);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}
.login-logo-text { display: flex; flex-direction: column; gap: 2px; }
.login-logo-name { font-size: 22px; color: var(--text); letter-spacing: -0.5px; }
.login-logo-badge {
  display: inline-block;
  padding: 1px 7px;
  background: rgba(124,58,237,0.2);
  border: 1px solid rgba(124,58,237,0.35);
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  color: var(--brand-light);
  letter-spacing: 1px;
  width: fit-content;
}

.login-subtitle { font-size: 13px; color: var(--muted); margin-top: -8px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--muted); }
.form-group input { padding: 14px 16px; font-size: 16px; }

.login-error {
  font-size: 13px;
  color: var(--red);
  min-height: 18px;
  text-align: center;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted2);
  font-size: 12px;
  margin: -4px 0;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-ssh { gap: 8px; }

/* ── App shell ─────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  gap: 8px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-right: 8px;
  border-right: 1px solid var(--border);
  margin-right: 4px;
}
.logo-icon {
  width: 28px;
  height: 28px;
  background: var(--brand);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  flex-shrink: 0;
}
.logo-name {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
  white-space: nowrap;
}
.logo-badge {
  padding: 1px 6px;
  background: rgba(124,58,237,0.18);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 20px;
  font-size: 9px;
  font-weight: 700;
  color: var(--brand-light);
  letter-spacing: 0.8px;
}

/* Session tabs */
.session-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  min-width: 0;
}
.session-tabs::-webkit-scrollbar { display: none; }

.session-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.session-tab:hover { background: var(--surface3); color: var(--text); }
.session-tab.active {
  background: rgba(124,58,237,0.12);
  border-color: rgba(124,58,237,0.35);
  color: var(--brand-light);
}

.tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted2);
  flex-shrink: 0;
}
.tab-dot.active { background: var(--green); box-shadow: 0 0 4px var(--green); }

.tab-close {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  font-size: 12px;
  color: var(--muted2);
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
}
.session-tab:hover .tab-close { opacity: 1; }
.tab-close:hover { background: var(--surface3); color: var(--text); }

/* User menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}
.user-email {
  font-size: 12px;
  color: var(--muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── App body ──────────────────────────────────────────────────────────────── */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: width 0.2s ease;
  position: relative;
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed-w); }

/* Left icon rail */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--sidebar-collapsed-w);
  flex-shrink: 0;
  padding: 8px 0;
  gap: 2px;
  border-right: 1px solid var(--border);
}

.sidebar-nav-btn {
  width: 36px;
  height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 8px;
  color: var(--muted2);
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.sidebar-nav-btn:hover { background: var(--surface2); color: var(--muted); }
.sidebar-nav-btn.active { background: rgba(124,58,237,0.15); color: var(--brand-light); }
.sidebar-nav-btn svg { flex-shrink: 0; width: 22px; height: 22px; }
.sidebar-nav-btn [data-lucide] { width: 22px !important; height: 22px !important; stroke-width: 1.8px !important; color: #94a3b8 !important; }
.sidebar-nav-btn:hover [data-lucide],
.sidebar-nav-btn.active [data-lucide] { color: #a78bfa !important; }
.sidebar-nav-label { display: none; font-size: 9px; font-weight: 600; letter-spacing: 0.3px; }

/* Topbar icons — bigger and brighter */
.topbar [data-lucide], .topbar svg:not(.logo-icon svg) { width: 20px !important; height: 20px !important; stroke-width: 1.8px !important; color: #cbd5e1 !important; }

/* Panel area */
.sidebar-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.sidebar-panel.active { display: flex; }
.sidebar.collapsed .sidebar-panel { display: none !important; }

.sidebar-panel-header {
  padding: 12px 14px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* File tree */
.file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  font-size: 12.5px;
  font-family: var(--font-mono);
}

/* History list */
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

/* Plugins */
.plugins-list { padding: 8px 0; }
.plugin-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.plugin-item:hover { background: var(--surface2); }
.plugin-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.plugin-info { flex: 1; min-width: 0; }
.plugin-name { font-size: 12.5px; font-weight: 500; color: var(--text); }
.plugin-desc { font-size: 11px; color: var(--muted2); margin-top: 1px; }
.plugin-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted2);
  flex-shrink: 0;
}
.plugin-status.active { background: var(--green); box-shadow: 0 0 4px var(--green); }

/* Settings */
.settings-list { padding: 12px; display: flex; flex-direction: column; gap: 16px; }
.settings-group { display: flex; flex-direction: column; gap: 6px; }
.settings-label { font-size: 11px; font-weight: 600; color: var(--muted2); text-transform: uppercase; letter-spacing: 0.6px; }
.settings-select { padding: 7px 10px; width: 100%; }
.settings-range { width: 100%; accent-color: var(--brand); }

/* Sidebar collapse button */
.sidebar-collapse-btn {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted2);
  transition: background var(--transition), color var(--transition);
}
.sidebar-collapse-btn:hover { background: var(--surface3); color: var(--text); }
.sidebar.collapsed .collapse-icon { transform: rotate(180deg); }

/* ── Workspace ─────────────────────────────────────────────────────────────── */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Terminal row */
.terminal-row {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* Terminal pane */
.terminal-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  overflow: hidden;
}

#terminal-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 4px;
}

#terminal {
  flex: 1;
  min-height: 0;
}

/* xterm overrides */
.xterm { font-family: var(--font-mono) !important; }
.xterm-viewport { background: transparent !important; }

/* Resize handle */
.resize-handle {
  width: 4px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background var(--transition);
  position: relative;
}
.resize-handle:hover, .resize-handle.dragging { background: var(--brand); }
.resize-handle::after {
  content: '';
  position: absolute;
  inset: 0 -4px;
}

/* Preview pane */
.preview-pane {
  width: 40%;
  min-width: 280px;
  max-width: 60%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
}
.preview-pane.hidden { display: none; }

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.preview-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }

.preview-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.preview-content pre {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  padding: 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ── Status bar ────────────────────────────────────────────────────────────── */
.statusbar {
  height: var(--statusbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted2);
  overflow: hidden;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  color: #cbd5e1;
}

.status-sep { color: var(--border); user-select: none; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted2);
  flex-shrink: 0;
}
.status-dot.connected { background: var(--green); box-shadow: 0 0 5px var(--green); }
.status-dot.disconnected { background: var(--red); }
.status-dot.connecting { background: var(--amber); animation: pulse 1.2s ease infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Legacy IDs used by app.js */
#status-bar {}
#sb-conn { display: inline-block; }

/* ── AI Panel ──────────────────────────────────────────────────────────────── */
.ai-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: var(--ai-panel-w);
  background: rgba(17,17,24,0.92);
  backdrop-filter: blur(12px);
  border-left: 1px solid rgba(124,58,237,0.2);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -8px 0 32px rgba(0,0,0,0.4);
}
.ai-panel.open { transform: translateX(0); }

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(124,58,237,0.15);
  flex-shrink: 0;
}
.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--brand-light);
}
.ai-panel-title .ai-sparkle { font-size: 14px; }

.ai-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-msg {
  padding: 10px 14px;
  border-radius: var(--radius-input);
  font-size: 13px;
  line-height: 1.6;
  max-width: 90%;
}
.ai-msg.user {
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.2);
  align-self: flex-end;
  color: var(--text);
}
.ai-msg.assistant {
  background: var(--surface2);
  border: 1px solid var(--border);
  align-self: flex-start;
  color: var(--text);
}

.ai-panel-input {
  padding: 14px 16px;
  border-top: 1px solid rgba(124,58,237,0.15);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-panel-input textarea {
  width: 100%;
  padding: 10px 12px;
  resize: none;
  border-radius: var(--radius-input);
  font-size: 13px;
  line-height: 1.5;
  min-height: 72px;
}
.ai-panel-input .btn-primary { align-self: flex-end; width: auto; }

/* ── Mobile toolbar ────────────────────────────────────────────────────────── */
#mobile-toolbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 8px;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
#mobile-toolbar::-webkit-scrollbar { display: none; }

.toolbar-key {
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #e2e8f0;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.toolbar-key:hover, .toolbar-key:active { background: var(--surface3); color: var(--text); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  :root {
    --sidebar-w: 100vw;
    --ai-panel-w: 100vw;
  }

  /* Topbar: hide tabs, user email, new-tab button */
  .session-tabs { display: none; }
  .user-email { display: none; }
  .logo-badge { display: none; }
  #btn-new-tab { display: none; }

  /* Hide sidebar completely — opens as overlay via hamburger only */
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: var(--statusbar-h);
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: var(--sidebar-w) !important;
  }
  .sidebar.open { transform: translateX(0); }

  /* Hide session tab bar injected by app.js */
  #cs-tab-bar { display: none !important; }

  /* Workspace fills full width — no sidebar eating space */
  .workspace, #workspace, .main-content {
    width: 100% !important;
    left: 0 !important;
    margin-left: 0 !important;
  }

  /* Show mobile toolbar */
  #mobile-toolbar { display: flex; }
  /* Hide status bar on mobile — toolbar takes that space */
  .statusbar { display: none !important; }

  /* Terminal must stop 44px above the fixed toolbar so the prompt isn't hidden */
  .workspace { padding-bottom: 44px; }
  #terminal-container { padding-bottom: 48px; }
  .cs-tab-terminal { padding-bottom: 0; }

  /* xterm font size — no !important so app.js terminal options take precedence */
  .xterm-viewport { font-size: 12px; }

  /* Preview panel: full-screen overlay, hidden by default */
  .preview-pane {
    width: 100%;
    max-width: 100%;
    position: fixed;
    inset: var(--topbar-h) 0 44px;
    z-index: 140;
  }

  /* AI panel: full-screen overlay when open, hidden otherwise */
  .ai-panel {
    position: fixed !important;
    top: var(--topbar-h) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 44px !important;
    width: 100% !important;
    transform: translateX(100%);
  }
  .ai-panel.open { transform: translateX(0); }
  .ai-panel-messages { flex: 1; min-height: 0; overflow-y: auto; }
  .ai-panel-input textarea { min-height: 48px; font-size: 16px; }

  /* File manager sidebar hidden on mobile */
  .fm-sidebar, #fm-sidebar { display: none !important; }

  /* Status bar: hide secondary items */
  #status-branch, #status-cmds { display: none; }
  #status-cwd { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (min-width: 768px) {
  #hamburger { display: none; }
}

/* Hamburger — mobile only, large tap target */
@media (max-width: 767px) {
  #hamburger {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: #e2e8f0;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
  }
  #hamburger svg { width: 22px; height: 22px; stroke-width: 2.5; }
}

/* ── Sidebar overlay backdrop (mobile) ─────────────────────────────────────── */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 149;
  display: none;
}
.sidebar-backdrop.visible { display: block; }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── File tree items (file-manager.js) ─────────────────────────────────────── */
.file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--transition), color var(--transition);
}
.file-item:hover { background: var(--surface2); color: var(--text); }
.file-item.selected { background: rgba(124,58,237,0.12); color: var(--brand-light); }
.file-item .file-icon { flex-shrink: 0; opacity: 0.7; }
.file-indent-1 { padding-left: 26px; }
.file-indent-2 { padding-left: 38px; }
.file-indent-3 { padding-left: 50px; }

/* ── History items (history-panel.js) ──────────────────────────────────────── */
.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.history-item:hover { background: var(--surface2); }
.history-item .hist-cmd {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--cyan);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item .hist-time { font-size: 11px; color: var(--muted2); white-space: nowrap; }
