/* === Fonts === */
@font-face {
  font-family: 'JetBrains Mono';
  src: url('lib/fonts/jetbrains-mono-latin-ext-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-024F;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('lib/fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('lib/fonts/jetbrains-mono-latin-ext-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-024F;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('lib/fonts/jetbrains-mono-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* === Design Tokens (Linear Dark) === */
:root {
  /* Background layers */
  --bg-canvas:   #08090a;
  --bg-surface:  #0f1011;
  --bg-elevated: #1a1b1e;
  --bg-hover:    var(--bg-elevated);

  /* Borders */
  --border-color:     #1c1d20;
  --border:           #1c1d20;
  --border-hover:     #2a2b2d;
  --border-active:    #5e6ad2;
  --border-subtle:    #1c1d20;

  /* Text */
  --text-primary:   #e5e5e5;
  --text-secondary: #888888;
  --text-muted:     #555555;

  /* Accent */
  --accent:        #5e6ad2;
  --accent-hover:  #6e7adf;
  --accent-dim:    rgba(94, 106, 210, 0.16);
  --accent-alpha:  rgba(94, 106, 210, 0.22);
  --accent-bg:     rgba(94, 106, 210, 0.18);
  --accent-fg:     #a9b0e0;

  /* Status colors */
  --success:      #3dd4a2;
  --success-dim:  rgba(61, 212, 162, 0.12);
  --danger:       #ff6b6b;
  --danger-dim:   rgba(255, 107, 107, 0.12);
  --warning:      #f5bf64;
  --highlight:    rgba(245, 191, 100, 0.3);

  /* Font sizes (Linear scale) */
  --fs-xs:  11px;
  --fs-sm:  12px;
  --fs-md:  13px;
  --fs-lg:  14px;
  --fs-xl:  16px;
  --fs-2xl: 20px;
  --fs-3xl: 24px;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --r-sm: var(--radius-sm);
  --r-md: var(--radius-md);
  --r-lg: var(--radius-lg);
  --r-xl: var(--radius-xl);

  /* Spacing (base-4) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 28px;
  --sp-8: 32px;

  /* Motion */
  --transition-fast:   100ms cubic-bezier(.4, 0, .2, 1);
  --transition-normal: 150ms cubic-bezier(.4, 0, .2, 1);
  --transition-slow:   200ms cubic-bezier(.4, 0, .2, 1);
  --t-fast:   100ms;
  --t-normal: 150ms;
  --t-slow:   200ms;
  --ease: cubic-bezier(.4, 0, .2, 1);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-soft: var(--shadow-sm);

  /* Fonts */
  --font-sans: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;

  /* Backward-compatible aliases (old tokens → new tokens) */
  --bg-primary:    var(--bg-canvas);
  --bg-secondary:  var(--bg-surface);
  --bg-tertiary:   var(--bg-elevated);
  --bg-input:      var(--bg-elevated);
  --surface-0:     var(--bg-canvas);
  --surface-1:     var(--bg-surface);
  --surface-2:     var(--bg-elevated);
  --surface-3:     var(--bg-hover);
  --glass-bg:      var(--bg-surface);
  --glass-border:  var(--border);
  --sidebar-bg:    var(--bg-surface);
  --canvas-glow:   none;
  --panel-glass:   0;
  --card-bg:       var(--bg-elevated);
  --sidebar-width: 200px;

  /* Theme switch hooks (keep for compatibility) */
  --glass-blur: 0px;
}

/* Linear Dark — explicit theme (default) */
[data-theme="linear-dark"] {
  /* All tokens defined in :root above */
}


/* === Wallpaper support === */
#main {
  position: fixed;
  left: var(--sidebar-width); top: 0; right: 0; bottom: 0;
  background:
    linear-gradient(180deg, rgba(5, 11, 19, 0.96) 0%, rgba(4, 9, 17, 0.98) 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Wallpaper layer — sits behind everything in #main */
#wallpaper-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}
#wallpaper-layer.active {
  opacity: 1;
}

#main::before,
#main::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#main::before {
  background: var(--canvas-glow);
  opacity: 1;
  z-index: 0;
}

#main::after {
  background:
    linear-gradient(90deg, rgba(4, 10, 18, 0.08) 0, rgba(4, 10, 18, 0.08) 1px, transparent 1px, transparent 100%),
    linear-gradient(180deg, rgba(4, 10, 18, 0.08) 0, rgba(4, 10, 18, 0.08) 1px, transparent 1px, transparent 100%);
  background-size: 32px 32px;
  opacity: 0.18;
  mix-blend-mode: screen;
  z-index: 0;
}

/* Ensure #main children are above wallpaper, but don't override panel z-index.
   #workspace-window-layer must stay fixed + high z-index, so it is excluded
   here — otherwise the floating windows get clipped by #main's overflow. */
#main > *:not(#wallpaper-layer):not([id$="-panel"]):not(#terminal-loading):not(#workspace-window-layer) {
  position: relative;
  z-index: 1;
}

/* Terminal becomes semi-transparent when wallpaper is set */
body.has-wallpaper #terminal-container .xterm-screen {
  opacity: 1;
}

/* === Theme panel === */
#theme-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
#theme-panel.hidden { display: none; }

.theme-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16, 27, 43, 0.98), rgba(12, 20, 33, 0.92));
  flex-shrink: 0;
}
.theme-header h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}
.theme-header button {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.theme-header button:hover {
  color: var(--danger);
}

.theme-body {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.theme-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border-subtle);
  background: rgba(14, 24, 39, 0.88);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.14);
}
.theme-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0;
}

/* Theme card grid */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.theme-card {
  position: relative;
  padding: 14px 13px;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  background: rgba(12, 21, 35, 0.78);
  cursor: pointer;
  transition: border-color 200ms ease, transform 150ms ease, box-shadow 200ms ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.theme-card:hover {
  border-color: rgba(131, 166, 208, 0.24);
  transform: translateY(-1px);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.14);
}
.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(110, 182, 255, 0.18), 0 18px 28px rgba(0, 0, 0, 0.18);
}

.theme-card-name {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.theme-card-check {
  color: var(--accent);
  font-size: 16px;
}

.theme-card-preview {
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
}

.theme-card-linear .theme-card-preview {
  background: linear-gradient(135deg, #08090a 0%, #1a1b1e 50%, #5e6ad2 100%);
}

/* Wallpaper section */
.wallpaper-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wallpaper-upload-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(131, 166, 208, 0.12);
  background: rgba(8, 15, 25, 0.72);
}

.wallpaper-upload-btn {
  min-height: 40px;
  padding: 9px 14px;
  background: rgba(18, 30, 46, 0.86);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}
.wallpaper-upload-btn:hover {
  background: rgba(24, 39, 60, 0.92);
  border-color: rgba(131, 166, 208, 0.22);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.wallpaper-url-input {
  flex: 1;
  min-height: 40px;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.wallpaper-url-input:focus { border-color: var(--accent); }
.wallpaper-url-input::placeholder { color: var(--text-muted); }

.wallpaper-apply-btn {
  min-height: 40px;
  padding: 9px 14px;
  background: var(--accent);
  color: #04111e;
  border: none;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}
.wallpaper-apply-btn:hover {
  filter: brightness(1.06);
  box-shadow: 0 12px 24px rgba(72, 149, 230, 0.24);
  transform: translateY(-1px);
}

.wallpaper-preview-row {
  display: flex;
  align-items: stretch;
  gap: 14px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(131, 166, 208, 0.12);
  background: rgba(8, 15, 25, 0.76);
}

.wallpaper-thumb {
  width: 138px;
  height: 88px;
  border-radius: 14px;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.wallpaper-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.wallpaper-slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wallpaper-slider-group label {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.wallpaper-slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.wallpaper-clear-btn {
  min-height: 38px;
  padding: 8px 12px;
  background: var(--danger-dim);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--danger);
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}
.wallpaper-clear-btn:hover {
  background: rgba(248, 113, 113, 0.2);
  transform: translateY(-1px);
}

/* === Shared Components === */

/* Unified panel header */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  gap: 10px;
  flex-shrink: 0;
}
.panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  margin: 0;
}

/* Unified close button */
.panel-close-btn {
  background: none; border: none; color: var(--text-secondary);
  font-size: 20px; cursor: pointer; padding: 0 4px;
  transition: color var(--transition-fast);
  line-height: 1;
}
.panel-close-btn:hover { color: var(--danger); }

/* Empty / loading states */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
  font-size: 13px;
}
.loading-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-title {
  margin: 0 0 16px;
  font-size: 16px;
  color: var(--text-primary);
  font-weight: 600;
}

.modal-option-btn {
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color 150ms ease;
}
.modal-option-btn:hover { border-color: var(--accent); }

/* Panel fade-in animation */
@keyframes panelFadeIn {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Panels animate in when revealed */
#file-panel:not(.hidden),
#memory-panel:not(.hidden),
#tunnel-panel:not(.hidden),
#scheduler-panel:not(.hidden),
#commands-panel:not(.hidden),
#cache-panel:not(.hidden),
#git-panel:not(.hidden),
#theme-panel:not(.hidden),
#model-panel:not(.hidden),
#workspace-panel:not(.hidden) {
  animation: panelFadeIn 180ms ease-out;
}

/* === Reset === */
html, body, #sidebar, #main, #connect-modal, .modal-content,
.sidebar-header, #session-list, .sidebar-footer,
#no-session, #terminal-container, .form-group, #btn-connect,
.session-close, .session-dot, .session-name,
.history-header, #history-list, .history-item, #history-panel {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

:focus:not(:focus-visible) {
  outline: none;
}

input, textarea, button, select {
  font: inherit;
}

code, pre, kbd, samp,
#terminal-status,
#file-path-input,
.file-breadcrumb,
#file-preview-name,
#file-preview-content,
#memory-file-body code,
.conv-text code,
.conv-file-path,
.plan-file-bar .conv-file-path,
.plan-content code,
.tunnel-card-addr,
#text-input,
.cmd-text,
.cmd-edit-text {
  font-family: var(--font-mono);
  font-weight: 400;
  font-style: normal;
  font-synthesis: none;
  letter-spacing: 0;
}

/* Protect xterm.js internals */
.xterm .xterm-screen { line-height: normal; }
.xterm {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.xterm-viewport {
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* === Sidebar === */
#sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 200px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  z-index: 20;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: width var(--transition-slow);
  overflow: hidden;
}

/* Sidebar collapsed: icon strip */
#sidebar.collapsed { width: 48px; }
#sidebar.hidden    { width: 0; border-right: none; }

#sidebar.collapsed .sidebar-header h2,
#sidebar.collapsed .session-name,
#sidebar.collapsed .session-close,
#sidebar.collapsed .session-rename,
#sidebar.collapsed .session-move,
#sidebar.collapsed .session-more,
#sidebar.collapsed .session-agent-badge,
#sidebar.collapsed .session-time,
#sidebar.hidden .sidebar-header,
#sidebar.hidden #session-list,
#sidebar.hidden .sidebar-footer {
  display: none;
}

#sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 12px 0 8px;
  min-height: 58px;
  gap: 0;
}

#sidebar.collapsed .header-buttons {
  width: 100%;
  justify-content: center;
}

#sidebar.collapsed #btn-devices {
  width: 34px;
  height: 34px;
}

#sidebar.collapsed #session-list {
  padding: 10px 7px 12px;
  overflow: visible auto;
}

/* In collapsed mode, session items show as colored dots */
#sidebar.collapsed .session-item {
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  margin: 0 auto 4px;
  position: relative;
  gap: 0;
  border-radius: 12px;
  border-left-width: 1px;
}
#sidebar.collapsed .session-item::before {
  content: none;
}
#sidebar.collapsed .session-dot {
  width: 8px;
  height: 8px;
  margin: 0;
}
#sidebar.collapsed .session-item.active .session-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(94, 106, 210, 0.18), 0 0 10px rgba(94, 106, 210, 0.5);
}
#sidebar.collapsed .session-item:hover {
  transform: none;
}
#sidebar.collapsed .session-item:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  max-width: 260px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(15, 16, 17, 0.96);
  border: 1px solid rgba(131, 166, 208, 0.18);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.32);
  z-index: 80;
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 14px 14px 18px;
  border-bottom: 1px solid var(--border);
  overflow: visible;
  gap: 12px;
  min-height: 66px;
  flex-shrink: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0) 100%),
    linear-gradient(180deg, rgba(6, 14, 24, 0.16) 0%, rgba(6, 14, 24, 0) 100%);
}

.sidebar-header h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-primary);
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: block;
  opacity: 0.94;
}

.header-buttons {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.header-buttons button, #btn-toolbar-menu {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(131, 166, 208, 0.16);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

#btn-devices {
  color: var(--text-primary);
}

#btn-devices svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
}

.header-buttons button:hover, #btn-toolbar-menu:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.035));
  color: var(--text-primary);
  border-color: var(--border-hover);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

/* Toolbar dropdown menu */
.toolbar-menu-wrapper {
  position: relative;
}
/* Hide deprecated toolbar menu (migrated to topbar) */
.toolbar-menu-wrapper { display: none; }

.toolbar-dropdown {
  position: fixed;
  top: 0;
  left: 0;
  background:
    linear-gradient(180deg, rgba(14, 24, 39, 0.98) 0%, rgba(10, 18, 30, 0.96) 100%);
  border: 1px solid rgba(131, 166, 208, 0.16);
  border-radius: 16px;
  box-shadow: 0 22px 56px rgba(0, 0, 0, 0.34);
  z-index: 120;
  min-width: 176px;
  max-width: min(228px, calc(100vw - 16px));
  padding: 10px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.toolbar-dropdown.hidden { display: none; }

.toolbar-dropdown button {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  height: auto;
  text-align: left;
  font-family: var(--font-sans);
  font-weight: 500;
}

.toolbar-dropdown button:hover {
  background: linear-gradient(135deg, rgba(110, 182, 255, 0.14), rgba(110, 182, 255, 0.06));
  color: var(--text-primary);
  box-shadow: none;
  border-color: transparent;
}

.toolbar-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.toolbar-icon-text {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 700;
}

.toolbar-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#session-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 14px;
}

.session-item {
  display: flex;
  align-items: center;
  padding: 13px 13px;
  cursor: pointer;
  position: relative;
  gap: 10px;
  font-size: 13px;
  border: 1px solid rgba(131, 166, 208, 0.04);
  border-left: 2px solid transparent;
  border-radius: 14px;
  margin-bottom: 8px;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
  color: var(--text-secondary);
  z-index: 0;
}

.session-item:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  color: var(--text-primary);
  border-color: rgba(136, 180, 235, 0.12);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.14);
  transform: translateX(1px);
}

.session-item.active {
  background: linear-gradient(135deg, rgba(110, 182, 255, 0.18), rgba(110, 182, 255, 0.06));
  border-left-color: var(--accent);
  border-color: rgba(110, 182, 255, 0.2);
  color: var(--text-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 24px rgba(0, 0, 0, 0.16);
}

.session-item.menu-open {
  z-index: 150;
}

.session-item.dragging {
  opacity: 0.4;
}

.session-item[draggable="true"] {
  cursor: grab;
}

.session-item[draggable="true"]:active {
  cursor: grabbing;
}

.session-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  transition: background var(--transition-fast);
  margin-top: 1px;
}

.session-dot.running {
  background: var(--success);
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.4);
  animation: breathe 2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 4px rgba(52, 211, 153, 0.3); }
  50% { box-shadow: 0 0 8px rgba(52, 211, 153, 0.6); }
}

.session-dot.exited { background: var(--danger); }

.session-name {
  flex: 1; overflow: hidden; min-width: 0;
  font-family: var(--font-sans);
  font-weight: 500;
}

.session-content {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.session-title-row,
.session-meta-row {
  display: flex;
  align-items: center;
  min-width: 0;
}

.session-title-row {
  gap: 8px;
}

.session-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.session-meta-row {
  gap: 6px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1;
}

.session-kind,
.session-cwd,
.session-agent-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 2px 6px;
  font-size: 9px;
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.2;
  border-radius: 999px;
}

.session-kind {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.session-kind.kind-claude {
  color: #d8c3ff;
  background: rgba(168, 139, 250, 0.13);
}

.session-kind.kind-codex {
  color: #9fd4ff;
  background: rgba(110, 182, 255, 0.13);
}

.session-kind.kind-shell {
  color: var(--text-muted);
}

.session-cwd {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.session-agent-badge {
  background: rgba(110, 182, 255, 0.1);
  color: var(--accent);
  flex-shrink: 0;
}

.session-close {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 13px; padding: 2px 4px; border-radius: var(--radius-sm);
  display: none; transition: color 150ms ease, background 150ms ease;
}

.session-rename {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 13px; padding: 2px 4px; border-radius: var(--radius-sm);
  display: none; transition: color 150ms ease, background 150ms ease;
}

.session-item:hover .session-close,
.session-item:hover .session-rename { display: block; }
.session-close:hover { color: var(--danger); background: var(--danger-dim); }
.session-rename:hover { color: var(--accent); background: var(--accent-dim); }

.session-move {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 10px; padding: 2px 4px; border-radius: var(--radius-sm);
  display: none; transition: color 150ms ease, background 150ms ease;
}
.session-item:hover .session-move { display: block; }
.session-move:hover { color: var(--accent); background: var(--accent-dim); }

/* Sidebar toggle chevron button */
.sidebar-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}
.sidebar-toggle:hover { color: var(--text-primary); background: var(--bg-hover); }

/* Session more menu (replaces inline rename/up/down/close buttons) */
.session-more {
  display: none;
  width: 24px; height: 24px;
  border: none; background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.session-item:hover .session-more { display: flex; }
.session-item.menu-open .session-more { display: flex; color: var(--text-primary); background: var(--bg-hover); }
.session-more:hover { color: var(--text-primary); background: var(--bg-hover); }

.session-more-menu {
  position: absolute;
  right: 8px; top: 36px;
  background: rgba(8, 15, 25, 0.98);
  border: 1px solid rgba(131, 166, 208, 0.22);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.04);
  z-index: 120;
  min-width: 140px;
  padding: 4px;
  pointer-events: auto;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.session-more-menu.hidden { display: none; }
.session-more-menu button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 10px;
  border: none; background: rgba(255, 255, 255, 0.025);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.session-more-menu button:hover { background: var(--bg-hover); }
.session-more-menu button[data-action="close"] { color: var(--danger); }

/* Session relative time */
.session-time {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
}

/* Adjust main area when sidebar changes width */
#main {
  transition: left var(--transition-slow);
}

.sidebar-footer {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.035) 100%),
    linear-gradient(180deg, rgba(6, 14, 24, 0) 0%, rgba(6, 14, 24, 0.18) 100%);
}

#sidebar.collapsed .sidebar-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0 12px;
  min-height: 56px;
  border-top-color: rgba(131, 166, 208, 0.08);
}

#sidebar.collapsed #connection-status {
  display: none;
}

#btn-fit {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(131, 166, 208, 0.16);
  color: var(--text-secondary);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 11px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

#btn-fit:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

#sidebar.collapsed #btn-fit {
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
}

#sidebar.collapsed #btn-fit::before {
  content: '⛶';
  font-size: 15px;
  line-height: 1;
}

#connection-status {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-sans);
  font-weight: 700;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(131, 166, 208, 0.1);
}

#connection-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-connected { color: var(--success); }
.status-connected::before { background: var(--success); box-shadow: 0 0 6px rgba(52, 211, 153, 0.5); }
.status-connected.agent-build-mismatch {
  color: var(--warning);
  border-color: rgba(245, 191, 100, 0.35);
  background: rgba(245, 191, 100, 0.08);
}
.status-connected.agent-build-mismatch::before {
  background: var(--warning);
  box-shadow: 0 0 8px rgba(245, 191, 100, 0.5);
}
.status-disconnected { color: var(--danger); }
.status-disconnected::before { background: var(--danger); }
.status-connecting { color: var(--warning); }
.status-connecting::before { background: var(--warning); animation: pulse 1.2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* === Main area === */
/* (see wallpaper section above for #main base styles) */

#no-session {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted); font-size: 14px;
  flex-direction: column;
  gap: 22px;
  padding: 54px 36px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

#no-session::before {
  content: '';
  position: absolute;
  inset: 18px 20px 18px 20px;
  border-radius: 34px;
  border: 1px solid rgba(131, 166, 208, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.015) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}

.no-session-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 760px;
}

#no-session .icon {
  font-size: 17px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.76;
  color: var(--accent);
  animation: float 3s ease-in-out infinite;
  position: relative;
  z-index: 1;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(110, 182, 255, 0.22);
  background: rgba(9, 18, 31, 0.72);
  box-shadow: 0 18px 34px rgba(5, 11, 19, 0.28);
}

.no-session-orb {
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 30%, rgba(110, 182, 255, 0.22), transparent 58%),
    radial-gradient(circle at 70% 70%, rgba(44, 88, 148, 0.18), transparent 64%);
  filter: blur(32px);
  opacity: 0.82;
}

.no-session-orb-primary {
  top: 4%;
  left: 10%;
}

.no-session-orb-secondary {
  right: 8%;
  bottom: 8%;
  width: 420px;
  height: 420px;
  opacity: 0.42;
}

.no-session-copy {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  padding: 34px 38px;
  border-radius: 32px;
  background:
    linear-gradient(180deg, rgba(14, 24, 38, 0.9) 0%, rgba(10, 18, 31, 0.8) 100%);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.no-session-copy::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), transparent 40%);
}

.no-session-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(110, 182, 255, 0.08);
  border: 1px solid rgba(110, 182, 255, 0.14);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.no-session-copy h1 {
  margin: 0 0 12px;
  font-size: clamp(36px, 5vw, 58px);
  line-height: 0.98;
  letter-spacing: -0.045em;
  color: var(--text-primary);
}

.no-session-copy p {
  margin: 0;
  font-size: 15px;
  line-height: 1.9;
  color: var(--text-secondary);
  max-width: 620px;
  margin-inline: auto;
}

.no-session-actions {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.no-session-actions button {
  min-height: 50px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(10, 19, 31, 0.86);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.no-session-actions button:hover {
  transform: translateY(-1px);
  border-color: var(--border-hover);
  color: var(--text-primary);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.2);
}

.no-session-actions .no-session-primary {
  background: linear-gradient(135deg, #4e9dff, #79cbff);
  border-color: transparent;
  color: #04111e;
  box-shadow: 0 16px 36px rgba(57, 132, 214, 0.28);
}

.no-session-actions .no-session-primary:hover {
  color: #04111e;
  border-color: transparent;
}

.no-session-tips {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 760px;
}

.no-session-tips span {
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(10, 18, 31, 0.72);
  border: 1px solid rgba(131, 166, 208, 0.12);
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

#terminal-wrapper {
  display: flex;
  flex: 1;
  min-height: 0;
  margin: 12px 12px 8px;
  gap: 4px;
  position: relative;
}

#terminal-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 12px 12px 8px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background:
    linear-gradient(180deg, rgba(12, 19, 31, 0.9) 0%, rgba(7, 13, 22, 0.96) 100%);
  border-radius: 22px 22px 18px 18px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 26px 58px rgba(0, 0, 0, 0.28);
  margin: 0;
  overflow: hidden;
}

#terminal-container::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0) 20%);
}

#terminal-container .xterm {
  flex: 1;
  min-height: 0;
  text-rendering: geometricPrecision;
}

#terminal-container .xterm-screen,
#terminal-container .xterm-viewport {
  min-height: 0;
}

#terminal-container .xterm-rows,
#terminal-container .xterm-helper-textarea {
  font-synthesis: none;
  letter-spacing: 0;
}

/* Terminal transparent when wallpaper is active */
body.has-wallpaper #terminal-wrapper {
  background: transparent;
}
body.has-wallpaper #terminal-container {
  background: transparent;
}
body.has-wallpaper #terminal-container .xterm-viewport {
  background: transparent !important;
}
body.has-wallpaper #terminal-scrollbar {
  background: transparent;
  border-color: transparent;
}
body.has-wallpaper #no-session {
  background: transparent;
}

/* Terminal status bar */
#terminal-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  margin: 0 12px;
  background: linear-gradient(180deg, rgba(15, 26, 41, 0.94), rgba(10, 18, 30, 0.9));
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 18px 18px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 400;
  flex-shrink: 0;
  min-height: 32px;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.16);
}
#terminal-status.hidden { display: none; }
#status-session {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#status-info {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--text-muted);
}

/* Terminal loading indicator */
#terminal-loading {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 5;
}
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Desktop: hide native xterm scrollbar (external scrollbar is used instead) */
#terminal-container .xterm-viewport::-webkit-scrollbar {
  width: 0;
  display: none;
}

/* External scrollbar */
#terminal-scrollbar {
  width: 14px;
  flex-shrink: 0;
  position: relative;
  background: linear-gradient(180deg, rgba(11, 18, 30, 0.72), rgba(8, 14, 24, 0.88));
  border-radius: 0 20px 20px 0;
  border: 1px solid rgba(131, 166, 208, 0.1);
  border-left: none;
  cursor: pointer;
  margin-left: 2px;
  overflow: hidden;
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.03);
}
#terminal-scrollbar.hidden { display: none; }

#terminal-scrollbar-thumb {
  position: absolute;
  left: 2px;
  right: 2px;
  min-height: 30px;
  background: linear-gradient(180deg, rgba(129, 140, 248, 0.3), rgba(110, 182, 255, 0.5));
  border-radius: 7px;
  transition: background 0.15s, box-shadow 0.15s;
}
#terminal-scrollbar-thumb:hover,
#terminal-scrollbar-thumb.dragging {
  background: linear-gradient(180deg, rgba(142, 188, 255, 0.62), rgba(110, 182, 255, 0.82));
  box-shadow: 0 0 0 1px rgba(195, 222, 255, 0.1);
}

/* === File browser panel === */
#file-panel {
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: 100%;
}
#file-panel.hidden { display: none; }

.file-header {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16, 27, 43, 0.98), rgba(12, 20, 33, 0.92));
  align-items: center;
}

#file-path-input {
  flex: 1;
  min-height: 40px;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
#file-path-input:focus { border-color: var(--accent); }

.file-header button {
  min-width: 36px;
  min-height: 36px;
  background: rgba(18, 30, 46, 0.86);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  padding: 6px 10px;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease, transform 150ms ease;
}
.file-header button:hover {
  border-color: rgba(131, 166, 208, 0.24);
  color: var(--text-primary);
  background: rgba(24, 39, 60, 0.92);
  transform: translateY(-1px);
}
.file-header button:disabled { opacity: 0.4; cursor: default; border-color: var(--border); color: var(--text-muted); }
#btn-file-close { font-size: 18px; padding: 4px 8px; }
#btn-file-close:hover { color: var(--danger); }
#btn-file-hidden.active { color: var(--accent); border-color: var(--accent); }

#file-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

/* === IDEA-style file split: tree sidebar + editor pane === */
.file-split {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}
.file-tree-sidebar {
  width: 42%;
  min-width: 180px;
  max-width: 60%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(8, 14, 24, 0.6);
  overflow: hidden;
}
.file-tree-sidebar #file-list {
  padding: 4px 4px 12px;
}

/* Tree nodes */
.tree-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  user-select: none;
  position: relative;
  transition: background 120ms ease;
}
.tree-node:hover { background: rgba(255, 255, 255, 0.04); }
.tree-node.tree-loading { color: var(--text-muted); font-size: 12px; cursor: default; }
.tree-node:hover .tree-actions { opacity: 1; }
.tree-caret {
  width: 14px;
  flex-shrink: 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 120ms ease;
}
.tree-caret.expanded { color: var(--text-secondary); }
.tree-caret-spacer { width: 14px; flex-shrink: 0; }
.tree-node-folder .file-icon { color: var(--accent); }
.tree-node-file .file-icon { color: var(--text-muted); font-size: 14px; }
.tree-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.file-loading {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.file-error { padding: 16px; color: var(--danger); font-size: 13px; }
.file-empty { padding: 16px; color: var(--text-muted); font-size: 13px; text-align: center; }

.file-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 19, 31, 0.88);
  font-size: 12px;
  min-height: 40px;
  align-items: center;
}
.file-breadcrumb-segment {
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.file-breadcrumb-segment:hover { color: var(--accent); background: rgba(255,255,255,0.05); }
.file-breadcrumb-sep { color: var(--text-muted); margin: 0 1px; }

.file-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 13px;
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
  border: 1px solid var(--border-subtle);
  background: var(--card-bg);
  margin-bottom: 10px;
}
.file-entry:hover {
  border-color: rgba(131, 166, 208, 0.24);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.14);
  transform: translateY(-1px);
}

.file-icon { font-size: 16px; flex-shrink: 0; }
.file-entry[data-type="dir"] .file-icon { color: var(--accent); }
.file-entry[data-type="file"] .file-icon { color: var(--text-muted); }

.file-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 48px;
  text-align: right;
}

.file-mtime {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: 0.7;
}

.file-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.file-entry:hover .file-actions { opacity: 1; }

.file-action-btn {
  min-height: 30px;
  background: rgba(18, 30, 46, 0.88);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 4px 9px;
  border-radius: 10px;
  font-size: 11px;
  cursor: pointer;
}
.file-action-btn:hover { color: var(--accent); border-color: var(--accent); }

#file-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(8, 15, 25, 0.86);
  min-width: 0;
  overflow: hidden;
}
#file-preview.hidden { display: none; }

/* Empty editor pane placeholder when no file selected */
.file-split:not(:has(#file-preview:not(.hidden)))::after {
  content: '选择左侧文件查看内容';
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px;
}

/* === IDE shell: unified project workspace (tree + editor + git) === */
#ide-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100%;
  background: var(--bg-primary);
}
#ide-shell.hidden { display: none; }

.ide-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16, 27, 43, 0.98), rgba(12, 20, 33, 0.92));
  flex-shrink: 0;
}
.ide-toolbar-path {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.ide-toolbar-path input {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}
.ide-toolbar-path input:focus { border-color: var(--accent); }
.ide-toolbar-path button {
  min-width: 32px;
  min-height: 32px;
  background: rgba(18, 30, 46, 0.86);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.ide-toolbar-path button:hover { color: var(--text-primary); border-color: rgba(131,166,208,0.24); }
#btn-file-hidden.active { color: var(--accent); border-color: var(--accent); }
.ide-toolbar-actions {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: rgba(8, 14, 24, 0.6);
  border-radius: 8px;
  flex-shrink: 0;
}
.ide-tab {
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  user-select: none;
  transition: background 120ms ease, color 120ms ease;
}
.ide-tab:hover { color: var(--text-secondary); }
.ide-tab.active { background: rgba(110, 182, 255, 0.16); color: var(--accent); font-weight: 600; }

.ide-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* === Activity bar (left icon column) === */
.ide-activity-bar {
  width: 44px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  background: rgba(6, 11, 20, 0.7);
  border-right: 1px solid var(--border);
}
.ide-activity-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  position: relative;
  transition: color 120ms ease, background 120ms ease;
}
.ide-activity-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.ide-activity-btn.active { color: var(--accent); }
.ide-activity-btn.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* === Sidebar (resizable views) === */
.ide-sidebar {
  width: var(--ide-sidebar-width, 260px);
  min-width: 180px;
  max-width: 560px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(8, 14, 24, 0.6);
  overflow: hidden;
}
.ide-sidebar-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.ide-sidebar-view.hidden { display: none; }
/* Allow deep tree levels to scroll horizontally instead of being clipped */
.ide-sidebar-view[data-ide-view="project"] {
  overflow-x: auto;
}
.ide-sidebar-view[data-ide-view="project"] #file-list {
  overflow-x: auto;
  white-space: nowrap;
}

.ide-sidebar-resizer {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  transition: background 120ms ease;
}
.ide-sidebar-resizer:hover,
.ide-sidebar-resizer.dragging {
  background: rgba(110, 182, 255, 0.3);
}

/* === Main viewer (file content / diff / commit) === */
.ide-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
}
.ide-main #file-preview {
  flex: 1;
  border: none;
  max-height: none;
  background: rgba(8, 15, 25, 0.86);
}
.ide-main-diff {
  flex: 1;
  overflow: auto;
  background: rgba(6, 11, 20, 0.92);
  padding: 0;
}
.ide-main-diff.hidden { display: none; }
.ide-diff-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  background: rgba(11, 19, 31, 0.96);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}
.ide-diff-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ide-diff-title { font-family: ui-monospace, monospace; color: var(--text-primary); font-weight: 700; }
.ide-diff-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.ide-diff-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(110, 182, 255, 0.14);
  color: var(--accent);
}
/* In the main area, diff hunks span full width */
.ide-main-diff .diff-line {
  grid-template-columns: 48px 48px minmax(0, 1fr);
}
.ide-empty-hint {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
}
.ide-main:has(#file-preview:not(.hidden)) .ide-empty-hint,
.ide-main:has(#ide-main-diff:not(.hidden)) .ide-empty-hint { display: none; }

/* === Git sidebar (changes list) === */
.git-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.git-sidebar-body .git-worktree-card { gap: 6px; padding: 0 6px; }
.git-sidebar-body .git-worktree-group { padding: 6px 8px; }
.git-sidebar-body .git-change-row {
  grid-template-columns: 36px minmax(0, 1fr) auto !important;
  padding: 4px 6px !important;
  font-size: 12px;
}
.git-sidebar-body .git-change-row:hover { background: rgba(255,255,255,0.05); }
.git-sidebar-body .git-change-row.selected {
  background: rgba(110, 182, 255, 0.14);
  border-left: 2px solid var(--accent);
}
.git-sidebar-body .git-file-path { font-size: 12px; }
.git-sidebar-body .git-diff-pane { display: none; }  /* diffs render in main area now */

/* === Git history sidebar === */
.git-history-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px;
}
.git-history-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.git-history-row:hover { background: rgba(255,255,255,0.04); }
.git-history-row.selected { background: rgba(110, 182, 255, 0.14); border-left-color: var(--accent); }
.git-history-row .gh-hash { font-family: ui-monospace, monospace; font-size: 11px; color: var(--accent); }
.git-history-row .gh-subject { font-size: 12px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.git-history-row .gh-meta { font-size: 10px; color: var(--text-muted); }

.file-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(11, 19, 31, 0.94);
  border-bottom: 1px solid var(--border);
}
#file-preview-name { font-size: 12px; color: var(--text-secondary); }
.file-preview-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.file-preview-actions button {
  min-width: 30px;
  min-height: 30px;
  background: rgba(18, 30, 46, 0.88);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 10px;
}
.file-preview-actions button:hover { color: var(--accent); border-color: var(--accent); }
#btn-file-preview-close { font-size: 16px; padding: 4px 8px; }
#btn-file-preview-close:hover { color: var(--danger); border-color: var(--danger); }

#file-preview-content {
  flex: 1;
  overflow: auto;
  padding: 14px 18px 18px;
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-primary);
  background: transparent;
  white-space: pre-wrap;
  word-break: break-all;
}

.file-editor {
  flex: 1;
  width: 100%;
  min-height: 260px;
  resize: none;
  border: 0;
  outline: none;
  padding: 14px 18px 18px;
  margin: 0;
  background: rgba(3, 9, 17, 0.72);
  color: var(--text-primary);
  font: 12px/1.6 var(--font-mono);
  white-space: pre;
}

.file-diff-confirm {
  border-bottom: 1px solid var(--border);
  background: rgba(10, 17, 28, 0.94);
}

.file-diff-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  color: var(--text-primary);
  font-size: 12px;
}

.file-diff-actions {
  display: inline-flex;
  gap: 8px;
}

.file-diff-actions button {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: rgba(18, 30, 46, 0.9);
  color: var(--text-secondary);
  padding: 6px 10px;
  cursor: pointer;
}

.file-diff-save {
  color: var(--accent) !important;
  border-color: rgba(92, 124, 250, 0.55) !important;
}

.file-diff-body {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 0 18px 12px;
  font: 12px/1.5 var(--font-mono);
}

.file-diff-line {
  white-space: pre-wrap;
  word-break: break-all;
  padding: 1px 6px;
}

.file-diff-added { color: #9ff2b2; background: rgba(46, 160, 67, 0.14); }
.file-diff-removed { color: #ffb4b4; background: rgba(248, 81, 73, 0.14); }
.file-diff-same { color: var(--text-muted); }

/* === Memory panel === */
#memory-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
#memory-panel.hidden { display: none; }

.memory-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16, 27, 43, 0.98), rgba(12, 20, 33, 0.92));
  gap: 12px;
  flex-wrap: wrap;
}
.memory-header h3 {
  font-size: 14px; font-weight: 600; letter-spacing: 0.2px;
  flex-shrink: 0;
}

/* Memory directory sync toolbar */
.memory-sync-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
  flex-wrap: wrap;
}
.memory-sync-dir {
  flex: 1;
  min-width: 180px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.memory-sync-dir:focus {
  outline: none;
  border-color: var(--accent);
}
.memory-sync-btn {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.memory-sync-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}
.memory-sync-btn:active {
  transform: translateY(1px);
}
.memory-sync-status {
  font-size: 12px;
  color: var(--text-muted, #888);
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.memory-sync-status.error {
  color: #ff6b6b;
}

/* Memory tabs */
.memory-tabs {
  display: flex;
  gap: 2px;
  background: rgba(7, 14, 24, 0.78);
  border-radius: 10px;
  padding: 2px;
  border: 1px solid var(--border-subtle);
}
.memory-tab {
  padding: 6px 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: background 150ms ease, color 150ms ease;
}
.memory-tab:hover {
  color: var(--text-primary);
}
.memory-tab.active {
  background: var(--bg-tertiary);
  color: var(--accent);
}
#memory-search {
  flex: 1;
  min-height: 38px;
  padding: 8px 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
#memory-search:focus { border-color: var(--accent); }
#btn-memory-search {
  background: none; border: none; color: var(--text-secondary);
  font-size: 16px; cursor: pointer; padding: 4px;
  line-height: 1; flex-shrink: 0;
}
#btn-memory-search:hover { color: var(--accent); }
#btn-memory-close {
  background: none; border: none; color: var(--text-secondary);
  font-size: 20px; cursor: pointer; padding: 0 4px;
  line-height: 1;
}
#btn-memory-close:hover { color: var(--danger); }

.memory-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
}

#memory-file-body {
  font-size: 13px;
  color: var(--text-primary);
}
#memory-file-body code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}

.memory-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px;
}
.memory-error {
  text-align: center;
  padding: 24px;
  color: var(--danger);
  font-size: 13px;
}

/* === Conversation styles === */
.conv-item {
  background: rgba(14, 24, 39, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.conv-item:hover {
  border-color: rgba(131, 166, 208, 0.24);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.14);
  transform: translateY(-1px);
}
.conv-item.expanded {
  border-color: var(--accent);
}
.conv-header {
  padding: 12px 14px;
  cursor: pointer;
}
.conv-summary {
  font-size: 13px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: 400;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
}
.conv-time {
  color: var(--text-secondary);
}
.conv-count {
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 8px;
}
.conv-size {
  color: var(--text-muted);
}
.conv-messages {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  max-height: 60vh;
  overflow-y: auto;
}
.conv-user, .conv-assistant {
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.6;
}
.conv-user {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}
.conv-assistant {
  background: var(--accent-dim);
  border: 1px solid rgba(99, 102, 241, 0.15);
}
.conv-role {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.conv-user .conv-role { color: var(--text-secondary); }
.conv-assistant .conv-role { color: var(--accent); }
.conv-role-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.conv-msg-time {
  font-size: 10px;
  color: var(--text-muted);
}
.conv-text {
  color: var(--text-primary);
  word-break: break-word;
}
.conv-text-collapsed {
  max-height: 120px;
  overflow: hidden;
  position: relative;
}
.conv-text-collapsed::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--bg-primary));
  pointer-events: none;
}
.conv-text-expanded {
}
.conv-text-expand-btn {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 4px 0;
  background: none;
  border: none;
  border-top: 1px dashed var(--border);
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  text-align: center;
}
.conv-text-expand-btn:hover {
  color: var(--text-primary);
}
.conv-text code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}

/* === Search results === */
.conv-search-header {
  padding: 8px 0;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.conv-search-clear {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: var(--radius-sm, 4px);
  font-size: 11px;
  cursor: pointer;
}
.conv-search-clear:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}
.conv-search-matches {
  padding: 8px 14px 4px;
}
.conv-match-item {
  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm, 4px);
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent);
  cursor: pointer;
}
.conv-match-item:hover {
  background: var(--bg-tertiary, #252540);
}
.conv-match-role {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.conv-match-snippet {
  color: var(--text-secondary);
  word-break: break-word;
}
.conv-match-snippet mark,
.conv-text mark {
  background: var(--highlight);
  color: var(--text-primary);
  padding: 1px 2px;
  border-radius: 2px;
}
.conv-highlight {
  animation: conv-highlight-flash 2s ease-out;
}
@keyframes conv-highlight-flash {
  0% { background-color: rgba(250, 204, 21, 0.3); }
  100% { background-color: transparent; }
}

.conv-file-path-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px 8px;
  border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
}
.conv-file-path {
  flex: 1;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-copy-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: all var(--transition-fast, 0.15s);
}
.conv-copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* === Plans list === */
.plan-item {
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.plan-item:hover {
  border-color: rgba(131, 166, 208, 0.24);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.14);
  transform: translateY(-1px);
}
.plan-item.expanded {
  border-color: var(--accent);
}
.plan-header {
  padding: 12px 14px;
  cursor: pointer;
}
.plan-title {
  font-size: 13px;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.plan-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}
.plan-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
}
.plan-file-bar {
  padding: 4px 14px 8px;
  border-top: 1px solid var(--border);
}
.plan-file-bar .conv-file-path {
  font-size: 11px;
  color: var(--text-muted);
}

/* Plan content (rendered markdown) */
.plan-content {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 60vh;
  overflow-y: auto;
}
.plan-content h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 16px 0 8px;
}
.plan-content h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 12px 0 6px;
}
.plan-content h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 10px 0 4px;
}
.plan-content p {
  margin: 6px 0;
}
.plan-content strong {
  color: var(--text-primary);
}
.plan-content code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}
.plan-content pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.plan-content pre code {
  background: none;
  padding: 0;
}
.plan-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12px;
}
.plan-content td {
  padding: 6px 10px;
  border: 1px solid var(--border);
}
.plan-content tr.table-sep {
  display: none;
}
.plan-content ul {
  padding-left: 20px;
  margin: 6px 0;
}
.plan-content li {
  margin: 3px 0;
}

/* === Tunnel panel === */
#tunnel-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
#tunnel-panel.hidden { display: none; }

.tunnel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16, 27, 43, 0.98), rgba(12, 20, 33, 0.92));
  flex-shrink: 0;
}
.tunnel-header h3 { font-size: 14px; font-weight: 600; }
#btn-tunnel-close {
  background: none; border: none; color: var(--text-secondary);
  font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1;
}
#btn-tunnel-close:hover { color: var(--danger); }

.tunnel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.tunnel-form {
  background: rgba(14, 24, 39, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.14);
}

.tunnel-form input[type="text"],
.tunnel-form input[type="number"] {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
}
.tunnel-form input:focus { border-color: var(--accent); }

.tunnel-form-divider {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 10px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.tunnel-form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.tunnel-form-row:last-of-type { margin-bottom: 0; }
.tunnel-form-row input { flex: 1; min-width: 0; }

.tunnel-secure-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.tunnel-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

#btn-tunnel-save {
  padding: 6px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: filter 150ms ease;
}
#btn-tunnel-save:hover { filter: brightness(1.1); }

#btn-tunnel-cancel {
  padding: 6px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
}
#btn-tunnel-cancel:hover { color: var(--text-primary); border-color: var(--border-hover); }
#btn-tunnel-cancel.hidden { display: none; }

.tunnel-list-header {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.tunnel-empty, .tunnel-error, .tunnel-loading {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: var(--text-muted);
}
.tunnel-error { color: var(--danger); }

.tunnel-card {
  background: rgba(14, 24, 39, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 14px 15px;
  margin-bottom: 10px;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.tunnel-card:hover { border-color: rgba(131, 166, 208, 0.24); box-shadow: 0 16px 26px rgba(0, 0, 0, 0.14); transform: translateY(-1px); }

.tunnel-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.tunnel-card-status { font-size: 12px; line-height: 1; }

.tunnel-card-name {
  flex: 1;
  font-size: 13px;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tunnel-card-proto {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border-radius: 3px;
  flex-shrink: 0;
}

.tunnel-card-addr {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.tunnel-card-error {
  font-size: 11px;
  color: var(--danger);
  margin-bottom: 8px;
  padding: 4px 8px;
  background: var(--danger-dim);
  border-radius: var(--radius-sm);
}

.tunnel-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tunnel-card-actions button {
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.tunnel-btn-open {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
}
.tunnel-btn-open:hover { background: var(--accent); color: #fff; }

.tunnel-btn-start {
  background: var(--success-dim);
  border: 1px solid rgba(52, 211, 153, 0.25);
  color: var(--success);
}
.tunnel-btn-start:hover { background: rgba(52, 211, 153, 0.2); }

.tunnel-btn-stop {
  background: var(--warning);
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: var(--warning);
}
.tunnel-btn-stop:hover { background: rgba(251, 191, 36, 0.2); }

.tunnel-btn-edit {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.tunnel-btn-edit:hover { color: var(--text-primary); border-color: var(--accent); }

.tunnel-btn-del {
  background: var(--danger-dim);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--danger);
}
.tunnel-btn-del:hover { background: rgba(248, 113, 113, 0.2); }

/* === Scheduler panel === */
#scheduler-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
#scheduler-panel.hidden { display: none; }

.task-schedule-builder {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-schedule-builder .task-form-row {
  flex-wrap: wrap;
}
.task-schedule-builder select {
  max-width: 160px;
}
.task-schedule-builder #task-freq,
.task-schedule-builder #task-agent-select {
  max-width: none;
}
.task-time-label {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 28px;
  white-space: nowrap;
  flex-shrink: 0;
}
.task-time-sep {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: bold;
  line-height: 28px;
  flex-shrink: 0;
}
.task-schedule-preview {
  min-height: 20px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  word-break: break-word;
}

.scheduler-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.scheduler-tab {
  padding: 6px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color 150ms ease, background 150ms ease;
}
.scheduler-tab:hover { color: var(--text-primary); }
.scheduler-tab.active {
  color: var(--accent);
  background: var(--bg-tertiary);
  font-weight: 600;
}

.task-form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.task-form-row input,
.task-form-row select {
  flex: 1;
  min-width: 0;
}
.task-agent-select {
  padding: 6px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 150ms ease;
}
.task-agent-select:focus { border-color: var(--accent); }

.task-enabled-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
}
.task-enabled-label input[type="checkbox"] {
  accent-color: var(--accent);
}

#task-prompt {
  width: 100%;
  padding: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-mono);
  resize: vertical;
  outline: none;
  transition: border-color 150ms ease;
  box-sizing: border-box;
}
#task-prompt:focus { border-color: var(--accent); }

.task-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

#btn-task-save {
  padding: 6px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: filter 150ms ease;
}
#btn-task-save:hover { filter: brightness(1.1); }

#btn-task-cancel {
  padding: 6px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
}
#btn-task-cancel:hover { color: var(--text-primary); border-color: var(--border-hover); }
#btn-task-cancel.hidden { display: none; }

.scheduler-card-cron {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border-radius: 3px;
  flex-shrink: 0;
  font-family: var(--font-mono);
}
.tunnel-card-status.is-online { color: var(--success); }
.tunnel-card-status.is-offline { color: var(--danger); }
.tunnel-card-status.is-disabled { color: var(--text-muted); }

.scheduler-run-status {
  font-size: 11px;
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

.scheduler-btn-toggle {
  background: var(--success-dim);
  border: 1px solid rgba(52, 211, 153, 0.25);
  color: var(--success);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: background 150ms ease;
}
.scheduler-btn-toggle:hover { background: rgba(52, 211, 153, 0.2); }

.scheduler-btn-view {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: background 150ms ease;
}
.scheduler-btn-view:hover { background: var(--accent); color: #fff; }

.scheduler-report-summary {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#report-content.hidden { display: none; }

.report-content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.report-content-header span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
#btn-report-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}
#btn-report-close:hover { color: var(--text-primary); }

.report-markdown {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  max-height: 60vh;
  overflow-y: auto;
  padding: 8px;
  background: rgba(14, 24, 39, 0.5);
  border-radius: var(--radius-sm);
  margin: 0;
}

/* === Input bar (desktop + mobile) === */
#input-bar {
  display: flex;
  gap: 10px;
  padding: 12px;
  margin: 0 12px 12px;
  background:
    linear-gradient(180deg, rgba(14, 24, 39, 0.96) 0%, rgba(10, 18, 30, 0.92) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.22);
  flex-shrink: 0;
}

#text-input {
  flex: 1;
  padding: 13px 15px;
  background: rgba(6, 13, 22, 0.9);
  border: 1px solid rgba(131, 166, 208, 0.12);
  border-radius: 15px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  resize: none;
  min-height: 50px;
  max-height: 140px;
  line-height: 1.55;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

#text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

#send-btn {
  width: 54px;
  min-height: 50px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border: none;
  border-radius: 15px;
  color: #07111f;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

#send-btn:hover {
  filter: brightness(1.06);
  box-shadow: 0 14px 28px rgba(72, 149, 230, 0.28);
  transform: translateY(-1px);
}

#send-btn:active {
  filter: brightness(0.9);
  box-shadow: none;
  transform: translateY(0);
}

/* === Virtual keys (mobile only, CSS-only) === */
#virtual-keys {
  display: none;
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  padding: 6px 8px;
  gap: 6px;
  justify-content: center;
  flex-wrap: nowrap;
  z-index: 25;  /* 虚拟按键在终端之上 */
  align-items: center;
}

#virtual-keys button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  min-width: 38px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  padding: 0 6px;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

#virtual-keys button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

#virtual-keys button:active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}


/* === Commands panel === */
#commands-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  z-index: 30;
  display: flex;
  flex-direction: column;
}

#commands-panel.hidden { display: none; }

.commands-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16, 27, 43, 0.98), rgba(12, 20, 33, 0.92));
}

.commands-header h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.commands-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.commands-header-actions button {
  min-height: 32px;
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: rgba(18, 30, 46, 0.86);
  color: var(--text-secondary);
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease, transform 150ms ease;
}

.commands-header-actions button:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: rgba(24, 38, 58, 0.96);
  transform: translateY(-1px);
}

#btn-commands-close {
  background: none; border: none; color: var(--text-secondary);
  font-size: 20px; cursor: pointer; padding: 0 4px;
  line-height: 1;
}
#btn-commands-close:hover { color: var(--danger); }

#commands-list {
  flex: 1; overflow-y: auto; padding: 14px;
}

.cmd-empty { text-align:center; color:var(--text-muted); padding:32px; font-size:13px; }

.cmd-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  margin: 8px 0 4px;
  background: rgba(15, 27, 43, 0.78);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
}
.cmd-group-header:first-child { margin-top: 0; }
.cmd-group-header:hover { border-color: var(--accent); }

.cmd-group-collapse {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.cmd-group-label {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.cmd-group-move-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}
.cmd-group-move-btn:hover { color: var(--accent); border-color: var(--accent); }

.cmd-group-move-select {
  padding: 2px 6px;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 11px;
  outline: none;
  flex-shrink: 0;
}

.cmd-group-body { }

.cmd-edit-agent-select {
  display: block;
  width: 100%;
  padding: 4px 8px;
  margin-top: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}
.cmd-edit-agent-select:focus { border-color: var(--accent); }

.cmd-agent-select {
  min-height: 38px;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  max-width: 120px;
}
.cmd-agent-select:focus { border-color: var(--accent); }

/* Cache panel */
#cache-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
#cache-panel.hidden { display: none; }

/* Git panel */
#git-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
#git-panel.hidden { display: none; }

.git-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16, 27, 43, 0.98), rgba(12, 20, 33, 0.92));
}
.git-header h3 { margin: 0; font-size: 15px; color: var(--text-primary); letter-spacing: 0.01em; }

.git-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

#btn-git-refresh,
#btn-git-close {
  background: rgba(131, 166, 208, 0.08);
  border: 1px solid rgba(131, 166, 208, 0.12);
  color: var(--text-secondary);
  border-radius: 10px;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
#btn-git-refresh { padding: 6px 9px; font-size: 13px; }
#btn-git-close { padding: 4px 8px; font-size: 20px; }
#btn-git-refresh:hover { color: var(--accent); border-color: rgba(94, 234, 212, 0.35); background: rgba(94, 234, 212, 0.08); }
#btn-git-close:hover { color: var(--danger); border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.08); }

.git-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
}

.git-empty,
.git-error-card {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
}

.git-empty-inline {
  min-height: 0;
  padding: 18px;
  border: 1px dashed rgba(131, 166, 208, 0.16);
  border-radius: 14px;
}

.git-error-card {
  background: rgba(248, 113, 113, 0.05);
  border: 1px solid rgba(248, 113, 113, 0.16);
  border-radius: 18px;
  min-height: 220px;
  padding: 20px;
}

.git-error-title {
  color: var(--text-primary);
  font-weight: 700;
}

.git-path,
.git-repo {
  max-width: 100%;
  word-break: break-all;
  font-family: var(--font-mono);
}

.git-summary-card {
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  background:
    radial-gradient(circle at top right, rgba(94, 234, 212, 0.10), transparent 34%),
    rgba(12, 22, 36, 0.78);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.git-summary-main,
.git-branch-row,
.git-divergence {
  display: flex;
  align-items: center;
  gap: 10px;
}

.git-summary-main {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.git-kicker {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}

.git-repo {
  color: var(--text-primary);
  font-size: 14px;
}

.git-clean-badge {
  flex: none;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.git-clean-badge.clean {
  color: var(--success);
  background: rgba(74, 222, 128, 0.10);
  border: 1px solid rgba(74, 222, 128, 0.20);
}
.git-clean-badge.dirty {
  color: var(--warning);
  background: rgba(251, 191, 36, 0.10);
  border: 1px solid rgba(251, 191, 36, 0.20);
}

.git-branch-row {
  margin-bottom: 12px;
}

.git-branch {
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
}

.git-commit-ref {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.git-divergence {
  flex-wrap: wrap;
}

.git-divergence span {
  color: var(--text-secondary);
  background: rgba(131, 166, 208, 0.08);
  border: 1px solid rgba(131, 166, 208, 0.10);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
}

.git-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 18px;
}

.git-stat {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(131, 166, 208, 0.12);
  background: rgba(10, 20, 34, 0.70);
}

.git-stat span {
  display: block;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
}

.git-stat label {
  color: var(--text-muted);
  font-size: 12px;
}

.git-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  margin: 18px 0 10px;
}

.git-section-title span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.git-branches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.git-branch-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(131, 166, 208, 0.11);
  border-radius: 15px;
  background: rgba(12, 22, 36, 0.58);
}

.git-branch-item.current {
  border-color: rgba(94, 234, 212, 0.34);
  background: rgba(94, 234, 212, 0.08);
}

.git-branch-item.remote {
  opacity: 0.82;
}

.git-branch-item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.git-branch-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
}

.git-branch-type {
  flex: none;
  color: var(--text-muted);
  border: 1px solid rgba(131, 166, 208, 0.13);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
}

.git-branch-meta,
.git-branch-subject {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}

.git-branch-subject {
  color: var(--text-secondary);
  margin-top: 4px;
}

.git-commits {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.git-search-input {
  width: 100%;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: rgba(8, 16, 28, 0.76);
  color: var(--text-primary);
  outline: none;
}

.git-search-input:focus {
  border-color: rgba(94, 234, 212, 0.45);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.08);
}

.git-commit {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(131, 166, 208, 0.10);
  background: rgba(12, 22, 36, 0.64);
}

.git-commit-hash {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
}

.git-commit-subject {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-size: 13px;
}

.git-commit-refs {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  margin-left: 8px;
  color: var(--accent);
  font-size: 11px;
}

.git-commit-meta {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.git-load-more {
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(94, 234, 212, 0.22);
  background: rgba(94, 234, 212, 0.08);
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.git-load-more:hover:not(:disabled) {
  background: rgba(94, 234, 212, 0.13);
}

.git-load-more:disabled {
  cursor: default;
  opacity: 0.62;
}

.git-end-message {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 12px;
}

.git-graph-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 32%);
  gap: 16px;
  align-items: start;
}

.git-graph-main,
.git-graph-side {
  min-width: 0;
}

.git-graph-side {
  position: sticky;
  top: 12px;
}

.git-commits-graph {
  gap: 0;
  border: 1px solid rgba(131, 166, 208, 0.10);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(8, 16, 28, 0.52);
}

.git-commits-graph .git-commit {
  grid-template-columns: 154px 72px minmax(0, 1fr) auto;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid rgba(131, 166, 208, 0.08);
  background: transparent;
  cursor: pointer;
  min-height: 46px;
}

.git-commits-graph .git-commit:hover,
.git-commits-graph .git-commit.selected {
  background: rgba(94, 234, 212, 0.07);
}

.git-commits-graph .git-commit.selected {
  box-shadow: inset 3px 0 0 var(--accent);
}

.git-graph {
  --lane-0: #5eead4;
  --lane-1: #fbbf24;
  --lane-2: #93c5fd;
  --lane-3: #fca5a5;
  --lane-4: #c4b5fd;
  --lane-5: #86efac;
  --lane-6: #fdba74;
  --lane-7: #f0abfc;
  display: grid;
  grid-template-columns: repeat(var(--lane-count, 1), 18px);
  align-items: stretch;
  height: 34px;
  position: relative;
}

.git-graph-cell {
  position: relative;
  display: block;
}

.git-graph-cell::before {
  content: "";
  position: absolute;
  top: -8px;
  bottom: -8px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: transparent;
  opacity: 0.78;
}

.git-graph-cell.active::before,
.git-graph-cell.parent::before {
  background: currentColor;
}

.git-graph-cell.connector::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 2px;
  transform: translateY(-50%);
  background: currentColor;
  opacity: 0.62;
}

.git-graph-cell > span {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: transparent;
}

.git-graph-cell.current > span {
  width: 12px;
  height: 12px;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.12);
}

.git-graph-cell:nth-child(8n+1) { color: var(--lane-0); }
.git-graph-cell:nth-child(8n+2) { color: var(--lane-1); }
.git-graph-cell:nth-child(8n+3) { color: var(--lane-2); }
.git-graph-cell:nth-child(8n+4) { color: var(--lane-3); }
.git-graph-cell:nth-child(8n+5) { color: var(--lane-4); }
.git-graph-cell:nth-child(8n+6) { color: var(--lane-5); }
.git-graph-cell:nth-child(8n+7) { color: var(--lane-6); }
.git-graph-cell:nth-child(8n+8) { color: var(--lane-7); }

.git-branch-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.git-branch-pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  border: 1px solid rgba(131, 166, 208, 0.13);
  border-radius: 999px;
  background: rgba(131, 166, 208, 0.06);
  padding: 5px 9px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.git-branch-pill.current {
  color: var(--accent);
  border-color: rgba(94, 234, 212, 0.32);
  background: rgba(94, 234, 212, 0.08);
}

.git-branch-pill em {
  margin-left: 6px;
  color: var(--text-muted);
  font-family: inherit;
  font-style: normal;
  font-size: 10px;
}

.git-detail-card,
.git-detail-empty {
  border: 1px solid rgba(131, 166, 208, 0.12);
  border-radius: 16px;
  background: rgba(12, 22, 36, 0.64);
  padding: 14px;
}

.git-detail-empty {
  color: var(--text-muted);
  font-size: 12px;
}

.git-detail-title {
  color: var(--text-primary);
  font-weight: 800;
  line-height: 1.45;
  margin-bottom: 12px;
}

.git-detail-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 7px 0;
  border-top: 1px solid rgba(131, 166, 208, 0.08);
  color: var(--text-secondary);
  font-size: 12px;
}

.git-detail-row span {
  color: var(--text-muted);
}

.git-detail-row code,
.git-detail-parents code {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
}

.git-detail-parents div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.git-detail-muted {
  color: var(--text-muted);
}

.git-file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  max-height: 260px;
  overflow-y: auto;
}

.git-file-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(8, 16, 28, 0.52);
  border: 1px solid rgba(131, 166, 208, 0.08);
  font-size: 12px;
}

.git-file-status {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.git-file-path {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.git-file-numstat {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
}

.git-worktree-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.git-worktree-group {
  border: 1px solid rgba(131, 166, 208, 0.10);
  border-radius: 14px;
  padding: 10px;
  background: rgba(12, 22, 36, 0.56);
}

.git-worktree-title {
  display: flex;
  justify-content: space-between;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.git-worktree-title span {
  color: var(--text-muted);
  font-weight: 600;
}

.git-worktree-card .git-file-row {
  grid-template-columns: 54px minmax(0, 1fr);
}

/* === Change-row actions + inline diff (IDEA-style) === */
.git-change-row {
  grid-template-columns: 40px minmax(0, 1fr) auto auto !important;
  align-items: center;
}
.git-row-actions {
  display: inline-flex;
  gap: 4px;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}
.git-change-row:hover .git-row-actions { opacity: 1; }
.git-row-btn {
  min-width: 24px;
  height: 24px;
  background: rgba(18, 30, 46, 0.88);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
.git-row-btn:hover { color: var(--accent); border-color: var(--accent); }

.git-diff-pane {
  grid-column: 1 / -1;
  margin: 2px 0 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(6, 11, 20, 0.92);
  overflow: hidden;
}
.git-diff-loading, .git-diff-empty {
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: 12px;
}
.diff-hunk { border-bottom: 1px solid rgba(131, 166, 208, 0.08); }
.diff-hunk:last-child { border-bottom: none; }
.diff-hunk-header {
  padding: 6px 12px;
  background: rgba(131, 166, 208, 0.08);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.diff-line {
  display: grid;
  grid-template-columns: 42px 42px minmax(0, 1fr);
  padding: 0 8px;
  font-size: 12px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
  overflow-x: auto;
}
.diff-line-old, .diff-line-new {
  color: var(--text-muted);
  text-align: right;
  padding-right: 8px;
  user-select: none;
}
.diff-line-text { color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; }
.diff-line.added { background: rgba(80, 200, 120, 0.10); }
.diff-line.added .diff-line-new { color: #50c878; }
.diff-line.deleted { background: rgba(255, 99, 99, 0.10); }
.diff-line.deleted .diff-line-old { color: #ff6363; }
.diff-line.context { color: var(--text-secondary); }
.diff-line.note { color: var(--text-muted); font-style: italic; grid-template-columns: 84px minmax(0, 1fr); }

/* === Side-by-side (two-column) diff === */
.diff-sxs { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.diff-sxs-hunk { border-bottom: 1px solid rgba(131, 166, 208, 0.08); }
.diff-sxs-hunk:last-child { border-bottom: none; }
.diff-sxs-header {
  padding: 6px 12px;
  background: rgba(131, 166, 208, 0.08);
  color: var(--text-secondary);
  font-size: 11px;
}
.diff-sxs-body { }
.diff-sxs-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}
.diff-sxs-row > .diff-sxs-cell:first-child {
  border-right: 1px solid var(--border);
}
.diff-sxs-cell {
  display: flex;
  gap: 4px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 1.5;
  overflow: visible;
  min-width: 0;
}
.diff-sxs-num {
  width: 38px;
  flex-shrink: 0;
  color: var(--text-muted);
  text-align: right;
  user-select: none;
  padding-right: 6px;
}
.diff-sxs-txt {
  color: var(--text-primary);
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* Context: both sides normal */
.diff-sxs-cell.context .diff-sxs-txt { color: var(--text-secondary); }
/* Added: left empty (no bg), right green */
.diff-sxs-cell.added .diff-sxs-num { color: #50c878; }
.diff-sxs-row > .diff-sxs-cell.added:first-child { background: transparent; }
.diff-sxs-row > .diff-sxs-cell.added:not(:first-child) { background: rgba(80, 200, 120, 0.10); }
/* Deleted: left red, right empty (no bg) */
.diff-sxs-cell.deleted .diff-sxs-num { color: #ff6363; }
.diff-sxs-row > .diff-sxs-cell.deleted:first-child { background: rgba(255, 99, 99, 0.10); }
.diff-sxs-row > .diff-sxs-cell.deleted:not(:first-child) { background: transparent; }
/* Empty placeholder cells */
.diff-sxs-cell.empty { background: rgba(131, 166, 208, 0.04); }
.diff-sxs-cell.note { font-style: italic; color: var(--text-muted); }

/* Commit form */
.git-commit-form {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(12, 22, 36, 0.56);
}
.git-commit-form input {
  flex: 1;
  min-height: 32px;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}
.git-commit-form input:focus { border-color: var(--accent); }
.git-commit-form button {
  min-height: 32px;
  padding: 0 14px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #06121f;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.git-commit-form button:hover { filter: brightness(1.1); }

@media (max-width: 768px) {
  .git-body {
    padding: 12px;
  }

  .git-summary-main,
  .git-branch-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .git-stats-grid,
  .git-branches {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .git-commit {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .git-commit-meta {
    grid-column: 2;
  }

  .git-graph-layout {
    grid-template-columns: 1fr;
  }

  .git-graph-side {
    position: static;
  }

  .git-commits-graph .git-commit {
    grid-template-columns: 110px 64px minmax(0, 1fr);
  }

  .git-commits-graph .git-commit-meta {
    grid-column: 3;
  }

  .git-graph {
    grid-template-columns: repeat(var(--lane-count, 1), 16px);
  }
}

.cache-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16, 27, 43, 0.98), rgba(12, 20, 33, 0.92));
}
.cache-header h3 { margin: 0; font-size: 15px; color: var(--text-primary); letter-spacing: 0.01em; }

#btn-cache-close {
  background: none; border: none; color: var(--text-secondary);
  font-size: 20px; cursor: pointer; padding: 0 4px;
  transition: color var(--transition-fast);
  line-height: 1;
}
#btn-cache-close:hover { color: var(--danger); }

.cache-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

#cache-list {
  width: 42%;
  min-width: 280px;
  overflow-y: auto;
  padding: 14px;
  border-right: 1px solid var(--border);
}

#cache-preview {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 18px;
}

.cache-empty { text-align:center; color:var(--text-muted); padding:32px; font-size:13px; }
.cache-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.cache-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.cache-clear-btn {
  background: var(--danger-dim);
  border: 1px solid rgba(248,113,113,0.2);
  color: var(--danger);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  cursor: pointer;
}
.cache-clear-btn:hover { border-color: var(--danger); }

.cache-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.cache-item:hover { background: rgba(18, 31, 48, 0.84); border-color: rgba(131, 166, 208, 0.12); transform: translateX(1px); }
.cache-item.active {
  background: linear-gradient(135deg, rgba(110, 182, 255, 0.14), rgba(110, 182, 255, 0.05));
  border-color: rgba(110, 182, 255, 0.18);
}

.cache-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.cache-item-kind {
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(129, 140, 248, 0.12);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.6;
}

.cache-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.cache-item-size { flex-shrink: 0; }

.cache-total {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

.cache-preview-header {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.cache-preview-title {
  margin: 0;
  font-size: 15px;
  color: var(--text-primary);
  word-break: break-all;
}

.cache-preview-meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.cache-preview-path {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
  font-family: var(--font-mono);
}

.cache-preview-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.cache-preview-image-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 220px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.cache-preview-image {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.cache-preview-message {
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .cache-body {
    flex-direction: column;
  }

  #cache-list {
    width: 100%;
    min-width: 0;
    max-height: 42%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.cmd-item {
  background: rgba(14, 24, 39, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 14px 15px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.cmd-item:hover {
  border-color: rgba(131, 166, 208, 0.24);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.16);
  transform: translateY(-1px);
}

.cmd-info { flex: 1; min-width: 0; }

.cmd-name {
  font-size: 13px; font-family: var(--font-sans); font-weight: 600; color: var(--text-primary);
}

.cmd-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cmd-badge-new-session {
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  white-space: nowrap;
}

.cmd-text {
  font-size: 11px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 2px;
}

.cmd-run {
  background: var(--success-dim);
  border: 1px solid rgba(52, 211, 153, 0.25);
  color: var(--success);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: background 150ms ease;
  flex-shrink: 0;
}

.cmd-run:hover {
  background: rgba(52, 211, 153, 0.2);
}

.cmd-edit {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease;
  flex-shrink: 0;
}

.cmd-edit:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.cmd-save {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: filter 150ms ease;
  flex-shrink: 0;
}

.cmd-save:hover {
  filter: brightness(1.1);
}

.cmd-edit-input {
  padding: 7px 9px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.cmd-edit-input:focus {
  border-color: var(--accent);
}

.cmd-edit-text {
  margin-top: 4px;
}

.cmd-edit-ns-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  cursor: pointer;
}

.cmd-add-ns-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0 4px;
}

.cmd-add-ns-label.hidden {
  display: none;
}

.cmd-del {
  background: var(--danger-dim);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--danger);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: background 150ms ease;
  flex-shrink: 0;
}

.cmd-del:hover {
  background: rgba(248, 113, 113, 0.2);
}

.commands-add {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(16, 27, 43, 0.94), rgba(6, 12, 22, 0.98));
}

.commands-add input {
  min-height: 40px;
  padding: 9px 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.commands-add input:focus {
  border-color: var(--accent);
}

#cmd-name-input { width: 80px; flex-shrink: 0; }
#cmd-text-input { flex: 1; min-width: 0; }

#cmd-add-btn {
  width: 40px; height: 40px;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter 150ms ease;
}

#cmd-add-btn:hover {
  filter: brightness(1.1);
}

/* === Command batch bar === */
.cmd-batch-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cmd-select-all {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.batch-mode-group {
  display: flex;
  gap: 2px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 2px;
  border: 1px solid var(--border);
}

.batch-mode-btn {
  padding: 3px 8px;
  font-size: 12px;
  font-family: "JetBrains Mono", Consolas, monospace;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 150ms ease;
}

.batch-mode-btn.active {
  background: var(--accent);
  color: #fff;
}

.batch-mode-btn:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.batch-run-btn {
  padding: 5px 14px;
  font-size: 12px;
  background: var(--success-dim);
  border: 1px solid rgba(52, 211, 153, 0.25);
  color: var(--success);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 150ms ease;
  margin-left: auto;
  white-space: nowrap;
}

.batch-run-btn:hover {
  background: rgba(52, 211, 153, 0.2);
}

.cmd-check {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--accent);
}

/* Sort buttons */
.cmd-sort {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.cmd-item:hover .cmd-sort { opacity: 1; }

.cmd-sort-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 2px;
}
.cmd-sort-btn:hover { color: var(--accent); background: var(--accent-dim); }

/* === Connect modal === */
#connect-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}

#connect-modal.hidden { display: none; }

#ssh-modal { z-index: 100; }
#ssh-modal .modal-content { width: 380px; }

.modal-content {
  background:
    linear-gradient(180deg, rgba(14, 24, 39, 0.97) 0%, rgba(9, 17, 30, 0.97) 100%);
  padding: 34px 32px;
  border-radius: 24px;
  border: 1px solid rgba(131, 166, 208, 0.18);
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 28px 68px rgba(0, 0, 0, 0.34);
}

.modal-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.modal-content h2 {
  margin-bottom: 12px;
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.connect-modal-copy {
  margin: 0 0 22px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block; font-size: 11px; color: var(--text-muted);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.8px;
  font-weight: 600;
}

.form-group input {
  width: 100%; padding: 11px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text-primary);
  font-size: 14px; outline: none;
  transition: border-color var(--transition-fast);
}
.form-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-group input::placeholder { color: var(--text-muted); }

#btn-connect {
  width: 100%; padding: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border: none; border-radius: 14px;
  color: #04111e; font-size: 14px; font-weight: 700;
  cursor: pointer; margin-top: 6px;
  transition: filter 150ms ease, transform 150ms ease, box-shadow 150ms ease;
  will-change: transform, filter;
  letter-spacing: 0.3px;
}
#btn-connect:hover {
  filter: brightness(1.06);
  box-shadow: 0 12px 24px rgba(72, 149, 230, 0.26);
  transform: translateY(-1px);
}
#btn-connect:active {
  transform: translateY(0);
}

.modal-actions {
  display: flex; gap: 10px; margin-top: 24px;
}
.modal-actions .btn-secondary {
  flex: 1; padding: 11px; background: rgba(18, 30, 46, 0.86);
  border: 1px solid var(--border-subtle); border-radius: 12px;
  color: var(--text-secondary); font-size: 14px; cursor: pointer;
}
.modal-actions .btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
#ssh-modal button:last-child {
  flex: 1; padding: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border: none; border-radius: var(--radius-sm);
  color: #04111e; font-size: 14px; font-weight: 700; cursor: pointer;
}
#ssh-modal button:last-child:hover {
  filter: brightness(1.06);
  box-shadow: 0 12px 24px rgba(72, 149, 230, 0.26);
  transform: translateY(-1px);
}
#ssh-modal button:last-child:active { transform: translateY(0); }

/* === Device dropdown (mobile) === */
.device-dropdown {
  position: fixed;
  background: linear-gradient(180deg, rgba(14, 24, 39, 0.98), rgba(9, 17, 30, 0.96));
  border: 1px solid rgba(131, 166, 208, 0.16);
  border-radius: 16px;
  box-shadow: 0 24px 52px rgba(0, 0, 0, 0.3);
  z-index: 100;
  padding: 12px 14px;
  min-width: 200px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.device-dropdown.hidden { display: none; }
.device-dropdown-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.device-dropdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 4px;
  background: rgba(18, 30, 46, 0.86);
  border: 1px solid rgba(131, 166, 208, 0.12);
}
.device-dropdown-name {
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.device-dropdown-name.buildMismatch {
  color: var(--warning);
}
.device-dropdown-build {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}
.device-dropdown-build.buildMismatch {
  color: var(--warning);
}
.device-dropdown-kick {
  background: var(--danger-dim);
  border: 1px solid rgba(248,113,113,0.2);
  color: var(--danger);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 8px;
  -webkit-tap-highlight-color: transparent;
}
.device-dropdown-kick:hover,
.device-dropdown-kick:active {
  background: var(--danger);
  color: #fff;
}

/* === Mobile === */
@media (max-width: 768px) {
  /* Sidebar: collapsed header bar, tap to expand */
  #sidebar {
    width: 100%; height: 48px; bottom: auto;
    flex-direction: column; overflow: hidden;
    cursor: pointer;
  }
  .sidebar-header {
    border-bottom: none;
    padding: 8px 12px; flex-shrink: 0;
    width: 100%;
  }
  .sidebar-header h2 {
    font-size: 14px; color: var(--text-primary); font-weight: 600; text-transform: none;
    letter-spacing: 0.02em;
    flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    display: block;
  }
  .header-buttons { flex-shrink: 0; }
  .header-buttons button, #btn-toolbar-menu {
    width: 32px; height: 32px; font-size: 18px;
  }
  .toolbar-dropdown {
    top: 48px;
    right: 8px;
    left: auto;
  }
  .device-dropdown {
    left: 50% !important;
    transform: translateX(-50%);
    min-width: min(200px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }
  /* Session list hidden by default, shown on expand */
  #session-list { display: none; }
  /* Expanded state */
  #sidebar.expanded {
    height: min(82vh, calc(100vh - 12px)); max-height: 82vh;
    overflow-y: auto;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
    z-index: 30;
  }
  #sidebar.expanded #session-list {
    display: block;
    overflow-y: auto;
    padding: 8px 10px 12px;
    -webkit-overflow-scrolling: touch;
  }
  .session-item {
    padding: 12px 12px; border-left: none;
    border-bottom: none;
    font-size: 14px; min-height: 64px;
    gap: 10px;
  }
  .session-item.active { background: var(--accent-dim); border-left: 3px solid var(--accent); }
  .session-meta-row {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .session-more {
    display: inline-flex !important;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(131, 166, 208, 0.12);
    border-radius: 12px;
  }
  .session-more-menu {
    right: 12px;
    top: auto;
    bottom: 12px;
    min-width: 180px;
    z-index: 90;
  }
  .sidebar-footer { display: none; }
  #main { left: 0; top: 48px; display: flex; flex-direction: column; }

  /* 移动端允许文本选择和交互 */
  #no-session {
    padding: 32px 18px 18px;
    gap: 16px;
  }
  #no-session::before {
    inset: 8px;
    border-radius: 24px;
  }
  .no-session-layout {
    gap: 14px;
  }
  .no-session-copy {
    padding: 24px 18px;
    border-radius: 24px;
  }
  .no-session-copy h1 {
    font-size: clamp(28px, 9vw, 38px);
  }
  .no-session-copy p {
    font-size: 14px;
    line-height: 1.75;
  }
  .no-session-actions {
    gap: 10px;
  }
  .no-session-actions button {
    min-height: 46px;
    padding: 11px 16px;
  }
  .no-session-tips {
    gap: 8px;
  }
  .no-session-tips span {
    width: 100%;
    font-size: 10px;
    letter-spacing: 0.03em;
  }

  .xterm {
    -webkit-user-select: text;
    user-select: text;
  }
  .xterm-screen {
    pointer-events: auto;
  }
  .xterm-viewport {
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  /* Mobile: use native scrollbar, hide external one */
  #terminal-wrapper {
    margin: 8px 8px 6px;
  }
  #terminal-scrollbar {
    display: none !important;
  }
  #terminal-container .xterm-viewport::-webkit-scrollbar {
    width: 6px;
    display: block;
  }
  #terminal-container .xterm-viewport::-webkit-scrollbar-track {
    background: transparent;
  }
  #terminal-container .xterm-viewport::-webkit-scrollbar-thumb {
    background: rgba(129, 140, 248, 0.25);
    border-radius: 3px;
  }

  #terminal-container {
    flex: 1;
    min-height: 0;
    height: auto;
    padding: 2px;
    margin: 8px 8px 6px;
    border-radius: 18px 18px 14px 14px;
  }

  #terminal-status {
    margin: 0 8px;
    border-radius: 0 0 14px 14px;
  }

  #virtual-keys {
    display: flex;
    position: static;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px;
    justify-content: center;
  }
  #virtual-keys button {
    min-width: 44px;
    height: 40px;
    font-size: 12px;
    padding: 0 4px;
  }

  /* File browser: always show action buttons on touch */
  .file-actions { opacity: 1; }
  .file-header,
  .theme-header {
    padding: 12px;
  }
  .file-entry {
    padding: 11px 12px;
    margin-bottom: 8px;
  }
  .file-breadcrumb {
    padding: 8px 12px;
    min-height: 36px;
  }
  .file-preview-header {
    padding: 10px 12px;
  }
  #file-preview-content {
    padding: 12px;
  }
  .theme-body {
    padding: 12px;
    gap: 12px;
  }
  .theme-section {
    padding: 12px;
    border-radius: 16px;
  }
  .theme-grid {
    grid-template-columns: 1fr;
  }
  .wallpaper-upload-row,
  .wallpaper-preview-row {
    flex-wrap: wrap;
  }
  .wallpaper-thumb {
    width: 100%;
    height: 120px;
  }
  .wallpaper-upload-btn,
  .wallpaper-apply-btn {
    flex: 1;
  }

  /* Input bar */
  #input-bar {
    margin: 0 8px 8px;
    padding: 8px;
    border-radius: 16px;
  }
  #text-input {
    min-height: 44px;
    font-size: 16px; /* ≥16px prevents iOS auto-zoom */
  }
  #send-btn {
    width: 48px;
    min-height: 44px;
  }

  .cmd-item {
    flex-wrap: wrap; gap: 6px; padding: 10px 12px;
  }
  .cmd-check { width: 20px; height: 20px; }
  .cmd-sort { opacity: 1; }
  .cmd-sort-btn { font-size: 14px; padding: 4px 6px; }
  .cmd-run, .cmd-edit, .cmd-save, .cmd-del { min-height: 36px; padding: 6px 12px; font-size: 13px; }
  .cmd-badge-new-session { font-size: 10px; padding: 2px 6px; }
  .cmd-edit-input { font-size: 16px; padding: 6px 8px; }
  .cmd-edit-ns-label { padding: 6px 0; }

  .cmd-batch-bar { flex-wrap: wrap; gap: 6px; }
  .batch-mode-btn { padding: 6px 10px; font-size: 13px; }
  .batch-run-btn { width: 100%; text-align: center; padding: 8px; margin-left: 0; }
  .cmd-select-all { width: 20px; height: 20px; }

  .commands-add { flex-wrap: wrap; }
  #cmd-name-input { width: 100%; }
  #cmd-text-input { min-height: 40px; font-size: 16px; }
  .cmd-add-ns-label { padding: 8px 0; width: 100%; }

  /* Memory panel */
  .memory-header { padding: 10px 12px; }
  #memory-search { font-size: 16px; }
  #btn-memory-search { min-height: 36px; min-width: 36px; }
  .memory-body { padding: 10px; }
  .conv-header { padding: 10px 12px; }
  .conv-summary { font-size: 14px; white-space: normal; overflow: visible; }
  .conv-messages { padding: 10px 12px; max-height: 70vh; }
  .conv-user, .conv-assistant { padding: 10px 12px; }
  .conv-text { font-size: 14px; }
  .conv-text-expand-btn { min-height: 36px; padding: 8px; }
  .conv-match-item { min-height: 36px; padding: 8px 10px; }
  .conv-search-header { flex-wrap: wrap; gap: 6px; }

  /* Tunnel panel */
  .tunnel-body { padding: 10px; }
  .tunnel-form { padding: 10px; }
  .tunnel-form input[type="text"],
  .tunnel-form input[type="number"] { font-size: 16px; }
  .tunnel-form-row { flex-wrap: wrap; }
  .tunnel-card-actions button { min-height: 32px; }

  .modal-content {
    padding: 26px 18px;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }
  .connect-modal-copy {
    font-size: 14px;
  }
  .modal-card {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    padding: 18px;
    border-radius: 20px;
  }
  .modal-card-actions {
    flex-wrap: wrap;
  }
  .modal-card-actions button {
    min-height: 42px;
  }

  .toast-container {
    right: 8px;
    left: 8px;
    bottom: 8px;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }

}

/* Very small screens */
@media (max-width: 480px) {
  #sidebar { height: 44px; }
  .sidebar-header { padding: 6px 8px; }
  #main { top: 44px; }
  #virtual-keys button {
    min-width: 38px;
    height: 36px;
    font-size: 11px;
  }
}

/* === Model configuration panel === */
#model-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 400px;
  background: linear-gradient(180deg, rgba(14, 24, 39, 0.98), rgba(9, 17, 30, 0.96));
  border-left: 1px solid rgba(131, 166, 208, 0.12);
  z-index: 30;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#model-panel.hidden { display: none; }

#workspace-panel {
  position: absolute;
  top: 18px;
  right: 18px;
  bottom: 96px;
  width: min(760px, calc(100vw - 300px));
  min-width: 520px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  border-radius: 8px;
  color: #e5edf7;
  z-index: 28;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#workspace-panel.hidden { display: none; }

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.workspace-header h3,
.workspace-section h4 {
  margin: 0;
}

.workspace-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-header-actions input,
.workspace-office-form input,
.workspace-office-form select {
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #e5edf7;
  border-radius: 6px;
  padding: 7px 9px;
}

.workspace-header-actions button,
.workspace-actions button,
.workspace-office-form button {
  background: rgba(51, 65, 85, 0.86);
  color: #e5edf7;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
}

.workspace-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.workspace-body {
  overflow: auto;
  padding: 14px;
}

.workspace-section {
  margin-bottom: 18px;
}

.workspace-section h4 {
  font-size: 13px;
  color: #93a4ba;
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.workspace-project,
.workspace-service {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(30, 41, 59, 0.54);
  border-radius: 8px;
  margin-bottom: 8px;
}

.workspace-project-main {
  min-width: 0;
}

.workspace-project-title,
.workspace-service-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.workspace-project-path,
.workspace-project-summary,
.workspace-office-url {
  color: #9fb0c6;
  font-size: 12px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.workspace-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 999px;
  color: #cbd5e1;
  background: rgba(100, 116, 139, 0.32);
}

.workspace-badge.ok {
  color: #bbf7d0;
  background: rgba(22, 163, 74, 0.24);
}

.workspace-badge.warn {
  color: #fde68a;
  background: rgba(202, 138, 4, 0.22);
}

.workspace-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  flex: none;
}

.workspace-empty {
  color: #9fb0c6;
  border: 1px dashed rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  padding: 14px;
}

.workspace-office-form {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

.model-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(131, 166, 208, 0.12);
  flex-shrink: 0;
}
.model-header h3 { margin: 0; font-size: 14px; color: var(--text-primary); }
.model-header-actions { display: flex; align-items: center; gap: 8px; }
.model-header-actions button {
  min-height: 32px; padding: 6px 11px; font-size: 12px; border-radius: 10px;
  cursor: pointer; border: 1px solid var(--border-subtle);
  background: rgba(18, 30, 46, 0.86); color: var(--text-secondary);
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease, transform 150ms ease;
}
.model-header-actions button:hover {
  border-color: var(--accent); color: var(--text-primary);
  background: rgba(24, 38, 58, 0.96); transform: translateY(-1px);
}
#btn-model-close { background: none; border: none; color: var(--text-secondary); font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1; }
#btn-model-close:hover { color: var(--danger); }

.model-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#model-list { display: flex; flex-direction: column; gap: 6px; }

.model-empty {
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
  padding: 16px;
}

.model-item {
  background: rgba(14, 24, 39, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 12px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.12);
}
.model-item-default {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-alpha, rgba(123,93,255,0.2)), 0 16px 26px rgba(0, 0, 0, 0.14);
}

.model-item-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}
.model-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.model-item-model {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.model-item-badge {
  font-size: 10px;
  background: var(--accent);
  color: #fff;
  padding: 1px 5px;
  border-radius: 10px;
  display: inline-block;
  margin-top: 3px;
}

.model-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.model-item-actions button {
  min-height: 30px;
  font-size: 11px;
  padding: 4px 9px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: rgba(18, 30, 46, 0.86);
  color: var(--text-secondary);
  cursor: pointer;
}
.model-item-actions button:hover { color: var(--text-primary); border-color: var(--accent); }
.model-item-actions button:disabled { opacity: 0.4; cursor: not-allowed; }
.model-del-btn:hover { color: var(--warning, #ef4444) !important; border-color: var(--warning, #ef4444) !important; }

.model-form {
  background: rgba(14, 24, 39, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.12);
}
.model-form-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.model-form input {
  width: 100%;
  background: rgba(6, 13, 22, 0.82);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 13px;
  box-sizing: border-box;
}
.model-form input:focus { outline: none; border-color: var(--accent); }
.model-form textarea {
  width: 100%;
  background: rgba(6, 13, 22, 0.82);
  border: 1px solid rgba(131, 166, 208, 0.16);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  box-sizing: border-box;
  resize: vertical;
  min-height: 60px;
}
.model-form textarea:focus { outline: none; border-color: var(--accent); }
.model-form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  min-height: 36px;
}
.model-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.model-form-actions button {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}
.model-form-actions button:last-child {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
.model-form-actions button:hover { opacity: 0.85; }

/* Advanced options toggle */
.model-form-advanced-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: 1px solid rgba(131, 166, 208, 0.1);
  border-radius: 10px;
  padding: 7px 12px;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 150ms ease;
}
.model-form-advanced-toggle:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.advanced-toggle-arrow {
  transition: transform 200ms ease;
  font-size: 10px;
}
.model-form-advanced-toggle.expanded .advanced-toggle-arrow {
  transform: rotate(180deg);
}

/* Advanced section */
.model-form-advanced {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  transition: max-height 200ms ease, opacity 200ms ease;
}
.model-form-advanced.hidden {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  margin: 0;
  padding: 0;
}

/* Select row for effort level */
.model-form-select-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.model-form-select-row label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 60px;
}
.model-form-select-row select {
  flex: 1;
  background: rgba(6, 13, 22, 0.82);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.model-form-select-row select:focus {
  border-color: var(--accent);
}

/* Model picker overlay (shown when creating new session) */
#model-picker {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: linear-gradient(180deg, rgba(14, 24, 39, 0.98), rgba(9, 17, 30, 0.96));
  border: 1px solid rgba(131, 166, 208, 0.16);
  border-radius: 24px;
  padding: 24px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 28px 64px rgba(0,0,0,0.34);
}
.modal-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 16px;
}
.modal-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.modal-card-actions button {
  flex: 1;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: rgba(18, 30, 46, 0.86);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease, transform 150ms ease;
}
.modal-card-actions button.btn-primary {
  background: var(--accent);
  color: #04111e;
  border-color: var(--accent);
}
.modal-card-actions button:hover {
  opacity: 1;
  transform: translateY(-1px);
}

#model-picker-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.model-picker-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease, background 150ms ease;
}
.model-picker-btn:hover {
  border-color: rgba(131, 166, 208, 0.24);
  background: rgba(18, 31, 48, 0.84);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.14);
  transform: translateY(-1px);
}
.model-picker-btn-default { border-color: var(--accent); }
.mpb-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.mpb-model {
  font-size: 11px;
  color: var(--text-secondary);
}

/* === Unified surfaces === */
#commands-panel,
#cache-panel,
#git-panel,
#memory-panel,
#tunnel-panel,
#scheduler-panel,
#file-panel,
#theme-panel,
#model-panel {
  background:
    linear-gradient(180deg, var(--surface-1) 0%, rgba(8, 16, 28, 0.98) 100%);
  border-left: 1px solid rgba(131, 166, 208, 0.08);
}

.commands-header,
.cache-header,
.memory-header,
.tunnel-header,
.file-header,
.theme-header,
.model-header,
.file-breadcrumb,
.file-preview-header {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035) 0%, rgba(255, 255, 255, 0.01) 100%);
  border-color: var(--border);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.02);
}

.commands-body,
.cache-body,
.memory-body,
.tunnel-body,
.theme-body,
.model-body,
#file-list,
#model-picker-list {
  background: transparent;
}

.toolbar-dropdown,
.modal-content,
.modal-card,
.tunnel-form,
.tunnel-card,
.conv-item,
.plan-item,
.model-item,
.model-form,
.model-picker-btn,
.cmd-item,
.file-entry,
.theme-card {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.modal-content,
.modal-card {
  background:
    linear-gradient(180deg, rgba(14, 24, 39, 0.96) 0%, rgba(9, 17, 30, 0.96) 100%);
  border: 1px solid rgba(131, 166, 208, 0.18);
}

/* === Toast === */
.toast-container {
  position: fixed;
  right: 20px;
  bottom: 40px;
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  min-width: 320px;
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  pointer-events: auto;
}
.toast-visible { opacity: 1; transform: translateX(0); }
.toast-hiding  { opacity: 0; transform: translateX(20px); }

.toast-success { border-left: 3px solid var(--success); }
.toast-danger  { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info    { border-left: 3px solid var(--accent); }

.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-success .toast-icon { color: var(--success); }
.toast-danger  .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    .toast-icon { color: var(--accent); }

.toast-content { flex: 1; }
.toast-title { font-size: var(--fs-sm); font-weight: 600; color: var(--text-primary); }
.toast-desc  { font-size: var(--fs-xs); color: var(--text-secondary); margin-top: 2px; }

.toast-close {
  flex-shrink: 0;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.toast-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-content h2 {
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.form-group input,
.model-form input,
#file-path-input,
#memory-search,
.commands-add input,
.wallpaper-url-input,
.tunnel-form input[type="text"],
.tunnel-form input[type="number"] {
  background: rgba(6, 13, 22, 0.82);
  border-color: rgba(131, 166, 208, 0.16);
}

.form-group input:focus,
.model-form input:focus,
#file-path-input:focus,
#memory-search:focus,
.commands-add input:focus,
.wallpaper-url-input:focus,
.tunnel-form input:focus {
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.memory-tabs,
.batch-mode-group {
  background: rgba(6, 13, 22, 0.76);
  border-color: rgba(131, 166, 208, 0.16);
}

.memory-tab.active,
.batch-mode-btn.active {
  background: rgba(110, 182, 255, 0.14);
  color: var(--accent);
}

.conv-item,
.plan-item,
.tunnel-card,
.model-item,
.model-form,
.model-picker-btn,
.theme-card,
.file-entry,
.cmd-item {
  border-color: var(--border-subtle);
  background: var(--card-bg);
}

.conv-item:hover,
.plan-item:hover,
.tunnel-card:hover,
.model-picker-btn:hover,
.theme-card:hover,
.file-entry:hover,
.cmd-item:hover {
  border-color: rgba(131, 166, 208, 0.24);
}

#connect-modal,
#model-picker,
.modal-overlay {
  background:
    radial-gradient(circle at top, rgba(110, 182, 255, 0.12), transparent 32%),
    rgba(3, 8, 15, 0.72);
}




@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

/* === Lucide Icons === */
.lucide-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  color: inherit;
}

/* === Topbar === */
.topbar {
  height: 38px;
  display: flex;
  align-items: center;
  padding: 0 var(--sp-3);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  gap: var(--sp-3);
  flex-shrink: 0;
  z-index: 25;
  position: relative;
}
.topbar-left  { display: flex; align-items: center; gap: var(--sp-2); }
.topbar-center {
  flex: 1;
  display: flex; align-items: center; gap: 2px;
  min-width: 0;
  overflow: hidden;
}
.topbar-right {
  display: flex; align-items: center; gap: var(--sp-1);
  flex-shrink: 0;
}

.topbar-session-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: none; background: none;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  cursor: pointer;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-session-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.topbar-session-tab.active { background: var(--accent-bg); color: var(--text-primary); }

.session-tab-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.session-tab-dot.running { background: var(--success); }
.session-tab-dot.exited  { background: var(--text-muted); }

.topbar-session-add {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.topbar-session-add:hover { background: var(--bg-hover); color: var(--text-primary); }

.topbar-tools {
  display: flex; align-items: center; gap: 6px;
  overflow: hidden;
}
.topbar-tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  border: 1px solid rgba(131, 166, 208, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  min-width: 0;
}
.topbar-tool-group-label {
  padding: 0 5px 0 6px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.topbar-tool-group-list {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
}
.topbar-tool-tab {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 7px;
  border: none; background: none;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  cursor: pointer;
  border-radius: 8px;
  white-space: nowrap;
}
.topbar-tool-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.topbar-tool-tab.active {
  background: linear-gradient(135deg, rgba(110, 182, 255, 0.22), rgba(110, 182, 255, 0.08));
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px rgba(110, 182, 255, 0.12);
}
.topbar-tool-label { font-size: var(--fs-xs); }

.topbar-cmdk {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  cursor: pointer;
  border-radius: var(--radius-md);
  white-space: nowrap;
  margin-left: var(--sp-2);
}
.topbar-cmdk:hover { border-color: var(--border-hover); color: var(--text-primary); }
.topbar-cmdk kbd {
  font-family: inherit;
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* === Right Panel === */
#workspace-window-layer {
  position: fixed;
  inset: 0;
  z-index: 160;
  pointer-events: none;
}

.git-file-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
  font-family: var(--font-mono);
}

.git-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 650;
}

.git-file-dir {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 10px;
}

.workspace-window {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 320px;
  min-height: 220px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 120px);
  border: 1px solid rgba(131, 166, 208, 0.18);
  border-radius: 16px;
  background: rgba(10, 18, 30, 0.96);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  pointer-events: auto;
}

.workspace-window.active {
  border-color: rgba(110, 182, 255, 0.34);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(110, 182, 255, 0.12);
}

.workspace-window.minimized {
  display: none;
}

.workspace-window.is-dragging,
.workspace-window.is-resizing {
  transition: none;
  opacity: 0.96;
}

.workspace-window-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px 0 12px;
  border-bottom: 1px solid rgba(131, 166, 208, 0.12);
  cursor: move;
  user-select: none;
}

.workspace-window.is-dragging .workspace-window-header {
  cursor: grabbing;
}

.workspace-window-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
}

.workspace-window-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.workspace-window-actions button {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-secondary);
  cursor: pointer;
}

.workspace-window-actions button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.workspace-window-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

/* Legacy tools used to be full-screen absolute panels. Once mounted inside a
   floating window they must stay inside the body, otherwise their z-indexed
   surface covers the WindowManager header and intercepts drag gestures. */
#workspace-window-layer .workspace-window-body > [id$="-panel"] {
  position: static;
  inset: auto;
  z-index: auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.workspace-window-resizer {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
}

.workspace-window-dock {
  position: absolute;
  left: 12px;
  bottom: 88px;
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.workspace-window-dock button {
  padding: 6px 10px;
  border: 1px solid rgba(131, 166, 208, 0.16);
  border-radius: 999px;
  background: rgba(10, 18, 30, 0.9);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
}

.workspace-window[data-window-id="files"] #file-panel {
  position: static;
  display: flex;
  height: 100%;
  min-height: 0;
  border: none;
  background: transparent;
}

.workspace-window[data-window-id="files"] #file-panel.hidden {
  display: flex;
}

.workspace-window[data-window-id="files"] #file-list {
  flex: 1;
  min-height: 0;
}

.workspace-window[data-window-id="files"] #file-preview {
  min-height: 0;
}

.workspace-window[data-window-id="files"] .file-editor {
  min-height: 280px;
}

.workspace-window[data-window-id="git"] {
  min-width: 360px;
  min-height: 280px;
}

.workspace-window[data-window-id="git"] #git-panel {
  position: static;
  display: flex;
  height: 100%;
  min-height: 0;
  border: none;
  background: transparent;
}

.workspace-window[data-window-id="git"] #git-panel.hidden {
  display: flex;
}

.workspace-window[data-window-id="git"] .git-body {
  min-height: 0;
}

/* IDE shell floating window — fill the window body */
.workspace-window[data-window-id="ide"] {
  min-width: 560px;
  min-height: 360px;
}
.workspace-window[data-window-id="ide"] .workspace-window-body {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.workspace-window[data-window-id="ide"] #ide-shell {
  position: static;
  height: 100%;
  min-height: 0;
  border: none;
  background: transparent;
}
.workspace-window[data-window-id="ide"] #ide-shell.hidden {
  display: flex;  /* keep visible inside the window even if class lingers */
}

#right-panel {
  position: absolute;
  top: 38px;
  right: 0;
  bottom: 22px;
  width: 320px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 30;
  overflow: hidden;
}
#right-panel.hidden { display: none; }

.right-panel-resizer {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  cursor: col-resize;
  z-index: 2;
}
.right-panel-resizer:hover { background: var(--accent); }

.right-panel-header {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.right-panel-heading {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.right-panel-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.right-panel-subtitle {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.right-panel-subtitle.hidden,
.right-panel-actions.hidden {
  display: none;
}
.right-panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.right-panel-close {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.right-panel-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.right-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2);
}

.terminal-status-action {
  margin-left: 8px;
  padding: 2px 8px;
  border: 1px solid rgba(131, 166, 208, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.terminal-status-action:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
  border-color: var(--border-hover);
}
.terminal-status-action.active {
  color: var(--warning);
  border-color: rgba(245, 191, 100, 0.28);
  background: rgba(245, 191, 100, 0.1);
}
.terminal-status-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.terminal-new-output {
  margin-left: 4px;
  padding: 3px 9px;
  border: 1px solid rgba(110, 182, 255, 0.28);
  border-radius: 999px;
  background: rgba(110, 182, 255, 0.13);
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}
.terminal-new-output.hidden {
  display: none;
}
.terminal-new-output:hover {
  background: rgba(110, 182, 255, 0.2);
  border-color: rgba(110, 182, 255, 0.42);
}

.snapshot-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
}
.snapshot-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 1;
  padding-bottom: 8px;
  background: var(--bg-surface);
}
.snapshot-search-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(131, 166, 208, 0.16);
  border-radius: 10px;
  background: rgba(6, 13, 22, 0.82);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}
.snapshot-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.snapshot-search-result {
  min-width: 48px;
  color: var(--text-muted);
  font-size: 11px;
  text-align: right;
}
.snapshot-search-nav {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(131, 166, 208, 0.16);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}
.snapshot-search-nav:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.09);
}
.snapshot-search-nav:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}
.snapshot-action-btn {
  padding: 5px 8px;
  border: 1px solid rgba(131, 166, 208, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
}
.snapshot-action-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.09);
}
.snapshot-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.snapshot-meta {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}
.snapshot-content {
  flex: 1;
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(131, 166, 208, 0.1);
  border-radius: 14px;
  background: rgba(6, 13, 22, 0.72);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow: auto;
}
.snapshot-content mark {
  background: rgba(245, 191, 100, 0.34);
  color: var(--text-primary);
  border-radius: 3px;
  padding: 0 2px;
}
.snapshot-content mark.snapshot-search-current {
  background: rgba(124, 156, 255, 0.5);
  box-shadow: 0 0 0 1px rgba(157, 184, 255, 0.55);
}

/* === Command Palette === */
.cmdk-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 220;
}
.cmdk-overlay.hidden { display: none; }

.cmdk-palette {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 560px;
  max-width: calc(100vw - 40px);
  max-height: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 221;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cmdk-palette.hidden { display: none; }

.cmdk-header {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.cmdk-input {
  flex: 1;
  border: none; background: none;
  color: var(--text-primary);
  font-size: var(--fs-lg);
  outline: none;
  font-family: var(--font-sans);
}
.cmdk-input::placeholder { color: var(--text-muted); }

.cmdk-list { flex: 1; overflow-y: auto; padding: var(--sp-1); }
.cmdk-group-header {
  padding: var(--sp-2) var(--sp-2) var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cmdk-item {
  display: flex; align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-primary);
  font-size: var(--fs-md);
}
.cmdk-item.selected { background: var(--accent-bg); }
.cmdk-item-type {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-left: auto;
}
.cmdk-empty {
  padding: var(--sp-6);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.cmdk-footer {
  display: flex; gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.cmdk-footer kbd {
  font-family: inherit;
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

/* === Skeleton Loading === */
.skeleton { padding: var(--sp-3); }
.skeleton-row {
  height: 14px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-2);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  0%   { opacity: 0.3; }
  50%  { opacity: 0.6; }
  100% { opacity: 0.3; }
}

.skeleton-list-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
}
.skeleton-avatar {
  width: 32px; height: 32px;
  background: var(--bg-hover);
  border-radius: var(--radius-md);
  animation: shimmer 1.5s infinite;
}
.skeleton-lines {
  flex: 1;
  display: flex; flex-direction: column; gap: 6px;
}
.skeleton-lines .skeleton-row { margin-bottom: 0; }

/* === Empty State === */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--sp-8);
  text-align: center;
  flex: 1;
  min-height: 200px;
}
.empty-state-icon {
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
}
.empty-state-title {
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--sp-1);
}
.empty-state-desc {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin: 0 0 var(--sp-4);
  max-width: 280px;
}
.empty-state-action {
  padding: 6px 16px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.empty-state-action:hover { border-color: var(--border-hover); background: var(--bg-hover); }

/* === Error Banner === */
.error-banner {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--danger-dim);
  border-bottom: 1px solid var(--danger);
  color: var(--danger);
  font-size: var(--fs-sm);
  flex-shrink: 0;
}
.error-banner-icon { flex-shrink: 0; }
.error-banner-msg { flex: 1; }
.error-banner-retry {
  padding: 2px 10px;
  border: 1px solid var(--danger);
  background: none;
  color: var(--danger);
  font-size: var(--fs-xs);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.error-banner-retry:hover { background: var(--danger); color: #fff; }

/* === Mobile Responsive (≤768px) === */
@media (max-width: 768px) {
  #sidebar.hidden { width: 0 !important; height: 0; border-right: none; }
  #sidebar.expanded {
    width: 100% !important;
    position: fixed;
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }

  #main { left: 0 !important; }
  #sidebar.hidden + #main { top: 0; }

  .topbar {
    height: 42px;
    min-height: 42px;
    padding: 0 8px;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar::-webkit-scrollbar { display: none; }
  .topbar-left,
  .topbar-right {
    flex-shrink: 0;
  }
  .topbar-center {
    flex: 1 0 auto;
    min-width: max-content;
    overflow: visible;
  }

  .topbar-tool-label { display: none; }
  .topbar-tool-group-label { display: none; }
  .topbar-tools {
    gap: 3px;
    overflow: visible;
    flex: 0 0 auto;
  }
  .topbar-tool-group {
    gap: 1px;
    padding: 1px;
    border-color: transparent;
    background: transparent;
    flex-shrink: 0;
  }
  .topbar-tool-group-list {
    overflow: visible;
  }
  .topbar-tool-tab {
    width: 34px;
    height: 34px;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
  }
  .topbar-session-tab { max-width: 132px; }
  .topbar-session-add,
  .topbar-cmdk {
    width: 34px;
    height: 34px;
    justify-content: center;
    padding: 0;
    margin-left: 0;
    flex-shrink: 0;
  }
  .topbar-cmdk-label { display: none; }
  .topbar-cmdk kbd { display: none; }

  #terminal-wrapper {
    margin: 7px 7px 5px;
  }
  #terminal-container {
    border-radius: 16px;
    padding: 6px;
  }
  #terminal-status {
    margin: 0 7px;
    gap: 6px;
    min-height: 36px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #terminal-status::-webkit-scrollbar { display: none; }
  #status-session,
  #status-info,
  .terminal-status-action,
  .terminal-new-output {
    flex: 0 0 auto;
  }
  #status-info {
    margin-left: 0;
  }
  #virtual-keys {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    padding: 6px 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #virtual-keys::-webkit-scrollbar { display: none; }
  #virtual-keys button {
    flex: 0 0 auto;
  }
  #input-bar {
    margin: 0 7px 7px;
    gap: 8px;
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    border-radius: 17px;
  }
  #text-input {
    min-height: 44px;
    max-height: 112px;
    padding: 11px 12px;
    font-size: 13px;
    border-radius: 13px;
  }
  #send-btn {
    width: 48px;
    min-height: 44px;
    border-radius: 13px;
  }

  #right-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    height: min(78dvh, 720px);
    width: 100% !important;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -18px 44px rgba(0, 0, 0, 0.45);
    z-index: 70;
  }
  .right-panel-resizer {
    display: none;
  }
  .right-panel-header {
    min-height: 48px;
    padding: 10px 12px;
  }
  .right-panel-actions {
    gap: 4px;
    overflow-x: auto;
    max-width: 44vw;
    scrollbar-width: none;
  }
  .right-panel-actions::-webkit-scrollbar { display: none; }
  .right-panel-body {
    padding: 10px;
    -webkit-overflow-scrolling: touch;
  }
  .snapshot-toolbar {
    flex-wrap: wrap;
    align-items: stretch;
  }
  .snapshot-search-input {
    flex-basis: 100%;
  }
  .snapshot-search-result,
  .snapshot-search-nav,
  .snapshot-action-btn {
    flex: 0 0 auto;
  }
  .workspace-window-layer {
    display: none;
  }

  .cmdk-palette { top: 10%; width: calc(100vw - 32px); }
  .toast { min-width: auto; max-width: calc(100vw - 40px); }
}
