@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/libs/fonts/JetBrainsMono-Regular.woff2') format('woff2');
}

/* CSS Variables - Modern Dark Theme with Reddish-Fuchsia Accent */
:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-hover: #30363d;
  --bg-active: #c1005926;
  --border-color: #30363d;
  --border-light: #484f58;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent-primary: #c10059;
  --accent-secondary: #00b4d8;
  --accent-tertiary: #f59e0b;
  --accent-success: #3fb950;
  --accent-warning: #d29922;
  --accent-danger: #f85149;
  --accent-danger-hover: #ff6b63;
  --accent-purple: #a371f2;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --header-height: 42px;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 50px;
}

/* Light Theme */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #eaeef2;
  --bg-hover: #d0d7de;
  --bg-active: #c100591a;
  --border-color: #d0d7de;
  --border-light: #afb8c1;
  --text-primary: #1f2328;
  --text-secondary: #656d76;
  --text-muted: #8c959f;
  /* Darker reds on light backgrounds: the dark-theme #f85149 only reaches
     ~3.2:1 against the white label of .btn-danger (Logout), which is
     unreadable on a light modal. #cf222e / #a40e26 give 4.8:1 / 7.6:1. */
  --accent-danger: #cf222e;
  --accent-danger-hover: #a40e26;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.2);
}

/* Theme Wave Animation */
.theme-wave {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.theme-wave::before {
  content: '';
  position: absolute;
  left: var(--wave-x);
  top: var(--wave-y);
  width: 0;
  height: 0;
  border-radius: 50%;
  background: var(--wave-color);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              height 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease;
}

.theme-wave.animate::before {
  width: 300vmax;
  height: 300vmax;
  opacity: 1;
}

.theme-wave.fade-out::before {
  opacity: 0;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              height 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease 0.05s;
}

/* Accent Colors - Dark Theme */
/* Primary = SSH bookmarks, Secondary = SFTP bookmarks, Tertiary = URL bookmarks */
/* Using complementary/triadic colors for visual distinction */
[data-accent="fuchsia"] {
  --accent-primary: #c10059;
  --accent-secondary: #00b4d8;
  --accent-tertiary: #f59e0b;
  --accent-hover: #d9106a;
}

[data-accent="green"] {
  --accent-primary: #2ea043;
  --accent-secondary: #8b5cf6;
  --accent-tertiary: #f97316;
  --accent-hover: #3fb950;
}

[data-accent="purple"] {
  --accent-primary: #a371f2;
  --accent-secondary: #84cc16;
  --accent-tertiary: #ef4444;
  --accent-hover: #b279f7;
}

[data-accent="orange"] {
  --accent-primary: #d18616;
  --accent-secondary: #3b82f6;
  --accent-tertiary: #ec4899;
  --accent-hover: #e09b2d;
}

[data-accent="red"] {
  --accent-primary: #da3633;
  --accent-secondary: #06b6d4;
  --accent-tertiary: #eab308;
  --accent-hover: #f85149;
}

[data-accent="cyan"] {
  --accent-primary: #1f6feb;
  --accent-secondary: #f97316;
  --accent-tertiary: #ec4899;
  --accent-hover: #388bfd;
}

[data-accent="blue"] {
  --accent-primary: #58a6ff;
  --accent-secondary: #f97316;
  --accent-tertiary: #22c55e;
  --accent-hover: #79b8ff;
}

[data-accent="yellow"] {
  --accent-primary: #d29922;
  --accent-secondary: #8b5cf6;
  --accent-tertiary: #3b82f6;
  --accent-hover: #e3b341;
}

/* Accent Colors - Light Theme (adjusted for visibility) */
/* Primary = SSH bookmarks, Secondary = SFTP bookmarks, Tertiary = URL bookmarks */
/* Using complementary/triadic colors for visual distinction */
[data-theme="light"][data-accent="fuchsia"] {
  --accent-primary: #c10059;
  --accent-secondary: #0891b2;
  --accent-tertiary: #d97706;
  --accent-hover: #9d0047;
}

[data-theme="light"][data-accent="green"] {
  --accent-primary: #1a7f37;
  --accent-secondary: #7c3aed;
  --accent-tertiary: #ea580c;
  --accent-hover: #2da44e;
}

[data-theme="light"][data-accent="purple"] {
  --accent-primary: #8250df;
  --accent-secondary: #65a30d;
  --accent-tertiary: #dc2626;
  --accent-hover: #9649e4;
}

[data-theme="light"][data-accent="orange"] {
  --accent-primary: #bf8700;
  --accent-secondary: #2563eb;
  --accent-tertiary: #db2777;
  --accent-hover: #d4a72c;
}

[data-theme="light"][data-accent="red"] {
  --accent-primary: #cf222e;
  --accent-secondary: #0891b2;
  --accent-tertiary: #ca8a04;
  --accent-hover: #da3633;
}

[data-theme="light"][data-accent="cyan"] {
  --accent-primary: #0550ae;
  --accent-secondary: #ea580c;
  --accent-tertiary: #db2777;
  --accent-hover: #0969da;
}

[data-theme="light"][data-accent="blue"] {
  --accent-primary: #0969da;
  --accent-secondary: #ea580c;
  --accent-tertiary: #16a34a;
  --accent-hover: #218bff;
}

[data-theme="light"][data-accent="yellow"] {
  --accent-primary: #9a6700;
  --accent-secondary: #7c3aed;
  --accent-tertiary: #2563eb;
  --accent-hover: #bf8700;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

/* Fix for mobile viewport height issues */
/* Use dvh (dynamic viewport height) with fallbacks for mobile browsers */
/* dvh accounts for browser UI (address bar, navigation bar) and keyboard, automatically adjusting */
@supports (height: 100dvh) {
  html, body {
    height: 100dvh;
  }
  
  .app-container {
    height: 100dvh;
  }
  
  .modal {
    height: 100dvh;
    max-height: 100dvh;
  }
}

/* Fallback to svh (small viewport height) for browsers without dvh support */
@supports (height: 100svh) and (not (height: 100dvh)) {
  html, body {
    height: 100svh;
  }
  
  .app-container {
    height: 100svh;
  }
  
  .modal {
    height: 100svh;
    max-height: 100svh;
  }
}

/* Final fallback for browsers without svh/dvh support - uses JS-set --vh variable */
@supports not (height: 100svh) {
  html, body {
    height: calc(var(--vh, 1vh) * 100);
  }
  
  .app-container {
    height: calc(var(--vh, 1vh) * 100);
  }
  
  .modal {
    height: calc(var(--vh, 1vh) * 100);
    max-height: calc(var(--vh, 1vh) * 100);
  }
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  position: relative;
  transition: transform 0.3s ease;
}

.header.hidden {
  transform: translateY(-100%);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.logo i {
  color: var(--accent-primary);
}

.menu-btn {
  display: none !important;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.menu-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Menu icon visibility - hamburger on desktop, bookmark on mobile */
.mobile-menu-icon {
  display: none;
}

/* Desktop-only controls - hidden on mobile */
.desktop-only {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Mobile overflow menu - hidden on desktop */
.mobile-overflow-menu {
  display: none;
  position: relative;
}

.overflow-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.overflow-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.overflow-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 8px 0;
  display: none;
  z-index: 1000;
}

.overflow-dropdown.show {
  display: block;
}

.overflow-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
}

.overflow-option:hover {
  background: var(--bg-hover);
}

.overflow-option i {
  width: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.overflow-option:hover i {
  color: var(--accent-primary);
}

/* Style accent-preview in mobile overflow menu */
.overflow-option .accent-preview {
  width: 16px;
  height: 16px;
  background: var(--accent-primary);
  border-radius: 4px;
  flex-shrink: 0;
}

.overflow-submenu {
  position: relative;
}

.submenu-arrow {
  margin-left: auto;
  font-size: 12px;
}

.submenu-content {
  display: none;
  padding: 8px 0;
  background: var(--bg-tertiary);
}

.submenu-content.show {
  display: block;
}

.submenu-content .accent-option,
.submenu-content .terminal-color-option {
  padding: 8px 16px 8px 32px;
}

/* Mobile tabs dropdown */
.mobile-tabs-dropdown {
  display: none;
  flex: 1;
  position: relative;
  gap: 4px;
}

.mobile-force-resize-btn {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.mobile-force-resize-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-primary);
  border-color: var(--border-light);
}

.mobile-tabs-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.mobile-tabs-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.mobile-tabs-toggle .tab-icon-active {
  color: var(--accent-primary);
}

.mobile-tabs-label {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-arrow {
  transition: transform var(--transition-fast);
}

.mobile-tabs-toggle.active .dropdown-arrow {
  transform: rotate(180deg);
}

.mobile-tabs-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
}

.mobile-tabs-menu.show {
  display: block;
}

.mobile-tab-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
  width: 100%;
  text-align: left;
}

.mobile-tab-option:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.mobile-tab-option.active {
  background: var(--bg-active);
  color: var(--text-primary);
}

.mobile-tab-option .tab-icon {
  font-size: 12px;
  width: 16px;
  text-align: center;
}

.mobile-tab-option .tab-icon.ssh {
  color: var(--accent-primary);
}

.mobile-tab-option .tab-icon.sftp {
  color: var(--accent-secondary);
}

.mobile-tab-option .tab-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-tab-option .tab-panel-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.2;
}

.mobile-tab-option .tab-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 12px;
  padding: 0;
}

.mobile-tab-option .tab-close:hover {
  background: var(--accent-danger);
  color: #fff;
}

.mobile-tab-option .tab-rename {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 10px;
  padding: 0;
}

.mobile-tab-option .tab-rename:hover {
  background: var(--accent-primary);
  color: #fff;
}

/* Theme Toggle & Accent Selector */
.theme-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.theme-toggle i {
  font-size: 16px;
}

.accent-selector {
  position: relative;
}

.accent-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.accent-btn:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.accent-preview {
  width: 16px;
  height: 16px;
  background: var(--accent-primary);
  border-radius: 4px;
  display: inline-block;
}

.accent-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  padding: 8px 0;
  display: none;
  z-index: 1000;
}

.accent-dropdown.show {
  display: block;
}

.accent-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
}

.accent-option:hover {
  background: var(--bg-hover);
}

.accent-option.active {
  background: var(--bg-active);
}

.accent-color {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  display: inline-block;
  flex-shrink: 0;
}

.accent-label {
  font-weight: 500;
}

/* Terminal Color Selector */
.terminal-color-selector {
  position: relative;
}

.terminal-color-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.terminal-color-btn:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.terminal-color-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  padding: 12px;
  display: none;
  z-index: 1000;
}

.terminal-color-dropdown.show {
  display: block;
}

.terminal-color-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.terminal-color-option {
  padding: 8px 0;
}

.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
}

.toggle-checkbox {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 40px;
  height: 20px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: var(--transition-fast);
}

.toggle-checkbox:checked + .toggle-slider {
  background: var(--accent-primary);
}

.toggle-checkbox:checked + .toggle-slider::after {
  transform: translateX(20px);
}

.terminal-color-options {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  display: none;
}

.terminal-color-options.show {
  display: block;
}

.terminal-color-options .terminal-color-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.terminal-color-options label {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Color picker + its restore-default button, kept together on the right */
.color-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.color-reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  transition: var(--transition-fast);
}

.color-reset-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.color-reset-btn:active {
  transform: scale(0.94);
}

.color-input {
  width: 40px;
  height: 28px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  padding: 2px;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

/* Layout Selector */
.layout-selector {
  position: relative;
}

.layout-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.layout-btn:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
  color: var(--text-primary);
}

.layout-btn.active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.layout-btn svg {
  width: 18px;
  height: 18px;
}

.layout-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: 8px 0;
  display: none;
  z-index: 1000;
}

.layout-dropdown.show {
  display: block;
}

.layout-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
}

.layout-option:hover {
  background: var(--bg-hover);
}

.layout-option.active {
  background: var(--bg-active);
  color: var(--accent-primary);
}

.layout-option i,
.layout-option svg {
  width: 20px;
  height: 20px;
  text-align: center;
  color: var(--text-secondary);
}

.layout-option.active i,
.layout-option.active svg {
  color: var(--accent-primary);
}

.layout-label {
  font-weight: 500;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
  color: #fff;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  min-height: 34px;
}

.btn-icon {
  padding: 8px 8px;
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

/* Mobile-specific button sizing */
@media (max-width: 768px) {
  .btn-icon {
    padding: 0 !important;
    min-width: 32px !important;
    min-height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    font-size: 16px !important;
    line-height: 1 !important;
    border-width: 1px !important;
  }
  
  .btn-icon i,
  .btn-icon svg {
    font-size: 16px !important;
    width: 16px !important;
    height: 16px !important;
  }
  
  .menu-btn {
    display: flex !important;
    padding: 0 !important;
    min-width: 32px !important;
    min-height: 32px !important;
    max-width: 32px !important;
    max-height: 32px !important;
    font-size: 16px !important;
    line-height: 1 !important;
  }
  
  .logo {
    margin-left: 8px;
  }
  
  .header-left, .header-right {
    gap: 4px !important;
  }
}

.btn-icon.inactive {
  opacity: 0.5;
}

.btn-icon.inactive:hover {
  opacity: 0.75;
}

.btn-danger {
  background: var(--accent-danger);
  border-color: var(--accent-danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--accent-danger-hover);
  border-color: var(--accent-danger-hover);
  color: #fff;
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: var(--transition-normal);
  overflow: hidden;
}

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

.sidebar.collapsed .sidebar-header h2,
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .bookmark-info,
.sidebar.collapsed .bookmark-actions {
  display: none;
}

.sidebar.collapsed .bookmark-item {
  justify-content: center;
  padding: 0;
  position: relative;
}

.sidebar.collapsed .bookmark-icon {
  margin-right: 0;
  position: relative;
}

.sidebar.collapsed .bookmark-icon i {
  display: none;
}

.sidebar.collapsed .bookmark-icon .bookmark-letter {
  display: flex;
  font-weight: 600;
  font-size: 14px;
}

.bookmark-icon .bookmark-letter {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-header-actions .btn {
  min-width: 32px;
  padding: 6px 8px !important;
}

.sidebar-toggle {
  padding: 6px 8px !important;
}

.sidebar-toggle:hover {
  background: var(--bg-hover);
}

.sidebar-toggle i {
  transition: transform var(--transition-normal);
}

.sidebar.collapsed .sidebar-toggle i {
  transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-header {
  flex-direction: column;
  padding: 12px 8px;
  gap: 8px;
}

/* Reverse button order in collapsed state: folder before + */
.sidebar.collapsed .sidebar-header-actions {
  flex-direction: column-reverse;
  width: 100%;
}

.sidebar.collapsed .sidebar-header-actions .btn {
  width: 100%;
  justify-content: center;
}

.bookmarks-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sidebar-footer {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.version-info {
  font-size: 12px;
  color: var(--text-secondary);
}

.version-label {
  font-weight: 500;
}

.version-number {
  font-family: monospace;
  color: var(--text-primary);
}

.update-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

.check-updates {
  font-size: 12px;
  color: var(--accent-primary);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.check-updates:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.btn-update {
  font-size: 11px;
  padding: 4px 10px !important;
  background: var(--accent-primary);
  color: white;
  border: none;
  gap: 4px;
}

.btn-update:hover {
  background: var(--accent-hover);
}

.sidebar.collapsed .sidebar-footer {
  padding: 8px;
  text-align: center;
}

.sidebar.collapsed .version-info {
  font-size: 10px;
}

.sidebar.collapsed .update-info {
  gap: 4px;
}

.sidebar.collapsed .check-updates {
  font-size: 10px;
}

.sidebar.collapsed .btn-update {
  font-size: 10px;
  padding: 3px 6px !important;
}

/* Hide empty state message when sidebar is collapsed */
.sidebar.collapsed .bookmarks-list > div[style*="text-align: center"] {
  display: none;
}

.bookmark-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  margin-bottom: 4px;
}

.bookmark-item:hover {
  background: var(--bg-hover);
}

.bookmark-item.active {
  background: var(--bg-active);
}

.bookmark-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  margin-right: 10px;
  font-size: 14px;
}

/* SSH bookmarks use primary accent (e.g., fuchsia/pink) */
.bookmark-icon.ssh {
  background: rgba(193, 0, 89, 0.15);
  color: var(--accent-primary);
}

/* SFTP bookmarks use secondary accent (complementary color - cyan/teal) */
.bookmark-icon.sftp {
  background: rgba(0, 180, 216, 0.15);
  color: var(--accent-secondary);
}

/* URL bookmarks use tertiary accent (triadic color - amber/orange) */
.bookmark-icon.url {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-tertiary);
}

.bookmark-info {
  flex: 1;
  min-width: 0;
}

.bookmark-name {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-details {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-actions {
  display: none;
  gap: 4px;
}

.bookmark-item:hover .bookmark-actions {
  display: flex;
}

/* Hide hover actions when sidebar is collapsed */
.sidebar.collapsed .bookmark-item:hover .bookmark-actions {
  display: none;
}

/* Context Menu for Collapsed Bookmarks */
.bookmark-context-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 160px;
  padding: 4px 0;
  display: none;
}

.bookmark-context-menu.active {
  display: block;
}

.bookmark-context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-primary);
  font-size: 13px;
}

.bookmark-context-menu-item:hover {
  background: var(--bg-hover);
}

.bookmark-context-menu-item i {
  width: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.bookmark-context-menu-item:hover i {
  color: var(--accent-primary);
}

.bookmark-context-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.bookmark-context-menu-header {
  padding: 8px 12px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 4px;
}

.bookmark-context-menu-item.disabled {
  color: var(--text-secondary);
  cursor: default;
  pointer-events: none;
}

/* SFTP Context Menu */
.sftp-context-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 160px;
  padding: 4px 0;
  display: none;
}

.sftp-context-menu.active {
  display: block;
}

.sftp-context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-primary);
  font-size: 13px;
}

.sftp-context-menu-item:hover {
  background: var(--bg-hover);
}

.sftp-context-menu-item i {
  width: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.sftp-context-menu-item:hover i {
  color: var(--accent-primary);
}

.sftp-context-menu-item.danger {
  color: #ef4444;
}

.sftp-context-menu-item.danger i {
  color: #ef4444;
}

.sftp-context-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.sftp-context-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

/* Tab Context Menu */
.tab-context-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 140px;
  padding: 4px 0;
  display: none;
}

.tab-context-menu.active {
  display: block;
}

.tab-context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-primary);
  font-size: 13px;
}

.tab-context-menu-item:hover {
  background: var(--bg-hover);
}

.tab-context-menu-item i {
  width: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.tab-context-menu-item:hover i {
  color: var(--accent-primary);
}

/* Terminal Context Menu */
.terminal-context-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 140px;
  padding: 4px 0;
  display: none;
}

.terminal-context-menu.active {
  display: block;
}

.terminal-context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-primary);
  font-size: 13px;
}

.terminal-context-menu-item:hover {
  background: var(--bg-hover);
}

.terminal-context-menu-item i {
  width: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.terminal-context-menu-item:hover i {
  color: var(--accent-primary);
}

.terminal-context-menu-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.terminal-context-menu-item.disabled:hover {
  background: transparent;
}

.terminal-context-menu-item.disabled:hover i {
  color: var(--text-secondary);
}

.terminal-context-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

/* Tab Rename Input */
.tab-rename-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  padding: 2px 6px;
  width: 120px;
  outline: none;
}

.tab-rename-input:focus {
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

/* Drag and Drop Styles */
.bookmark-item[draggable="true"] {
  cursor: grab;
}

.bookmark-item[draggable="true"]:active {
  cursor: grabbing;
}

.tab[draggable="true"] {
  cursor: grab;
}

.tab[draggable="true"]:active {
  cursor: grabbing;
}

/* Folder Styles */
.folder-container {
  margin-bottom: 4px;
}

.folder-header {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  user-select: none;
}

.folder-header:hover {
  background: var(--bg-hover);
}

.folder-header[draggable="true"] {
  cursor: grab;
}

.folder-header[draggable="true"]:active {
  cursor: grabbing;
}

.folder-toggle {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  font-size: 10px;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.folder-icon {
  position: relative;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  font-size: 14px;
  color: var(--accent-primary);
}

.folder-icon .folder-letter {
  display: none;
  position: absolute;
  font-weight: 700;
  font-size: 10px;
  line-height: 1;
  color: var(--text-primary);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-shadow: 0 0 2px var(--bg-primary);
}

/* Show letter only when sidebar is collapsed */
.sidebar.collapsed .folder-icon .folder-letter {
  display: block;
}

.folder-name {
  flex: 1;
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-count {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 10px;
  margin-right: 8px;
}

.folder-menu-wrapper {
  position: relative;
  display: none;
}

.folder-header:hover .folder-menu-wrapper {
  display: block;
}

.folder-menu-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  font-size: 12px;
}

.folder-menu-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.folder-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 150px;
  padding: 4px 0;
  display: none;
  z-index: 1000;
}

.folder-menu-dropdown.show {
  display: block;
}

.folder-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
}

.folder-menu-item:hover {
  background: var(--bg-hover);
}

.folder-menu-item i {
  font-size: 12px;
  width: 16px;
  text-align: center;
}

.folder-actions {
  display: none;
  gap: 4px;
}

.folder-header:hover .folder-actions {
  display: flex;
}

.folder-actions button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  font-size: 12px;
}

.folder-actions button:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.folder-bookmarks {
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.folder-bookmarks.expanded {
  max-height: 1000px;
}

.folder-bookmarks.collapsed {
  max-height: 0;
}

.folder-bookmarks .bookmark-item {
  margin-left: 20px;
}

.bookmarks-root {
  min-height: 20px;
  padding: 2px 0;
}

.bookmarks-root.drag-over {
  background-color: var(--bg-hover);
  border-radius: 4px;
}

/* Sidebar collapsed folder styles */
.sidebar.collapsed .folder-header {
  justify-content: center;
  padding: 10px 8px;
}

.sidebar.collapsed .folder-toggle,
.sidebar.collapsed .folder-name,
.sidebar.collapsed .folder-count,
.sidebar.collapsed .folder-actions,
.sidebar.collapsed .folder-menu-wrapper {
  display: none;
}

.sidebar.collapsed .folder-icon {
  margin-right: 0;
}

.sidebar.collapsed .folder-bookmarks {
  display: none;
}

.bookmark-actions button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.bookmark-actions button:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.bookmark-actions .bookmark-menu-btn {
  padding: 6px;
}

.bookmark-actions .bookmark-menu-btn:hover {
  background: var(--bg-hover);
}

/* Terminal Area */
.terminal-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* Tabs */
.tabs-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  min-height: 37px;
  z-index: 10;
  transition: transform 0.3s ease;
}

.tabs-container.hidden {
  transform: translateY(-100%);
}

.tabs {
  display: flex;
  align-items: center;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
  min-height: 40px; /* Ensure there's always a drop target */
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  transition: var(--transition-fast);
  white-space: nowrap;
  font-size: 13px;
}

.tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tab.active {
  background: var(--bg-tertiary);
  border-bottom-color: var(--accent-primary);
  color: var(--text-primary);
}

.tab.flashing {
  animation: tab-flash 1s ease-in-out infinite;
  transition: none;
}

@keyframes tab-flash {
  0%, 100% {
    background: transparent;
    color: var(--accent-primary);
  }
  50% {
    background: var(--accent-primary);
    color: #fff;
  }
}

.tab.active.flashing {
  animation: tab-flash-active 1s ease-in-out infinite;
  transition: none;
}

@keyframes tab-flash-active {
  0%, 100% {
    background: var(--bg-tertiary);
    border-bottom-color: var(--accent-primary);
    color: var(--accent-primary);
  }
  50% {
    background: var(--accent-primary);
    color: #fff;
    border-bottom-color: var(--accent-primary);
  }
}

.mobile-tabs-toggle.flashing {
  animation: mobile-toggle-flash 1s ease-in-out infinite;
  transition: none;
}

@keyframes mobile-toggle-flash {
  0%, 100% {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary);
  }
  50% {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
    box-shadow: 0 0 8px var(--accent-primary);
  }
}

.mobile-tab-option.flashing {
  animation: mobile-option-flash 1s ease-in-out infinite;
  transition: none;
}

@keyframes mobile-option-flash {
  0%, 100% {
    background: transparent;
    color: var(--accent-primary);
  }
  50% {
    background: var(--accent-primary);
    color: #fff;
  }
}

[data-theme="light"] .tab.flashing {
  animation: tab-flash-light 1s ease-in-out infinite;
}

@keyframes tab-flash-light {
  0%, 100% {
    background: transparent;
    color: var(--accent-primary);
  }
  50% {
    background: var(--accent-primary);
    color: #fff;
  }
}

[data-theme="light"] .tab.active.flashing {
  animation: tab-flash-active-light 1s ease-in-out infinite;
}

@keyframes tab-flash-active-light {
  0%, 100% {
    background: var(--bg-tertiary);
    border-bottom-color: var(--accent-primary);
    color: var(--accent-primary);
  }
  50% {
    background: var(--accent-primary);
    color: #fff;
    border-bottom-color: var(--accent-primary);
  }
}

[data-theme="light"] .mobile-tabs-toggle.flashing {
  animation: mobile-toggle-flash-light 1s ease-in-out infinite;
}

@keyframes mobile-toggle-flash-light {
  0%, 100% {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary);
  }
  50% {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
    box-shadow: 0 0 8px var(--accent-primary);
  }
}

[data-theme="light"] .mobile-tab-option.flashing {
  animation: mobile-option-flash-light 1s ease-in-out infinite;
}

@keyframes mobile-option-flash-light {
  0%, 100% {
    background: transparent;
    color: var(--accent-primary);
  }
  50% {
    background: var(--accent-primary);
    color: #fff;
  }
}

.tab-icon {
  font-size: 12px;
}

.tab-icon.ssh {
  color: var(--accent-primary);
}

.tab-icon.sftp {
  color: var(--accent-secondary);
}

.tab-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  transition: var(--transition-fast);
  font-size: 10px;
}

/* Drag and drop styles for multi-panel tabs */
.tabs-container.drag-target {
  background: var(--bg-hover);
  border-radius: 4px;
}

.tabs-container.drag-over {
  background: var(--bg-tertiary);
  box-shadow: inset 0 0 0 2px var(--accent-primary);
}

/* Prevent cursor changes during tab drag */
body.dragging-tabs .tab,
body.dragging-tabs .tabs,
body.dragging-tabs .tabs-container {
  cursor: default !important;
}

/* Highlight entire tabs container when dragging over it */
.tabs.drag-over {
  background: var(--bg-hover);
  border-radius: 4px;
}

.tab-close:hover {
  background: var(--accent-danger);
  color: #fff;
}

.tabs-actions {
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 4px;
}

/* Special keys button should match mobile tabs dropdown height */
.tabs-actions .btn-sm {
  min-height: 32px;
}

/* Disabled state for terminal-only actions (e.g. on SFTP tabs) */
.tabs-actions .btn-sm[disabled],
.tabs-actions .btn-sm.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Tabs scroll arrows - desktop only */
.tabs-scroll-arrows {
  display: none;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
}

.tabs-scroll-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition-fast);
  font-size: 12px;
}

.tabs-scroll-arrow:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tabs-scroll-arrow:active {
  background: var(--bg-tertiary);
}

.tabs-scroll-arrow:disabled {
  opacity: 0.3;
}

/* Show scroll arrows on desktop when tabs overflow */
.tabs-scroll-arrows.visible {
  display: flex;
}

/* Layout System */
.layout-container {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.layout-container.columns {
  flex-direction: row;
}

.layout-container.rows {
  flex-direction: column;
}

.layout-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

/* Add right border to all columns except the last one */
.layout-column:not(:last-child) {
  border-right: 1px solid var(--border-color);
}

.layout-row {
  display: flex;
  flex-direction: row;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.layout-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-primary);
}

/* Add bottom border to all panels except the last one in a column */
.layout-panel:not(:last-child) {
  border-bottom: 1px solid var(--border-color);
}

.layout-panel .tabs-container {
  flex-shrink: 0;
}

.layout-panel .terminals-container {
  flex: 1;
  min-height: 0;
}

/* Panel resize handles (for future use) */
.layout-panel-resize-handle {
  position: absolute;
  background: transparent;
  z-index: 10;
}

.layout-panel-resize-handle.vertical {
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: ew-resize;
}

.layout-panel-resize-handle.horizontal {
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  cursor: ns-resize;
}

/* Terminals Container */
.terminals-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 200px;
}

.terminal-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  padding: 8px;
  z-index: 2;
}

.terminal-wrapper.active {
  display: flex;
  flex-direction: column;
}

.terminal-wrapper .xterm {
  flex: 1;
  width: 100%;
  height: 100%;
}

.terminal-container {
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 200px;
  position: relative;
}

/* Ensure xterm fills the container */
.terminal-container .xterm {
  height: 100%;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.terminal-container .xterm-viewport {
  height: 100% !important;
  background-color: #0d1117;
}

.terminal-container .xterm-screen {
  height: 100% !important;
  position: relative;
}

.terminal-container .xterm-rows {
  height: 100% !important;
}

/* Ensure xterm helper elements don't interfere */
.terminal-container .xterm-helpers {
  position: absolute;
  opacity: 0;
}

/* xterm v6 custom scrollbar: always visible */
.terminal-container .xterm-scrollable-element > .scrollbar {
  opacity: 1 !important;
  pointer-events: auto !important;
  transition: none !important;
  background-color: var(--terminal-scrollbar-track, #151b23) !important;
  width: 8px !important;
}

.terminal-container .xterm-scrollable-element > .scrollbar.invisible {
  opacity: 1 !important;
  pointer-events: auto !important;
  transition: none !important;
  background-color: var(--terminal-scrollbar-track, #151b23) !important;
}

.terminal-container .xterm-scrollable-element > .scrollbar.invisible.fade {
  opacity: 1 !important;
  transition: none !important;
  background-color: var(--terminal-scrollbar-track, #151b23) !important;
}

.terminal-container .xterm-scrollable-element > .scrollbar > .slider {
  border-radius: 3px;
  background-color: var(--terminal-scrollbar-thumb, #3d444d) !important;
  width: 8px !important;
  min-width: 8px !important;
  max-width: 8px !important;
}

.terminal-container .xterm-scrollable-element > .shadow {
  display: none !important;
}

/* Hide the overview ruler canvas — it creates a visible white strip
   when the terminal has no scrollback or on blur. The custom scrollbar
   already shows scroll position. */
.terminal-container .xterm-decoration-overview-ruler {
  display: none !important;
}

/* Hide native viewport scrollbar (xterm v6 uses custom scrollbar) */
.terminal-container .xterm-viewport::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.terminal-container .xterm-viewport {
  scrollbar-width: none;
}

/* Ensure terminal screen is properly positioned */
.terminal-container .xterm-screen {
  position: relative;
}

.terminal-container .xterm-screen canvas {
  position: absolute;
  left: 0;
  top: 0;
}

/* Fix for accessibility elements that might overlay - hide visually but keep focusable */
.terminal-container .xterm .xterm-accessibility,
.terminal-container .xterm .xterm-message {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: -1 !important;
  pointer-events: none !important;
  opacity: 0;
  /* Don't use visibility: hidden or display: none as it prevents keyboard input */
}

.terminal-container .xterm .xterm-helpers {
  z-index: -1;
  opacity: 0;
  pointer-events: none;
  /* Don't use visibility: hidden as it prevents keyboard input */
}

/* Enable text selection in terminal */
.terminal-container .xterm {
  user-select: text !important;
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
}

.terminal-container .xterm-screen {
  user-select: text !important;
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
}

.terminal-container .xterm-viewport {
  user-select: text !important;
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
}

.terminal-container .xterm-rows {
  user-select: text !important;
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  height: 100% !important;
}

/* Ensure the terminal screen and canvas are visible */
.terminal-container .xterm-screen {
  position: relative;
  z-index: 1;
}

.terminal-container .xterm-screen canvas {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
}

/* Empty State */
.empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-secondary);
  z-index: 1;
  max-width: 500px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-state.hidden {
  display: none !important;
}

.empty-state i {
  font-size: 72px;
  color: var(--accent-primary);
  margin-bottom: 20px;
  opacity: 0.7;
}

.empty-state h3 {
  font-size: 24px;
  margin-bottom: 12px;
  color: var(--text-primary);
  font-weight: 600;
}

.empty-state p {
  margin-bottom: 32px;
  font-size: 15px;
  color: var(--text-secondary);
}

.empty-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.empty-actions .btn {
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
  min-width: 180px;
}

.empty-actions .btn i {
  font-size: 16px;
  color: #fff;
  margin-right: 8px;
  line-height: 1;
  display: inline-block;
  transform: translateY(9px);
}

.empty-actions .btn-primary {
  background: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(193, 0, 89, 0.25);
}

.empty-actions .btn-primary:hover {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(193, 0, 89, 0.35);
  color: #fff;
}

.empty-actions .btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(193, 0, 89, 0.25);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  /* Use svh (small viewport height) for better mobile support */
  /* svh accounts for browser UI and prevents content from being cut off */
  height: 100svh;
  max-height: 100svh;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 500px;
  max-height: 90svh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-content.modal-sm {
  max-width: 400px;
}

.modal-content.modal-lg {
  max-width: 700px;
}

.modal-content.modal-large {
  max-width: 800px;
  max-height: 85svh;
}

.modal-content.modal-md {
  max-width: 560px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  font-size: 16px;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group > label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition-fast);
  cursor: pointer;
}

.form-group select {
  padding-right: 30px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="number"]:focus,
.form-group input[type="url"]:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.form-group textarea {
  font-family: var(--font-mono);
  font-size: 12px;
  resize: vertical;
}

.private-key-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.key-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.key-upload-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.key-upload-btn i {
  font-size: 11px;
}

.key-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  font-size: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.key-clear-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.key-format-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--accent-primary);
  color: #fff;
  white-space: nowrap;
}

.key-format-badge.format-warning {
  background: #e67e22;
}

.key-format-badge.format-error {
  background: #e74c3c;
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.flex-3 { flex: 3; }

.password-input {
  position: relative;
}

.password-input input {
  padding-right: 40px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}

.password-toggle:hover {
  color: var(--text-primary);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  user-select: none;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  width: fit-content;
  min-width: 200px;
}

.checkbox-label:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Custom checkbox */
.checkbox-label .checkbox-custom {
  position: relative;
  display: inline-block;
  width: 22px;
  height: 22px;
  min-width: 22px;
  max-width: 22px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  box-sizing: border-box;
  vertical-align: middle;
}

.checkbox-label:hover .checkbox-custom {
  border-color: var(--accent-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox-label .checkbox-custom::after {
  content: '';
  position: absolute;
  display: none;
  left: 7px;
  top: 3px;
  width: 6px;
  height: 11px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
  display: block;
}

.checkbox-label span:not(.checkbox-custom) {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 22px;
  vertical-align: middle;
  margin-left: 14px;
}

/* Icon Selector */
.icon-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.icon-option {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-secondary);
}

.icon-option:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.icon-option.selected {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.icon-option i {
  font-size: 18px;
}

/* Special Keys Grid */
.special-keys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.key-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.key-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.key-btn:active {
  transform: scale(0.95);
}

.key-combo {
  font-weight: 600;
  font-size: 12px;
}

.key-desc {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Speech-to-Text Modal */
.speech-to-text-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.speech-to-text-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.speech-to-text-controls .btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
}

.stt-btn-label {
  font-size: 13px;
  font-weight: 500;
}

/* Inline status indicator (spinner + label) shown in the controls row
   instead of a toast while the audio is being transcribed. */
.stt-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  margin-left: 4px;
}

.stt-status[hidden] {
  display: none;
}

.stt-status i {
  color: var(--accent-primary);
}

.stt-record-btn.recording {
  background: var(--accent-danger, #da3633);
  color: #fff;
  border-color: var(--accent-danger, #da3633);
}

.stt-record-btn.recording i {
  animation: stt-pulse 1.1s ease-in-out infinite;
}

.stt-record-btn.paused {
  background: var(--accent-warning, #d18616);
  color: #fff;
  border-color: var(--accent-warning, #d18616);
}

.stt-record-btn.paused i {
  animation: none;
}

@keyframes stt-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.speech-to-text-transcript {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  box-sizing: border-box;
  transition: var(--transition-fast);
}

.speech-to-text-transcript:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* SFTP Browser */
.sftp-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: var(--bg-secondary);
}

.sftp-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.sftp-path {
  display: flex;
  flex: 1;
  min-width: 200px;
}

.sftp-home-btn {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  padding: 8px 10px;
}

.sftp-path-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
}

.sftp-path-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.sftp-go-btn {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.sftp-actions {
  display: flex;
  gap: 8px;
}

.sftp-file-list {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-y: auto;
  margin-top: 12px;
  position: relative;
}

.sftp-file-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition-fast);
}

.sftp-file-item:last-child {
  border-bottom: none;
}

.sftp-file-item:hover {
  background: var(--bg-hover);
}

.sftp-file-item.selected {
  background: var(--bg-active);
}

.sftp-file-icon {
  width: 24px;
  margin-right: 12px;
  color: var(--text-secondary);
  text-align: center;
}

.sftp-file-icon.directory {
  color: var(--accent-warning);
}

.sftp-file-name {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sftp-file-size {
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: 12px;
}

.sftp-transfer-progress {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.sftp-transfer-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}

.sftp-transfer-icon {
  color: var(--accent-primary);
  width: 16px;
  text-align: center;
}

.sftp-transfer-filename {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  min-width: 0;
}

.sftp-transfer-count {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.sftp-transfer-size {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.sftp-transfer-percent {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13px;
  min-width: 40px;
  text-align: right;
  white-space: nowrap;
}

.sftp-transfer-cancel {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.sftp-transfer-cancel:hover {
  opacity: 1;
  color: var(--accent-danger, #e74c3c);
}

.sftp-transfer-bar {
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  overflow: hidden;
}

.sftp-transfer-bar-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 2px;
  transition: width 0.2s ease;
}

.sftp-container.drag-over .sftp-file-list {
  border-color: var(--accent-primary) !important;
  background: rgba(0, 123, 255, 0.05) !important;
}

.sftp-container.drag-over .sftp-file-list::after {
  content: 'Drop files here to upload';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-secondary);
  font-size: 14px;
  pointer-events: none;
}

.sftp-file-list.drag-over::after {
  content: 'Drop files here to upload';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-secondary);
  font-size: 14px;
  pointer-events: none;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-left: 3px solid var(--accent-success);
}

.toast.error {
  border-left: 3px solid var(--accent-danger);
}

.toast.warning {
  border-left: 3px solid var(--accent-warning);
}

.toast-icon {
  font-size: 16px;
}

.toast.success .toast-icon { color: var(--accent-success); }
.toast.error .toast-icon { color: var(--accent-danger); }
.toast.warning .toast-icon { color: var(--accent-warning); }

.toast-message {
  font-size: 13px;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* Responsive Design */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 100%;
    --header-height: 43px;
  }

  /* Thinner xterm scrollbar on mobile */
  .terminal-container .xterm-scrollable-element > .scrollbar {
    width: 4px !important;
    min-width: 4px !important;
    max-width: 4px !important;
  }
  .terminal-container .xterm-scrollable-element > .scrollbar.vertical {
    width: 4px !important;
    min-width: 4px !important;
    max-width: 4px !important;
  }
  .terminal-container .xterm-scrollable-element > .scrollbar > .slider {
    width: 4px !important;
    min-width: 4px !important;
    max-width: 4px !important;
    border-radius: 2px !important;
    /* Match the track background so the scrollbar blend in and doesn't
       look like a white line against the dark terminal background. */
    background-color: var(--terminal-scrollbar-track, #151b23) !important;
  }
  /* Also hide the viewport scrollbar more aggressively on mobile */
  .terminal-container .xterm-viewport {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  .terminal-container .xterm-viewport::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
  }

  .header {
    padding: 0 6px;
  }

  .logo {
    font-size: 16px;
    gap: 6px;
  }

  .logo i {
    font-size: 14px;
  }

  .logo-text {
    display: inline;
    font-size: 14px;
  }

  /* Show bookmark icon on mobile, hamburger on desktop */
  .desktop-menu-icon {
    display: none;
  }

  .mobile-menu-icon {
    display: inline-block;
  }

  /* Hide desktop-only controls on mobile */
  .desktop-only {
    display: none;
  }

  /* Show mobile overflow menu on mobile */
  .mobile-overflow-menu {
    display: block;
  }

  /* Hide desktop tabs on mobile */
  .tabs {
    display: none;
  }

  /* Show mobile tabs dropdown on mobile */
  .mobile-tabs-dropdown {
    display: flex;
    margin-left: 4px;
  }

  .mobile-force-resize-btn {
    display: flex;
    min-width: 28px;
    min-height: 28px;
    padding: 4px 6px;
    font-size: 12px;
  }

  .mobile-tabs-toggle {
    min-height: 28px;
    padding: 4px 6px;
    font-size: 12px;
  }

  .tabs-actions {
    padding: 0 4px;
  }

  .btn-text {
    display: none;
  }

  .header-left, .header-right {
    gap: 4px;
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    width: 100%;
    max-width: 300px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-normal);
  }

  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  .modal-content {
    max-width: 100%;
    margin: 10px;
    max-height: calc(100svh - 20px);
    width: calc(100% - 20px);
  }

  .modal-body {
    max-height: calc(100svh - 140px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Fallback for browsers without svh support */
  @supports not (height: 100svh) {
    .modal-content {
      max-height: calc(calc(var(--vh, 1vh) * 100) - 20px);
    }
    
    .modal-body {
      max-height: calc(calc(var(--vh, 1vh) * 100) - 140px);
    }
  }

  .form-row {
    flex-direction: column;
  }

  /* Hide bookmark action buttons (folder and 3-dot) on mobile */
  .bookmark-actions {
    display: none !important;
  }

  .empty-actions {
    flex-direction: column;
    align-items: center;
  }

  .empty-actions .btn {
    width: 100%;
    max-width: 280px;
  }

  .sftp-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .sftp-actions {
    justify-content: center;
  }

  .sftp-transfer-info {
    flex-wrap: wrap;
  }

  .sftp-transfer-cancel {
    font-size: 16px;
    padding: 4px 6px;
    margin-left: 4px;
  }

  .special-keys-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .toast-container {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }
}

@media (max-width: 480px) {
  .special-keys-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .key-btn {
    padding: 10px 6px;
  }

  .key-combo {
    font-size: 11px;
  }

  .key-desc {
    font-size: 9px;
  }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Keep tabs-actions buttons at 32px for consistency */
  .tabs-actions .btn-sm {
    min-height: 28px;
    min-width: 28px;
    padding: 4px 6px;
    font-size: 12px;
  }

  .tab {
    min-height: 44px;
  }

  .bookmark-item {
    min-height: 48px;
  }

  .key-btn {
    min-height: 60px;
  }

  .sftp-file-item {
    min-height: 48px;
  }
}

/* Settings Modal */
.settings-section {
  margin-bottom: 24px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.settings-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 16px;
}

.settings-group:last-child {
  margin-bottom: 0;
}

.settings-label {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.settings-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-accent-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.settings-accent-option {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.settings-accent-option:hover {
  border-color: var(--text-secondary);
  transform: scale(1.1);
}

.settings-accent-option.active {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px var(--accent-color);
}

.settings-accent-option .accent-color {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.settings-terminal-colors {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.settings-terminal-colors.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Security Info Modal - Service Worker Status */
.sw-status-card {
  flex-direction: column !important;
  align-items: center !important;
  text-align: center;
  padding: 24px 16px;
}

.sw-status-icon {
  font-size: 48px;
  margin-bottom: 12px;
  line-height: 1;
}

.sw-status-active .sw-status-icon {
  color: var(--accent-success);
}

.sw-status-failed .sw-status-icon {
  color: var(--accent-danger);
}

.sw-status-unsupported .sw-status-icon {
  color: var(--accent-warning);
}

.sw-status-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.sw-status-active .sw-status-title {
  color: var(--accent-success);
}

.sw-status-failed .sw-status-title {
  color: var(--accent-danger);
}

.sw-status-unsupported .sw-status-title {
  color: var(--accent-warning);
}

.sw-status-detail {
  max-width: 400px;
}

.sw-feature-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  text-align: left;
  display: inline-block;
}

.sw-feature-list li {
  padding: 3px 0;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sw-feature-list li i {
  width: 16px;
  text-align: center;
}

.sw-status-active .sw-feature-list li i {
  color: var(--accent-success);
}

.sw-status-failed .sw-feature-list li i,
.sw-status-unsupported .sw-feature-list li i {
  color: var(--accent-danger);
}

.sw-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

.sw-install-link {
  color: var(--accent-primary);
  text-decoration: underline !important;
}

.sw-install-link:hover {
  color: var(--accent-secondary);
  text-decoration: underline !important;
}

.sw-custom-cert-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-tertiary, rgba(255, 152, 0, 0.1));
  border: 1px solid var(--accent-warning, #d29922);
  border-radius: 6px;
  font-size: 13px;
  color: var(--accent-warning, #d29922);
  line-height: 1.4;
}

.sw-custom-cert-warning i {
  margin-top: 2px;
  flex-shrink: 0;
}

/* Settings Modal Styles */
.setting-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.setting-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.setting-label i {
  color: var(--accent-primary);
}

.setting-description {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.setting-control {
  display: flex;
  align-items: center;
  margin-top: 8px;
}

.setting-input {
  width: 150px;
  padding: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition-fast);
}

.setting-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
}

.setting-input::-webkit-outer-spin-button,
.setting-input::-webkit-inner-spin-button {
  opacity: 1;
}

/* Settings subgroups (used by Speech & AI category) */
.setting-subgroup {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.setting-subgroup-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.setting-subgroup-title i {
  color: var(--accent-primary);
}

/* Speech & AI category: URL / textarea inputs need full width */
#settings-category-speech-ai .setting-control {
  display: block;
}

#settings-category-speech-ai .setting-input,
#settings-category-speech-ai .password-input {
  width: 100%;
  box-sizing: border-box;
}

#settings-category-speech-ai .password-input {
  display: flex;
  align-items: center;
}

#settings-category-speech-ai .stt-prompt-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

/* Speech & AI settings profiles (fast-swap dropdown + save/delete row) */
#settings-category-speech-ai .speech-ai-profile-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#settings-category-speech-ai .speech-ai-profile-row .setting-input {
  flex: 1;
  min-width: 0;
}

#settings-category-speech-ai .speech-ai-profile-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.stt-prompt-textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-mono, monospace);
  line-height: 1.4;
  padding: 10px 12px;
  box-sizing: border-box;
}

.stt-prompt-reset {
  align-self: flex-end;
}

.debug-info-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.debug-info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.debug-info-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.debug-info-value {
  font-size: 13px;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
  background: var(--bg-tertiary);
  padding: 6px 10px;
  border-radius: 6px;
  word-break: break-all;
  border: 1px solid var(--border-color);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
  display: none;
}

.toggle-switch .toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  transition: var(--transition-fast);
  display: block;
}

.toggle-switch .toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: var(--transition-fast);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
  background: var(--accent-primary);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider::after {
  transform: translateX(20px);
}

/* Settings modal sidebar layout */
.modal-settings {
  max-width: 780px;
  max-height: 80svh;
  height: 80svh;
}

@supports not (height: 100svh) {
  .modal-settings {
    max-height: calc(var(--vh, 1vh) * 80);
    height: calc(var(--vh, 1vh) * 80);
  }
}

.modal-settings-layout {
  display: flex;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.settings-nav {
  width: 180px;
  min-width: 180px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 8px 0;
  background: var(--bg-tertiary);
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
  white-space: nowrap;
}

.settings-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.settings-nav-item.active {
  color: var(--accent-primary);
  background: var(--bg-secondary);
  border-right: 2px solid var(--accent-primary);
  font-weight: 600;
}

.settings-nav-item i {
  width: 16px;
  text-align: center;
  font-size: 13px;
}

.settings-panel {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  min-height: 0;
}

.settings-category-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 16px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.settings-category-title i {
  color: var(--accent-primary);
}

.settings-category .setting-item {
  margin-bottom: 12px;
}

.settings-category .setting-item:last-child {
  margin-bottom: 0;
}

/* Mobile: dropdown category selector */
.settings-mobile-category {
  display: none;
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

@media (max-width: 768px) {
  .modal-settings {
    max-width: 100%;
  }

  .modal-settings-layout {
    flex-direction: column;
  }

  .settings-nav {
    display: none;
  }

  .settings-mobile-category {
    display: block;
  }

  .settings-panel {
    padding: 12px 16px;
  }

  .modal-settings {
    height: auto;
    max-height: calc(100svh - 20px);
    max-width: 100%;
  }

  @supports not (height: 100svh) {
    .modal-settings {
      max-height: calc(calc(var(--vh, 1vh) * 100) - 20px);
    }
  }
}

.plugins-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plugins-loading {
  color: var(--text-secondary);
  font-size: 13px;
  padding: 8px 0;
}

.plugin-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  gap: 12px;
}

.plugin-card.missing {
  opacity: 0.55;
}

.plugin-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.plugin-card-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.plugin-card-description {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.plugin-card-missing {
  font-size: 11px;
  color: var(--accent-danger, #f85149);
  margin-top: 2px;
}

/* Mobile Keys Bar */
.mobile-keys-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  z-index: 40;
  padding: 2px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
  transition: bottom 0.2s ease;
  /* Prevent scrolling from moving the bar */
  transform: translateZ(0);
  will-change: bottom;
}

.mobile-keys-bar.visible {
  display: block;
}

.mobile-keys-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2px;
  margin-bottom: 2px;
}

.mobile-keys-row:last-child {
  margin-bottom: 0;
}

.mobile-key {
  flex: 1;
  min-width: 0;
  height: 34px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.1s ease, transform 0.1s ease;
  padding: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  /* Ensure button is clickable */
  pointer-events: auto;
}

.mobile-key:active {
  background: var(--bg-active);
  transform: scale(0.95);
}

.mobile-key.mobile-key-modifier {
  background: var(--bg-tertiary);
  border-color: var(--accent-primary);
  color: var(--text-secondary);
}

.mobile-key.mobile-key-modifier.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.mobile-key.mobile-key-arrow {
  font-size: 14px;
}

/* Mobile-only: Show keys bar */
@media (max-width: 768px) {
  .mobile-keys-bar.visible {
    display: block;
  }
  
  /* Prevent native vertical scroll on mobile - but allow xterm to scroll */
  html, body {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
    overscroll-behavior: none;
  }
  
  .app-container {
    overflow: hidden !important;
    overscroll-behavior: none;
    /* Use dvh for dynamic viewport height that accounts for keyboard */
    height: 100dvh;
    height: 100svh;
    height: calc(var(--vh, 1vh) * 100);
  }
  
  /* Main content should use flexbox to fill available space */
  .main-content {
    overflow: hidden !important;
    overscroll-behavior: none;
    /* Use flex to fill available space */
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flexbox to shrink */
    /* Remove fixed max-height - let flexbox handle it */
  }
  
  /* Terminal area should fill all available space in main-content */
  .terminal-area {
    overflow: hidden !important;
    overscroll-behavior: none;
    /* Fill available space in flex container */
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flexbox to shrink */
  }
  
  /* Mobile header/tabs hide/show on scroll */
  .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    /* Don't use flex - fixed positioning */
    flex: none;
  }
  
  .header.hidden {
    transform: none !important;
  }
  
  .tabs-container {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    z-index: 45; /* Lower than sidebar (z-index: 50) so sidebar appears on top */
    flex: none;
  }
  
  .tabs-container.hidden {
    transform: none !important;
  }
  
  /* Add padding to main-content to account for fixed header and tabs */
  .main-content {
    /* Header: 43px + 1px border, Tabs: 35px + 1px border = 80px total */
    padding-top: 80px;
    /* Account for mobile keys bar at bottom - use padding-bottom */
    padding-bottom: 75px;
  }
  
  /* When header is hidden, move tabs to top and adjust padding */
  .app-container.header-hidden .tabs-container {
    top: 0;
  }
  
  .app-container.header-hidden .main-content {
    /* Only tabs: 35px + 1px border = 36px */
    padding-top: 36px;
  }
  
  /* When both header and tabs are hidden, remove all padding */
  .app-container.header-hidden.tabs-hidden .main-content {
    padding-top: 0;
  }
  
  /* When mobile keys bar is hidden (e.g., for SFTP tabs), remove bottom padding */
  body.mobile-keys-bar-hidden .main-content {
    padding-bottom: 0 !important;
  }
  
  /* Ensure all containers fill the space when mobile keys bar is hidden */
  body.mobile-keys-bar-hidden .terminal-area {
    flex: 1;
  }
  
  body.mobile-keys-bar-hidden .terminals-container {
    flex: 1;
  }
  
  body.mobile-keys-bar-hidden .terminal-wrapper.active {
    /* Already positioned absolute to fill terminals-container */
  }
  
  body.mobile-keys-bar-hidden .sftp-container {
    flex: 1;
  }
}

/* Desktop: Hide mobile keys bar completely */
@media (min-width: 769px) {
  .mobile-keys-bar {
    display: none !important;
  }
}

/* Mobile keyboard visible state - adjust layout when keyboard is open */
@media (max-width: 768px) {
  /* Prevent layout scroll that could push fixed elements out of view */
  body.keyboard-visible {
    overflow: hidden !important;
  }

  body.keyboard-visible .header,
  body.keyboard-visible .tabs-container {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
  }

  body.keyboard-visible .header {
    top: var(--vv-offset-top, 0px) !important;
    z-index: 100 !important;
  }

  body.keyboard-visible .tabs-container {
    top: calc(var(--vv-offset-top, 0px) + var(--header-height, 43px)) !important;
    z-index: 45 !important;
  }

  body.keyboard-visible .main-content {
    /* Header and tabs stay fixed at top when keyboard is open */
    padding-top: 80px !important;
    /* Remove bottom padding since mobile keys bar is positioned above keyboard */
    padding-bottom: 0 !important;
  }

  /* When keyboard is visible and both header and tabs are hidden (shouldn't happen on keyboard, but keep for safety) */
  body.keyboard-visible.app-container.header-hidden.tabs-hidden .main-content,
  body.keyboard-visible .app-container.header-hidden.tabs-hidden .main-content {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  /* Adjust terminal area when keyboard is visible */
  body.keyboard-visible .terminal-area {
    /* Use the visual viewport height, minus header, tabs, and mobile keys bar */
    height: calc(var(--viewport-height, 100vh) - var(--header-height, 43px) - var(--mobile-keys-bar-height, 75px) - 37px);
    max-height: calc(var(--viewport-height, 100vh) - var(--header-height, 43px) - var(--mobile-keys-bar-height, 75px) - 37px);
  }

  /* Remove default spacing on terminal elements when keyboard is visible */
  body.keyboard-visible .terminal-area *,
  body.keyboard-visible .terminal-area *::before,
  body.keyboard-visible .terminal-area *::after {
    margin-bottom: -0.5px;
  }

  /* Ensure terminals container fills available space */
  body.keyboard-visible .terminals-container {
    flex: 1;
    min-height: 50px;
  }

  /* Ensure terminal wrapper fills available space */
  body.keyboard-visible .terminal-wrapper.active {
    min-height: 50px;
  }
}

/* Mobile-specific xterm styles to prevent native scroll interference */
@media (max-width: 768px) {
  .terminal-container {
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: pan-y; /* Allow vertical scrolling */
    -webkit-overflow-scrolling: touch;
    /* Fill available space in flex container */
    flex: 1;
    min-height: 100px; /* Ensure minimum height for initialization */
  }
  
  .terminal-container .xterm {
    overflow: hidden !important;
    touch-action: pan-y; /* Allow vertical scrolling */
    /* Fill available space */
    height: 100%;
    display: flex;
    flex-direction: column;
  }
  
  .terminal-container .xterm-viewport {
    overflow-y: hidden !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    touch-action: none;
    flex: 1;
    min-height: 0;
    height: auto !important;
    scrollbar-width: none;
  }
  
  .terminal-container .xterm-viewport::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
  
  .terminal-container .xterm-scrollable-element > .scrollbar {
    opacity: 1 !important;
    pointer-events: auto !important;
    transition: none !important;
    background-color: var(--terminal-scrollbar-track, #151b23) !important;
  }
  
  .terminal-container .xterm-scrollable-element > .scrollbar.invisible {
    opacity: 1 !important;
    pointer-events: auto !important;
    transition: none !important;
    background-color: var(--terminal-scrollbar-track, #151b23) !important;
  }
  
  .terminal-container .xterm-scrollable-element > .scrollbar > .slider {
    min-height: 30px !important;
    background-color: var(--terminal-scrollbar-thumb, #3d444d) !important;
  }
  
  .terminal-container .xterm-screen {
    height: 100% !important;
  }
  
  .terminal-container .xterm-rows {
    height: 100% !important;
  }
  
  .terminal-wrapper {
    /* Position absolute to fill terminals-container */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Allow overflow for selection handles */
    overflow: visible;
    min-height: 100px; /* Ensure minimum height for initialization */
    padding: 0; /* Remove padding on mobile to maximize terminal space */
  }
  
  /* Add bottom margin when keyboard is hidden */
  .terminal-wrapper.keyboard-hidden {
    padding-bottom: 4px;
  }
  
  .terminals-container {
    overflow: hidden !important;
    /* Fill available space in flex container */
    flex: 1;
    min-height: 100px; /* Ensure minimum height for initialization */
  }
  
  /* Add bottom margin when keyboard is hidden */
  .terminals-container.keyboard-hidden {
    padding-bottom: 4px;
  }
  
  /* SFTP container should fill available space on mobile */
  .sftp-container {
    flex: 1;
    min-height: 100px; /* Ensure minimum height for initialization */
  }
}

/* Terminal Control Overlay */
.terminal-control-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 17, 23, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.terminal-control-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
  max-width: 90%;
}

.terminal-control-icon {
  font-size: 48px;
  color: var(--text-secondary);
  opacity: 0.8;
}

.terminal-control-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.terminal-control-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.terminal-control-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.terminal-control-btn {
  margin-top: 8px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-control-btn i {
  font-size: 18px;
}

.terminal-control-manage {
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: underline;
  cursor: pointer;
  margin-top: 0;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.terminal-control-manage:hover {
  opacity: 1;
}

/* Light theme adjustments for control overlay */
[data-theme="light"] .terminal-control-overlay {
  background: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .terminal-control-icon {
  color: var(--text-secondary);
}

/* Sessions List Styles */
.sessions-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 4px;
}

.sessions-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.sessions-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.sessions-empty i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: var(--transition-fast);
}

.session-item:hover {
  border-color: var(--accent-primary);
}

.session-item:last-child {
  margin-bottom: 0;
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.session-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-name i {
  color: var(--accent-primary);
}

.session-name .session-type {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-primary);
  color: white;
  text-transform: uppercase;
  font-weight: 500;
}

.session-name .session-type.sftp {
  background: #2ea043;
}

.session-details {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 12px;
}

.session-detail {
  display: flex;
  align-items: center;
  gap: 4px;
}

.session-detail i {
  font-size: 10px;
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  transition: var(--transition-fast);
  font-size: 12px;
}

.session-close-btn:hover {
  background: var(--accent-danger);
  color: #fff;
}

/* NOTE: .btn-danger is defined once, near the other button styles.
   A second definition used to live here using an undefined
   `--danger-color`; that made `background` invalid at computed-value
   time (→ transparent) while still forcing `color: white`, so the
   Logout button rendered as white text on the light modal background. */

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

/* Print styles */
@media print {
  .sidebar,
  .header,
  .tabs-container,
  .modal,
  .mobile-keys-bar {
    display: none !important;
  }

  .terminal-area {
    height: auto;
    overflow: visible;
  }
}

/* Update Overlay */
.update-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.update-overlay.active {
  display: flex;
}

.update-overlay-content {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 40px 50px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
}

.update-spinner {
  font-size: 48px;
  color: var(--accent-primary);
  margin-bottom: 20px;
}

.update-title {
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 12px 0;
}

.update-message {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 24px 0;
  line-height: 1.5;
}

.update-progress {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 16px;
}

.update-progress-bar {
  height: 100%;
  background: var(--accent-primary);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 2px;
}

.update-status {
  color: var(--text-secondary);
  font-size: 12px;
  margin: 0;
  font-family: monospace;
}

/* Light theme adjustments for update overlay */
[data-theme="light"] .update-overlay {
  background: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .update-overlay-content {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* Mobile-friendly context menu styles */
@media (max-width: 768px) {
  .terminal-context-menu {
    min-width: 160px;
  }
  
  .terminal-context-menu-item {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  .terminal-context-menu-item i {
    width: 20px;
    font-size: 16px;
  }
  
  /* Enable native touch selection on mobile for terminal */
  .terminal-container .xterm,
  .terminal-container .xterm-screen,
  .terminal-container .xterm-rows,
  .terminal-container .xterm-helpers {
    -webkit-touch-callout: default !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    touch-action: manipulation !important;
  }
  
  .terminal-container .xterm-viewport {
    touch-action: none !important;
  }
  
  /* Allow text selection in terminal on mobile */
  .terminal-container {
    -webkit-touch-callout: default !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
  }
}

/* Paste modal for HTTP contexts */
.paste-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

.paste-modal-content {
  background: var(--bg-primary);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  animation: slideIn 0.2s ease;
}

.paste-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.paste-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.paste-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.paste-modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.paste-modal-body {
  padding: 20px;
}

.paste-modal-body p {
  margin: 0 0 12px 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.paste-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.paste-textarea:focus {
  border-color: var(--accent-primary);
}

.paste-textarea::placeholder {
  color: var(--text-tertiary);
}

.paste-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.paste-modal-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.paste-modal-cancel {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.paste-modal-cancel:hover {
  background: var(--bg-secondary);
}

.paste-modal-submit {
  background: var(--accent-primary);
  color: white;
}

.paste-modal-submit:hover {
  background: var(--accent-secondary);
}

/* Light theme adjustments for paste modal */
[data-theme="light"] .paste-modal {
  background: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .paste-modal-content {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* ============================================
   MOBILE TERMINAL SELECTION AND CONTEXT MENU
   ============================================ */

/* Mobile terminal padding - add space around terminal text */
@media (max-width: 768px), (pointer: coarse) {
  .terminal-container .xterm {
    padding: 6px 8px !important;
  }
  
  .terminal-container .xterm-viewport {
    padding: 6px 8px !important;
  }
  
  .terminal-container .xterm-screen {
    padding: 6px 8px !important;
  }
}

/* Mobile selection overlay - highlights selected text */
.mobile-selection-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.mobile-selection-rect {
  position: absolute;
  background: rgba(38, 79, 120, 0.4);
  border: 1px solid rgba(38, 79, 120, 0.6);
  border-radius: 2px;
}

/* Mobile selection handles - draggable anchors */
.mobile-selection-handle {
  position: absolute;
  width: 24px;
  height: 24px;
  z-index: 100;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.mobile-selection-handle-start {
  transform: translate(-50%, 0%);
}

.mobile-selection-handle-end {
  transform: translate(-50%, 0%);
}

.handle-visual {
  width: 100%;
  height: 100%;
  background: var(--accent-primary, #c10059);
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-radius 0.15s ease;
}

.mobile-selection-handle-start .handle-visual {
  border-radius: 12px 2px 12px 12px;
}

.mobile-selection-handle-end .handle-visual {
  border-radius: 2px 12px 12px 12px;
}

.mobile-selection-handle.active .handle-visual {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Mobile context menu - single row with buttons */
.mobile-context-menu {
  position: fixed;
  background: var(--bg-secondary, #161b22);
  border: 1px solid var(--border-color, #30363d);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 10000;
  padding: 3px;
  animation: mobile-menu-fade-in 0.15s ease;
}

@keyframes mobile-menu-fade-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Single row menu layout */
.mobile-menu-row {
  display: flex;
  align-items: center;
  gap: 1px;
}

/* Drag handle for context menu */
.mobile-menu-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
  cursor: grab;
  color: var(--text-secondary, #8b949e);
  border-bottom: 1px solid var(--border-color, #30363d);
  margin-bottom: 2px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-drag-handle:active {
  cursor: grabbing;
}

.mobile-menu-drag-handle i {
  font-size: 8px;
}

/* Menu buttons with icons and text */
.mobile-menu-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 4px 6px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-primary, #e6edf3);
  font-size: 9px;
  cursor: pointer;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  min-width: 30px;
}

.mobile-menu-btn:hover {
  background: var(--bg-tertiary, #21262d);
}

.mobile-menu-btn:active {
  background: var(--accent-primary, #c10059);
  color: white;
}

.mobile-menu-btn i {
  font-size: 12px;
  color: var(--text-secondary, #8b949e);
}

.mobile-menu-btn:active i {
  color: white;
}

.mobile-menu-btn span {
  font-size: 8px;
  font-weight: 500;
}

/* Hidden textarea for mobile keyboard input */
.mobile-hidden-textarea {
  position: fixed !important;
  left: -9999px !important;
  top: 0 !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  font-size: 16px !important; /* Prevent zoom on iOS */
}

/* Mobile-specific terminal adjustments */
@media (max-width: 768px) {
  /* Ensure terminal container allows for selection handles */
  .terminal-container {
    position: relative;
    overflow: visible;
  }
  
  /* Terminal wrapper needs to contain selection elements */
  /* Keep position: absolute to fill the terminals-container */
  .terminal-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: visible;
  }
  
  /* Disable native text selection in terminal on mobile */
  .terminal-container .xterm {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  
  /* Note: xterm-viewport scrolling is handled by the earlier mobile-specific styles (lines 3586-3600) */
  /* Selection handles are positioned absolutely and don't need overflow: visible on viewport */
  
  /* Ensure selection handles are visible above terminal */
  .xterm-screen {
    z-index: 1;
  }
  
  /* Mobile context menu adjustments */
  .mobile-context-menu {
    max-width: calc(100vw - 32px);
    padding: 4px;
    border-radius: 6px;
  }
  
  .mobile-menu-drag-handle {
    padding: 3px 0;
  }

  .mobile-menu-drag-handle i {
    font-size: 10px;
  }

  .mobile-menu-btn {
    padding: 5px 8px;
    font-size: 12px;
    min-width: 39px;
    min-height: 47px;
    gap: 2px;
  }

  .mobile-menu-btn i {
    font-size: 16px;
  }

  .mobile-menu-btn span {
    font-size: 10px;
  }
}

/* Light theme adjustments for mobile elements */
[data-theme="light"] .mobile-selection-rect {
  background: rgba(38, 79, 120, 0.3);
  border-color: rgba(38, 79, 120, 0.5);
}

[data-theme="light"] .mobile-context-menu {
  background: #ffffff;
  border-color: #d0d7de;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .mobile-menu-btn {
  color: #24292f;
}

[data-theme="light"] .mobile-menu-btn:hover {
  background: #f6f8fa;
}

[data-theme="light"] .mobile-menu-btn i {
  color: #656d76;
}

/* Lock Screen */
.lock-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lock-screen-content {
  text-align: center;
  width: 100%;
  max-width: 360px;
  padding: 40px 24px;
}

.lock-screen-icon {
  font-size: 48px;
  color: var(--accent-primary);
  margin-bottom: 16px;
}

.lock-screen-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.lock-screen-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 32px;
}

.lock-screen-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lock-screen-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  box-sizing: border-box;
  transition: border-color var(--transition-fast);
}

.lock-screen-input:focus {
  border-color: var(--accent-primary);
}

.lock-screen-submit {
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
}

.lock-screen-error {
  color: var(--accent-danger);
  font-size: 13px;
  margin-top: 8px;
}

/* Password disclaimer */
.password-disclaimer {
  background: rgba(210, 153, 34, 0.1);
  border: 1px solid rgba(210, 153, 34, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--accent-warning);
}

.password-disclaimer i {
  margin-right: 4px;
}

.password-disclaimer strong {
  color: var(--accent-warning);
}