/* static/style.css — GWS Agent Web (chatbot UI redesign) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
  --bg:        #0d0f14;
  --surface:   #151820;
  --surface2:  #1c2030;
  --surface3:  #232840;
  --border:    #2a3050;
  --border2:   #374060;

  --text:      #e8eaf2;
  --text-muted:#8890b0;
  --text-dim:  #555f80;

  --accent:    #5b6ef5;
  --accent-h:  #7080ff;
  --accent-glow: rgba(91,110,245,.22);

  --green:     #3dd68c;
  --green-bg:  rgba(61,214,140,.12);
  --blue:      #4da6ff;
  --blue-bg:   rgba(77,166,255,.12);
  --yellow:    #f5c518;
  --yellow-bg: rgba(245,197,24,.12);
  --red:       #ff5f6d;
  --red-bg:    rgba(255,95,109,.12);
  --grey:      #8890b0;
  --grey-bg:   rgba(136,144,176,.10);

  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
  --transition: 180ms ease;

  --topbar-h:  52px;
  --sidebar-w: 260px;
  --right-w:   320px;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

/* ── App shell ──────────────────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Top bar ────────────────────────────────────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 40;
  flex-shrink: 0;
}

.logo {
  font-weight: 700;
  font-size: 15px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  margin-right: 4px;
}

/* Topbar nav icon buttons */
.btn-nav-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.btn-nav-icon:hover { background: var(--surface2); color: var(--text); }

/* ── Workspace switcher ─────────────────────────────────────────────────── */
.ws-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.ws-switch-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  max-width: 220px;
  font-family: 'Inter', sans-serif;
}
.ws-switch-btn:hover { border-color: var(--accent); background: var(--surface3); }
.ws-switch-btn.open { border-color: var(--accent); }
#ws-switch-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  color: var(--text-muted);
}
#ws-switch-name.has-ws { color: var(--text); }
.ws-chevron {
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform var(--transition);
}
.ws-switch-btn.open .ws-chevron { transform: rotate(180deg); }

/* Auth badge */
#auth-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  white-space: nowrap;
  cursor: default;
  flex-shrink: 0;
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--grey);
  flex-shrink: 0;
  transition: background var(--transition);
}
#auth-badge.ok   .dot { background: var(--green); }
#auth-badge.warn .dot { background: var(--yellow); }
#auth-badge.ok   { border-color: rgba(61,214,140,.35); }

/* ── Workspace dropdown ─────────────────────────────────────────────────── */
.ws-dropdown {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  width: 280px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 200;
  display: none;
  overflow: hidden;
  animation: slideDown .15s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } }
.ws-dropdown.open { display: block; }

.ws-dropdown-header {
  padding: 10px 16px 6px;
  border-bottom: 1px solid var(--border);
}
.ws-dropdown-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.ws-dropdown-list { padding: 6px; max-height: 300px; overflow-y: auto; }
.ws-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.ws-dropdown-item:hover { background: var(--surface3); }
.ws-dropdown-item.active { background: var(--accent-glow); }
.ws-dropdown-item .ws-item-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ws-dropdown-item .ws-item-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--red);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  transition: opacity var(--transition), background var(--transition);
  line-height: 1;
}
.ws-dropdown-item:hover .ws-item-delete { opacity: 1; }
.ws-dropdown-item .ws-item-delete:hover { background: var(--red-bg); }
.ws-dropdown-footer {
  padding: 6px;
  border-top: 1px solid var(--border);
}
.ws-dropdown-new-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: 'Inter', sans-serif;
}
.ws-dropdown-new-btn:hover { background: var(--accent-glow); color: var(--accent); }

/* ── Main grid ──────────────────────────────────────────────────────────── */
#main-grid {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr 0px;
  grid-template-rows: 1fr;
  overflow: hidden;
  position: relative;
  transition: grid-template-columns .2s ease;
}
#main-grid.sidebar-collapsed {
  grid-template-columns: 0px 1fr 0px;
}
#main-grid.right-open {
  grid-template-columns: var(--sidebar-w) 1fr var(--right-w);
}
#main-grid.sidebar-collapsed.right-open {
  grid-template-columns: 0px 1fr var(--right-w);
}

/* ── Left sidebar ───────────────────────────────────────────────────────── */
.sidebar-left {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: width .2s ease;
  min-width: 0;
}
.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  min-width: var(--sidebar-w);
}
.sidebar-inner::-webkit-scrollbar { width: 4px; }
.sidebar-inner::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* New chat button */
.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  font-family: 'Inter', sans-serif;
  margin-bottom: 6px;
}
.btn-new-chat:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}
.btn-new-chat:disabled { opacity: .45; cursor: not-allowed; }

/* Auth warning in sidebar */
#auth-warning {
  display: none;
  align-items: flex-start;
  gap: 7px;
  padding: 8px 10px;
  margin-bottom: 4px;
  background: var(--yellow-bg);
  border: 1px solid rgba(245,197,24,.25);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--yellow);
  line-height: 1.5;
  flex-shrink: 0;
}
#auth-warning svg { flex-shrink: 0; margin-top: 2px; }
#auth-warning.show { display: flex; }
#auth-warning strong { color: var(--text); font-weight: 600; }
.btn-auth-warning-setup {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(124, 58, 237, 0.35);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.btn-auth-warning-setup:hover {
  background: rgba(124, 58, 237, 0.18);
  border-color: var(--accent);
}

/* Sidebar section label */
.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 8px 10px 4px;
}

/* Project folders */
.sidebar-projects {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.sidebar-projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 2px 10px;
}
.btn-folder-add {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-folder-add:hover {
  border-color: var(--border);
  color: var(--accent);
  background: var(--surface2);
}
.folder-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.folder-item-row {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.folder-item-row .folder-item { flex: 1; min-width: 0; }
.folder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: 12.5px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}
.folder-item:hover { background: var(--surface2); color: var(--text); }
.folder-item.active { background: var(--accent-glow); color: var(--accent); }
.folder-item-icon { flex-shrink: 0; font-size: 13px; opacity: .85; }
.folder-item-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.folder-item-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface3);
  padding: 1px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}
.folder-item-menu-btn,
.history-item-menu-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition), color var(--transition);
}
.folder-item-row:hover .folder-item-menu-btn,
.history-item:hover .history-item-menu-btn { opacity: 1; }
.folder-item-menu-btn:hover,
.history-item-menu-btn:hover {
  background: var(--surface3);
  color: var(--text);
}
.history-empty {
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 12px 12px;
  line-height: 1.45;
}
.chat-folder-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  padding: 4px 12px 0;
  flex-shrink: 0;
}
.floating-menu {
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.floating-menu-wide { min-width: 180px; max-height: 280px; overflow-y: auto; }
.floating-menu-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  padding: 6px 8px 4px;
}
.floating-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.floating-menu button:hover { background: var(--surface2); color: var(--text); }
.floating-menu button.danger { color: var(--red); }
.floating-menu button.danger:hover { background: var(--red-bg); }

#folder-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 9000;
  align-items: center;
  justify-content: center;
}
#folder-modal-overlay.show { display: flex; }
#folder-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  width: min(400px, 92vw);
  box-shadow: 0 16px 48px rgba(0,0,0,.4);
}
#folder-modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
#folder-modal-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
}
#folder-modal-input:focus { border-color: var(--accent); outline: none; }
#folder-modal-hint { font-size: 11px; color: var(--text-dim); margin-top: 6px; }
#folder-modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ── Backup tab & import modal ───────────────────────────────────────────── */
.backup-section { margin-bottom: 24px; }
.backup-section .btn-primary,
.backup-section .btn-secondary { margin-top: 10px; }

#import-modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 260;
  align-items: center;
  justify-content: center;
}
#import-modal-overlay.show { display: flex; }
.import-modal-panel {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 440px; max-width: 94vw;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
}
.import-modal-panel h3 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.import-modal-file {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 16px;
  word-break: break-all;
}
.import-mode-fieldset {
  border: none;
  padding: 0;
  margin: 16px 0;
}
.import-mode-fieldset legend { margin-bottom: 8px; }
.import-mode-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 8px;
  cursor: pointer;
}
.import-confirm-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--red);
  margin: 12px 0 4px;
  cursor: pointer;
}
#import-target-name {
  width: 100%; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px;
}
#import-target-name:focus { border-color: var(--accent); outline: none; }
#import-modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* History groups */
.history-groups { display: flex; flex-direction: column; gap: 0; flex: 1; min-height: 0; }
.history-date-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 4px; }
.history-date-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 6px 10px 3px;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  color: var(--text-muted);
  font-size: 12.5px;
}
.history-item:hover { background: var(--surface2); color: var(--text); }
.history-item.active { background: var(--accent-glow); color: var(--accent); }
.history-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item-status {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  flex-shrink: 0;
}
.history-item-status.completed { background: var(--green-bg); color: var(--green); }
.history-item-status.error { background: var(--red-bg); color: var(--red); }
.history-item-status.running { background: var(--blue-bg); color: var(--blue); }

/* Sidebar sections (scheduled tasks, etc.) */
.sidebar-section { margin-top: 4px; flex-shrink: 0; }
.sidebar-section-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: 'Inter', sans-serif;
}
.sidebar-section-header:hover { background: var(--surface2); color: var(--text); }
.sidebar-section-header span { flex: 1; text-align: left; }
.section-chevron { flex-shrink: 0; transition: transform var(--transition); }
.sidebar-section-header[aria-expanded="true"] .section-chevron { transform: rotate(180deg); }
.sidebar-section-body { padding: 2px 4px 4px; display: flex; flex-direction: column; gap: 1px; }
.sidebar-task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
}
.sidebar-task-name { flex: 1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-task-status {
  font-size: 10px; color: var(--accent); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 88px; display: none;
}
.sidebar-task-status.visible { display: inline; }
.sidebar-task-item-running .sidebar-task-name { color: var(--accent); }
.sidebar-task-run {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 10px;
  padding: 1px 6px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.sidebar-task-run:hover { border-color: var(--green); color: var(--green); }
.sidebar-task-run:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.sidebar-task-run:disabled:hover { border-color: var(--border); color: var(--text-muted); }

/* Sidebar bottom */
.sidebar-bottom {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-settings-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-family: 'Inter', sans-serif;
}
.sidebar-settings-btn:hover:not(:disabled) { background: var(--surface2); color: var(--text); }
.sidebar-settings-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Chat center panel ──────────────────────────────────────────────────── */
#chat-main {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  position: relative;
  min-width: 0;
}

/* Welcome state */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 14px;
  padding: 40px;
  text-align: center;
}
.welcome-icon {
  font-size: 52px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}
.welcome-title { font-size: 22px; font-weight: 600; color: var(--text); }
.welcome-sub { font-size: 14px; color: var(--text-muted); max-width: 320px; }
.btn-welcome-new {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  margin-top: 4px;
  font-family: 'Inter', sans-serif;
}
.btn-welcome-new:hover { opacity: .9; transform: translateY(-1px); }

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 0 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Message group */
.msg-group {
  display: flex;
  gap: 12px;
  padding: 6px 24px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  animation: msgIn .18s ease;
}
@keyframes msgIn { from { opacity:0; transform:translateY(6px); } }

.msg-group.user { justify-content: flex-end; }
.msg-group.agent { justify-content: flex-start; }

/* Agent avatar */
.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 4px;
  color: #fff;
  font-weight: 700;
  position: relative;
}
.msg-group.agent.processing .msg-avatar {
  animation: agent-avatar-spin 1.1s linear infinite;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.25);
}
@keyframes agent-avatar-spin {
  to { transform: rotate(360deg); }
}
.agent-processing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 0;
}
.agent-processing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.agent-processing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: agent-dot-bounce 1.2s ease-in-out infinite;
}
.agent-processing-dots span:nth-child(2) { animation-delay: .15s; }
.agent-processing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes agent-dot-bounce {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.msg-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 75%;
}
.msg-group.user .msg-content { max-width: 72%; align-items: flex-end; }

/* Message bubble */
.msg-bubble {
  padding: 11px 15px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}
.msg-group.user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: var(--radius-sm);
}
.msg-group.agent .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-top-left-radius: var(--radius-sm);
}

/* Thinking block (inside agent bubble area) */
.thinking-block {
  border: 1px solid rgba(167,139,250,.22);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 12px;
  max-width: 100%;
}
.thinking-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  background: rgba(167,139,250,.08);
  cursor: pointer;
  user-select: none;
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 500;
  transition: background var(--transition);
}
.thinking-header:hover { background: rgba(167,139,250,.14); }
.thinking-label { flex: 1; }
.thinking-chevron { font-size: 10px; transition: transform var(--transition); color: rgba(196,181,253,.6); }
.thinking-block.collapsed .thinking-chevron { transform: rotate(-90deg); }
.thinking-body {
  padding: 8px 12px;
  background: rgba(167,139,250,.04);
  color: #d0c4f7;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}
.thinking-block.collapsed .thinking-body { display: none; }

/* Tool call group (inside agent message area) */
.tool-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 12px;
}
.tool-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface2);
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  text-align: left;
  font-family: 'Inter', sans-serif;
}
.tool-group-toggle:hover { background: var(--surface3); color: var(--text); }
.tool-group-toggle svg { flex-shrink: 0; transition: transform var(--transition); }
.tool-group.expanded .tool-group-toggle svg { transform: rotate(90deg); }
.tool-group-body {
  display: none;
  flex-direction: column;
  gap: 0;
  background: var(--surface);
  max-height: 240px;
  overflow-y: auto;
}
.tool-group.expanded .tool-group-body { display: flex; }
.tool-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  word-break: break-word;
}
.tool-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}
.tool-item-details {
  margin-top: 2px;
  font-size: 10px;
}
.tool-item-details > summary {
  cursor: pointer;
  color: var(--text-dim);
  user-select: none;
}
.tool-item-time { color: var(--text-dim); font-size: 10px; flex-shrink: 0; min-width: 50px; padding-top: 1px; }
.tool-item-name {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--blue-bg);
  color: var(--blue);
  align-self: flex-start;
}
.tool-item-content { flex: 1; color: var(--text); }
.tool-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}
.tool-item-status {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--grey-bg);
  color: var(--grey);
}
.tool-item-running .tool-item-status { background: var(--yellow-bg); color: var(--yellow); }
.tool-item-done .tool-item-status { background: var(--green-bg); color: var(--green); }
.tool-item-error .tool-item-status { background: var(--red-bg); color: var(--red); }
.tool-item-detail {
  width: 100%;
  margin: 4px 0 0;
  padding: 6px 8px;
  font-size: 10px;
  line-height: 1.45;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
}
.tool-item-result { color: var(--text-muted); }
.agent-status-line {
  font-size: 11px;
  color: var(--text-dim);
  padding: 2px 0 6px;
  font-style: italic;
}

/* Agent response wrapper + copy control */
.agent-response-wrap {
  position: relative;
  max-width: 100%;
  align-self: flex-start;
}
.agent-response-wrap .msg-bubble {
  padding-top: 36px;
}
.btn-copy-response {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity var(--transition), background var(--transition), color var(--transition), border-color var(--transition);
}
.agent-response-wrap:hover .btn-copy-response,
.btn-copy-response:focus-visible,
.btn-copy-response.copied {
  opacity: 1;
}
.btn-copy-response:hover {
  background: var(--surface3);
  color: var(--text);
  border-color: var(--text-dim);
}
.btn-copy-response.copied {
  color: var(--green);
  border-color: rgba(74, 222, 128, .35);
}
.btn-copy-response svg { flex-shrink: 0; }

/* Agent markdown response area */
.agent-response {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
}
.agent-response h1,.agent-response h2,.agent-response h3,.agent-response h4 {
  color: var(--text); font-weight: 600; margin: .9em 0 .35em; line-height: 1.3;
}
.agent-response h1 { font-size: 1.2em; }
.agent-response h2 { font-size: 1.05em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }
.agent-response h3 { font-size: 1em; }
.agent-response h4 { font-size: .9em; color: var(--text-muted); }
.agent-response p { margin: .4em 0; }
.agent-response strong { font-weight: 600; }
.agent-response em { font-style: italic; color: var(--text-muted); }
.agent-response a { color: var(--accent); text-decoration: none; }
.agent-response a:hover { text-decoration: underline; }
.agent-response ul,.agent-response ol { padding-left: 1.4em; margin: .35em 0; }
.agent-response li { margin: .15em 0; }
.agent-response code {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px; color: var(--blue);
}
.agent-response pre {
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 13px; overflow-x: auto; margin: .5em 0;
}
.agent-response pre code { background: none; border: none; padding: 0; color: var(--text); font-size: 12px; }
.agent-response blockquote {
  margin: .5em 0; padding: .4em .8em;
  border-left: 3px solid var(--accent);
  background: var(--accent-glow);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
}
.agent-response hr { border: none; border-top: 1px solid var(--border); margin: .8em 0; }
.agent-response table { width: 100%; border-collapse: collapse; font-size: 13px; margin: .5em 0; }
.agent-response th {
  background: var(--surface3); color: var(--text-muted);
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 6px 10px; border: 1px solid var(--border); text-align: left;
}
.agent-response td { padding: 5px 10px; border: 1px solid var(--border); vertical-align: top; word-break: break-word; }
.agent-response tr:nth-child(even) td { background: rgba(255,255,255,.02); }

/* Collapsible run details (tool actions summary) */
.agent-run-details {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  font-size: 12px;
}
.agent-run-details > summary {
  cursor: pointer;
  user-select: none;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  list-style: none;
}
.agent-run-details > summary::-webkit-details-marker { display: none; }
.agent-run-details > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  font-size: 10px;
  transition: transform var(--transition);
}
.agent-run-details[open] > summary::before { transform: rotate(90deg); }
.agent-run-details-body {
  padding: 0 10px 10px;
  border-top: 1px solid var(--border);
}
.agent-run-details-body p {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.agent-summary-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.action-tag {
  font-size: 11px; padding: 2px 8px;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: 999px; color: var(--text-muted);
}

/* Context indicator shown in input bar when there are prior turns */
.chat-context-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: var(--accent-glow);
  border: 1px solid rgba(91,110,245,.3);
  border-radius: 999px;
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 6px;
  width: fit-content;
}

/* Cancelled notice inside agent bubble */
.msg-cancelled {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 4px 10px;
  background: var(--grey-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-dim);
}

/* Stop button while a run is active */
.btn-send.running {
  background: var(--red);
}
.btn-send.running .send-icon {
  display: none;
}
.btn-send.running::after {
  content: '';
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 2px;
  position: absolute;
  animation: stop-pulse 1s ease-in-out infinite;
}
@keyframes stop-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.88); }
}

/* Status in history view messages */
.msg-status-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 2px;
}

/* ── Chat input bar ──────────────────────────────────────────────────────── */
.chat-input-bar {
  flex-shrink: 0;
  padding: 8px 24px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  align-self: stretch;
}
/* Full width override so the bar always spans the full center column */
#chat-main .chat-input-bar { max-width: none; padding: 8px 24px 16px; }

.chat-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.chat-examples.hidden { display: none; }
.example-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}
.example-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px 6px 6px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.chat-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
#chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 4px 0;
}
#chat-input::placeholder { color: var(--text-dim); }
.btn-send {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity var(--transition), transform var(--transition);
  position: relative;
}
.btn-send:hover:not(:disabled) { opacity: .88; transform: scale(1.04); }
.btn-send:disabled { opacity: .35; cursor: not-allowed; }
.btn-send.running { background: var(--red); }
.send-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .65s linear infinite;
  display: none;
  position: absolute;
}
.btn-send.running .send-spinner { display: none; }
.btn-send.running .send-icon { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Right sidebar (file manager) ───────────────────────────────────────── */
.sidebar-right {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
  min-width: 0;
  transition: width .2s ease;
}
.sidebar-right-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: var(--right-w);
  overflow: hidden;
}
.sidebar-right-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}
.sidebar-right-header span { flex: 1; }
.btn-icon-sm {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition);
  text-decoration: none;
  flex-shrink: 0;
}
.btn-icon-sm:hover { border-color: var(--border); color: var(--text); background: var(--surface2); }

/* File tree */
.file-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  min-height: 0;
}
.file-tree::-webkit-scrollbar { width: 4px; }
.file-tree::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.file-tree-empty { font-size: 12px; color: var(--text-dim); padding: 12px 10px; text-align: center; }
.file-tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-tree-item:hover { background: var(--surface2); color: var(--text); }
.file-tree-item.active { background: var(--accent-glow); color: var(--accent); }
.file-tree-item.is-dir { color: var(--blue); font-weight: 500; cursor: default; }
.file-tree-item svg { flex-shrink: 0; }
.file-tree-name { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.file-tree-size { font-size: 10px; color: var(--text-dim); flex-shrink: 0; }

/* File viewer */
.file-viewer {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: 50%;
  min-height: 120px;
  flex-shrink: 0;
}
.file-viewer-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.file-viewer-name {
  flex: 1;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'JetBrains Mono', monospace;
}
.file-viewer-content {
  flex: 1;
  overflow: auto;
  padding: 10px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  margin: 0;
  background: var(--bg);
}

/* Right panel toggle button (tab on the right edge) */
.btn-right-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 60px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  z-index: 10;
}
.btn-right-toggle:hover { background: var(--surface2); color: var(--accent); }
#main-grid.right-open .btn-right-toggle { display: none; }

/* ── Settings drawer ────────────────────────────────────────────────────── */
.settings-overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  /* Start after the left sidebar so the drawer covers only the center+right area */
  left: var(--sidebar-w);
  right: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(3px);
  z-index: 150;
  display: none;
  align-items: stretch;
  justify-content: flex-end;
}
.settings-overlay.open { display: flex; }
/* When sidebar is collapsed, the overlay covers the full viewport width */
.settings-overlay.sidebar-collapsed {
  left: 0;
}

.settings-drawer {
  width: 100%;
  max-width: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  animation: drawerIn .2s ease;
  overflow: hidden;
}
@keyframes drawerIn { from { transform: translateX(40px); opacity: 0; } }

.settings-drawer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface2);
}
.settings-drawer-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Settings tab bar */
.stab-bar {
  display: flex;
  gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}
.stab-bar::-webkit-scrollbar { display: none; }
.stab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}
.stab:hover { color: var(--text); }
.stab.active { color: var(--accent); border-bottom-color: var(--accent); }

.settings-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}
.stab-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  overflow-y: auto;
  height: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.stab-panel::-webkit-scrollbar { width: 4px; }
.stab-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.stab-panel.active { display: flex; }

/* SKILL editor */
#skill-editor {
  flex: 1;
  min-height: 260px;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  line-height: 1.65;
  padding: 12px 14px;
  outline: none;
  resize: vertical;
  transition: border-color var(--transition);
}
#skill-editor:focus { border-color: var(--accent); }
#skill-editor::placeholder { color: var(--text-dim); }

/* ── Config form components ─────────────────────────────────────────────── */
.config-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field-row { display: flex; flex-direction: column; gap: 4px; }
.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.field-hint { font-size: 11px; color: var(--text-dim); line-height: 1.5; }
.config-section input[type="text"],
.config-section input[type="email"],
.config-section input[type="url"],
.config-section textarea,
.config-section select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  padding: 8px 10px;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}
.config-section input:focus,
.config-section textarea:focus,
.config-section select:focus { border-color: var(--accent); }
.config-section textarea { resize: vertical; min-height: 56px; }
.config-section select { cursor: pointer; }

.toggle-row { flex-direction: row !important; align-items: center; justify-content: space-between; }
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border2);
  border-radius: 999px;
  transition: background var(--transition);
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

.btn-save { align-self: flex-start; margin-top: 4px; }
.add-row { display: flex; gap: 6px; flex-wrap: wrap; }
.add-row input, .add-row select {
  flex: 1; min-width: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  font-family: 'Inter', sans-serif;
  transition: border-color var(--transition);
}
.add-row input:focus, .add-row select:focus { border-color: var(--accent); }
.btn-add {
  padding: 7px 12px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  font-family: 'Inter', sans-serif;
}
.btn-add:hover { background: var(--accent); color: #fff; }

.id-list, .refs-list, .mcps-list, .tasks-list { display: flex; flex-direction: column; gap: 4px; }
.id-row, .ref-row, .mcp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.id-value { font-family: 'JetBrains Mono', monospace; color: var(--text); flex: 1; word-break: break-all; }
.id-label { color: var(--text-muted); font-size: 11px; }
.id-remove {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 13px; padding: 2px 5px;
  border-radius: 4px; line-height: 1; flex-shrink: 0;
  transition: all var(--transition);
}
.id-remove:hover { background: var(--red-bg); color: var(--red); }

/* Members */
.member-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.member-row {
  display: grid;
  grid-template-columns: 30px 1fr auto auto 28px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.member-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.member-email { font-size: 13px; font-weight: 500; }
.member-email em { color: var(--text-dim); font-style: normal; font-size: 11px; }
.member-name { font-size: 11px; color: var(--text-muted); }
.badge-role-manager { background: rgba(167,139,250,.18); color: #c4b5fd; font-size: 10px; padding: 2px 7px; border-radius: 999px; }
.badge-role-member  { background: var(--grey-bg); color: var(--grey); font-size: 10px; padding: 2px 7px; border-radius: 999px; }

/* Tasks */
.tasks-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.task-row {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
}
.task-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-label { font-size: 13px; font-weight: 600; flex: 1; }
.task-cron code { font-size: 11px; color: var(--text-muted); }
.task-prompt { font-size: 12px; color: var(--text-muted); padding: 5px 8px; background: var(--surface3); border-radius: var(--radius-sm); }
.task-meta { font-size: 11px; color: var(--text-dim); }
.task-status { display: inline-flex; align-items: center; gap: 6px; }
.task-status.task-run-active { color: var(--accent); font-weight: 600; }
.task-status.task-run-active::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: task-pulse 1.2s ease-in-out infinite;
}
.task-row-running {
  border-color: rgba(61,214,140,.45);
  box-shadow: 0 0 0 1px rgba(61,214,140,.12);
}
@keyframes task-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}
.btn-trigger {
  background: var(--green-bg); border: 1px solid rgba(61,214,140,.3);
  border-radius: var(--radius-sm); color: var(--green);
  font-size: 11px; font-weight: 600; padding: 3px 8px; cursor: pointer;
  transition: all var(--transition);
}
.btn-trigger:hover { background: var(--green); color: #000; }
.btn-trigger:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.btn-trigger:disabled:hover { background: var(--green-bg); color: var(--green); }
.btn-task-edit,
.btn-task-history,
.btn-task-toggle {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 11px; padding: 3px 8px; cursor: pointer;
  transition: all var(--transition);
}
.btn-task-edit:hover,
.btn-task-history:hover,
.btn-task-toggle:hover { border-color: var(--accent); color: var(--accent); }
#task-history-modal-overlay {
  z-index: 9500;
}
.task-history-title-wrap {
  flex: 1;
  min-width: 0;
}
.task-history-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  margin: 2px 0 0;
}
.task-history-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow: hidden;
  min-height: 0;
}
.task-history-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.task-history-pagination.hidden { display: none; }
.task-history-page-info {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  flex: 1;
}
.task-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.task-history-list::-webkit-scrollbar { width: 4px; }
.task-history-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.task-history-item {
  padding: 0;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.task-history-item.collapsed { border-color: var(--border); }
.task-history-item.expanded { border-color: rgba(61,214,140,.25); }
.task-history-item-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  background: none;
  border: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}
.task-history-item-head:hover { background: rgba(255,255,255,.03); }
.task-history-item.expanded .task-history-item-head {
  border-bottom: 1px solid var(--border);
}
.task-history-summary {
  flex: 1 1 100%;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-history-item.expanded .task-history-summary { display: none; }
.task-history-item.collapsed .task-history-summary { display: block; }
.task-history-chevron {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.task-history-item.expanded .task-history-chevron {
  transform: rotate(-135deg);
  margin-top: 4px;
}
.task-history-item-body {
  padding: 10px 12px 12px;
}
.task-history-item.collapsed .task-history-item-body { display: none; }
.task-history-when { font-size: 12px; font-weight: 600; }
.task-history-trigger {
  font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px; padding: 1px 6px;
}
.task-history-status { font-size: 11px; font-weight: 600; }
.task-run-ok { color: var(--green); }
.task-run-error { color: var(--red); }
.task-run-active { color: var(--accent); }
.task-history-prompt { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; white-space: pre-wrap; }
.task-history-response {
  font-size: 12px; color: var(--text); white-space: pre-wrap;
  padding: 8px; background: var(--surface2); border-radius: var(--radius-sm);
  max-height: 220px; overflow-y: auto;
}
.task-history-response-empty { color: var(--text-dim); font-style: italic; }
.task-form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-task-delete {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 13px; padding: 2px 5px;
  border-radius: 4px; transition: all var(--transition);
}
.btn-task-delete:hover { background: var(--red-bg); color: var(--red); }

/* Web refs */
.ref-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  position: relative;
}
.ref-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ref-label {
  flex: 1;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ref-label:hover { text-decoration: underline; }
.ref-url {
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  font-family: 'JetBrains Mono', monospace;
}
.ref-desc {
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.4;
}

/* MCPs */
.mcp-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; background: var(--surface3);
  border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px;
}
.mcp-name { font-weight: 600; color: var(--blue); min-width: 70px; }
.mcp-cmd { flex: 1; font-family: 'JetBrains Mono', monospace; color: var(--text-muted); font-size: 11px; word-break: break-all; }
.btn-mcp-edit {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 11px; padding: 3px 8px; cursor: pointer;
  transition: all var(--transition); flex-shrink: 0;
}
.btn-mcp-edit:hover { border-color: var(--accent); color: var(--accent); }
.mcp-form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mcp-auth-details {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
}
.mcp-auth-details summary {
  cursor: pointer;
  list-style: disclosure-closed;
  margin-bottom: 4px;
}
.mcp-auth-details[open] summary { margin-bottom: 8px; }

.tab-desc { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.empty-hint { font-size: 12px; color: var(--text-dim); padding: 8px 0; }

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge {
  font-size: 10px; font-weight: 600; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 999px; text-transform: uppercase; flex-shrink: 0;
}
.badge-idle      { background: var(--grey-bg);   color: var(--grey);  }
.badge-running   { background: var(--blue-bg);   color: var(--blue);  animation: pulse 1.5s infinite; }
.badge-completed { background: var(--green-bg);  color: var(--green); }
.badge-error     { background: var(--red-bg);    color: var(--red);   }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* Buttons */
.btn-primary {
  padding: 8px 18px;
  background: var(--accent); border: 1px solid transparent;
  border-radius: var(--radius-sm); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity var(--transition); font-family: 'Inter', sans-serif;
}
.btn-primary:hover { opacity: .88; }
.btn-secondary {
  padding: 8px 18px;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: 13px; cursor: pointer;
  transition: all var(--transition); font-family: 'Inter', sans-serif;
}
.btn-secondary:hover { border-color: var(--border2); color: var(--text); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 13px; color: var(--text);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 300;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok    { border-color: rgba(61,214,140,.4); color: var(--green); }
#toast.error { border-color: rgba(255,95,109,.4); color: var(--red); }

/* ── New workspace modal ─────────────────────────────────────────────────── */
#modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 250;
  align-items: center;
  justify-content: center;
}
#modal-overlay.show { display: flex; }
#modal {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 400px; max-width: 94vw;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform:translateY(20px); opacity:0; } }
#modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
#modal input {
  width: 100%; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px;
  outline: none; transition: border-color var(--transition);
  font-family: 'JetBrains Mono', monospace;
}
#modal input:focus { border-color: var(--accent); }
#modal-hint { font-size: 11px; color: var(--text-dim); margin-top: 6px; }
#modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body { overflow: auto; }
  #app { height: auto; overflow: visible; }
  #main-grid {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto 1fr auto;
    height: auto;
  }
  .sidebar-left { border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-right { display: none; }
  .btn-right-toggle { display: none; }
  .chat-messages { min-height: 60vh; }
  /* On mobile the sidebar stacks vertically; overlay should cover full width */
  .settings-overlay { left: 0; }
}

/* Animations */
@keyframes fadeIn { from { opacity:0; transform:translateY(4px); } }

/* ── Topbar: Google Workspace service strip ─────────────────────────────────── */
.topbar-account-area {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.gws-service-strip {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.gws-svc-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: border-color var(--transition), background var(--transition), color var(--transition), opacity var(--transition);
}
.gws-svc-icon svg {
  width: 13px;
  height: 13px;
  display: block;
}
.gws-svc-icon.gws-svc-ok {
  border-color: rgba(61, 214, 140, 0.45);
  color: var(--green);
  background: rgba(61, 214, 140, 0.1);
  opacity: 1;
}
.gws-svc-icon.gws-svc-warn {
  border-color: rgba(234, 179, 8, 0.45);
  color: #eab308;
  background: rgba(234, 179, 8, 0.1);
  opacity: 1;
}
.gws-svc-icon.gws-svc-off {
  border-color: rgba(255, 95, 109, 0.45);
  color: var(--red);
  background: var(--red-bg);
  opacity: 1;
}
.gws-svc-icon:hover {
  opacity: 1;
  border-color: var(--accent);
  background: var(--surface3);
}

/* ── User account chip (topbar) ─────────────────────────────────────────────── */
.btn-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 4px;
  border-radius: 20px;
  border: 1px solid var(--border, #2a2a2a);
  background: transparent;
  cursor: pointer;
  color: var(--fg, #e8e8e8);
  font-size: 0.78rem;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.btn-user-chip:hover {
  background: var(--surface-2, #1c1c1c);
  border-color: var(--muted, #555);
}
.user-chip-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent, #4f8ef7);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.user-chip-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.user-chip-email {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted, #aaa);
}

/* ── Login overlay ─────────────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg, #0d0d0d);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 40px;
  background: var(--surface, #161616);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 16px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.login-logo {
  font-size: 2.5rem;
  line-height: 1;
  color: var(--accent, #4f8ef7);
}
.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  color: var(--fg, #e8e8e8);
}
.login-sub {
  font-size: 0.875rem;
  color: var(--muted, #888);
  margin: 0;
}
.btn-google-signin {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 22px;
  background: #fff;
  color: #3c4043;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  border: 1px solid #dadce0;
  transition: box-shadow 0.15s, background 0.15s;
}
.btn-google-signin:hover {
  background: #f8f8f8;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.login-error {
  font-size: 0.8rem;
  color: #f87171;
  margin: 0;
}

/* ── My Connections tab ─────────────────────────────────────────────────────── */
.connections-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 18px;
  border-bottom: 1px solid var(--border, #2a2a2a);
  margin-bottom: 16px;
}
.connections-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent, #4f8ef7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  overflow: hidden;
}
.connections-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.connections-user-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.connections-email {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg, #e8e8e8);
}
.connections-display-name {
  font-size: 0.78rem;
  color: var(--muted, #888);
}
.connections-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.conn-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2, #1c1c1c);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 8px;
  transition: border-color 0.15s;
}
.conn-card.connected {
  border-color: var(--green, #22c55e);
}
.conn-card.unavailable {
  opacity: 0.55;
}
.conn-icon {
  font-size: 1.2rem;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.conn-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.conn-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg, #e8e8e8);
}
.conn-desc {
  font-size: 0.75rem;
  color: var(--muted, #888);
}
.conn-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.conn-status-ok {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--green, #22c55e);
}
.conn-status-off {
  font-size: 0.75rem;
  color: var(--muted, #888);
}
.btn-conn-action {
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border, #2a2a2a);
  background: transparent;
  color: var(--fg, #e8e8e8);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.btn-conn-action:hover:not([disabled]) {
  background: var(--surface-3, #252525);
  border-color: var(--muted, #888);
}
.btn-conn-action[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-conn-connect {
  border-color: var(--accent, #4f8ef7);
  color: var(--accent, #4f8ef7);
}
.btn-conn-connect:hover {
  background: rgba(79,142,247,.08) !important;
}
.btn-conn-disconnect {
  border-color: #f87171;
  color: #f87171;
}
.btn-conn-disconnect:hover {
  background: rgba(248,113,113,.08) !important;
}
/* Account drawer: scroll main content; keep Sign out pinned at bottom */
.account-settings-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.account-settings-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.account-settings-scroll::-webkit-scrollbar {
  width: 6px;
}
.account-settings-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.connections-footer {
  flex-shrink: 0;
  margin-top: 0;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--border, #2a2a2a);
  background: var(--surface);
}
.btn-signout {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted, #888);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border, #2a2a2a);
  display: inline-block;
  background: var(--surface-2, #1c1c1c);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-signout:hover {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(248, 113, 113, 0.06);
}

/* ── Account drawer: section headers ────────────────────────────────────── */
.account-section {
  margin-top: 20px;
}
.account-section-header {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #888);
  margin-bottom: 10px;
}

/* ── GWS connection card ────────────────────────────────────────────────── */
.gws-conn-card {
  background: var(--surface-2, #1c1c1c);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gws-conn-status {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gws-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.gws-status-unknown { background: var(--muted, #888); }
.gws-status-ok      { background: var(--green, #22c55e); box-shadow: 0 0 6px rgba(34,197,94,.5); }
.gws-status-off     { background: #f87171; }
.gws-status-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg, #e8e8e8);
}
.gws-status-email {
  font-size: 0.78rem;
  color: var(--muted, #888);
}
.gws-conn-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ── Zoho CRM (account drawer) ───────────────────────────────────────────── */
.zoho-conn-card .zoho-conn-hint {
  margin: 4px 0 0;
  line-height: 1.55;
}
.zoho-conn-card .zoho-conn-hint code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface3);
  color: var(--text-muted);
}
.zoho-cred-panel {
  margin-top: 12px;
  padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.zoho-cred-panel-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.zoho-conn-card .field-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.zoho-conn-card .field-row .field-hint {
  margin-top: 2px;
}
.zoho-conn-card .field-row .field-hint code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--surface3);
  color: var(--text-dim);
}
.zoho-conn-card .zoho-field-input,
.zoho-conn-card input.zoho-field-input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.4;
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}
.zoho-conn-card .zoho-field-input:hover:not(:disabled) {
  border-color: var(--border2);
}
.zoho-conn-card .zoho-field-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.zoho-conn-card .zoho-field-input::placeholder {
  color: var(--text-dim);
}
.zoho-conn-card .zoho-field-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--surface2);
}
.zoho-conn-card input.zoho-field-input:-webkit-autofill,
.zoho-conn-card input.zoho-field-input:-webkit-autofill:hover,
.zoho-conn-card input.zoho-field-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  box-shadow: 0 0 0 1000px var(--surface) inset;
  border: 1px solid var(--border);
  transition: background-color 9999s ease-out 0s;
}
.zoho-conn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.zoho-mcp-url-hint {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.45;
  word-break: break-all;
}

/* ── Workspace services panel (account drawer) ───────────────────────────── */
.workspace-services-panel {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.workspace-bulk-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border, #2a2a2a);
}
.workspace-select-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg, #e8e8e8);
  cursor: pointer;
  user-select: none;
}
.workspace-select-all input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #4f8ef7);
  cursor: pointer;
}
.workspace-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn-workspace {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  line-height: 1.2;
}
.btn-workspace:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-workspace-primary {
  background: var(--accent, #4f8ef7);
  color: #fff;
  border-color: var(--accent, #4f8ef7);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.btn-workspace-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}
.btn-workspace-secondary {
  background: transparent;
  color: var(--accent, #4f8ef7);
  border-color: var(--accent, #4f8ef7);
}
.btn-workspace-secondary:hover:not(:disabled) {
  background: rgba(79, 142, 247, 0.12);
}
.btn-workspace-muted {
  background: var(--surface-3, #252525);
  color: var(--fg, #e8e8e8);
  border-color: var(--border, #2a2a2a);
}
.btn-workspace-muted:hover:not(:disabled) {
  border-color: var(--muted, #888);
}
.btn-workspace-danger {
  background: transparent;
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.45);
}
.btn-workspace-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.1);
  border-color: #f87171;
}
.workspace-service-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.workspace-svc-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 14px;
  background: var(--surface-3, #252525);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 8px;
  transition: border-color 0.15s, background 0.15s;
}
.workspace-svc-row.is-connected {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.04);
}
.workspace-svc-check {
  display: flex;
  align-items: center;
  cursor: pointer;
}
.workspace-svc-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #4f8ef7);
  cursor: pointer;
}
.workspace-svc-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.workspace-svc-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg, #e8e8e8);
}
.workspace-svc-pill {
  display: inline-block;
  width: fit-content;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.workspace-svc-pill-ok {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}
.workspace-svc-pill-warn {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
}
.workspace-svc-pill-off {
  background: rgba(136, 136, 136, 0.15);
  color: var(--muted, #888);
}
.workspace-svc-actions {
  flex-shrink: 0;
}
.workspace-svc-actions .btn-conn-action {
  min-width: 88px;
  justify-content: center;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
}
.btn-gws-reauth {
  font-size: 0.78rem;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid var(--accent, #4f8ef7);
  background: transparent;
  color: var(--accent, #4f8ef7);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-gws-reauth:hover:not([disabled]) {
  background: rgba(79,142,247,.1);
}
.btn-gws-reauth[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.gws-reauth-msg {
  font-size: 0.75rem;
  color: var(--muted, #888);
  flex: 1;
}
.gws-reauth-msg a {
  color: var(--accent, #4f8ef7);
  text-decoration: underline;
}

/* ── Tool status grid ──────────────────────────────────────────────────── */
.tool-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}
.tool-status-item {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-2, #1c1c1c);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 6px;
  padding: 8px 10px;
}
.tool-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted, #555);
}
.tool-dot-ok  { background: var(--green, #22c55e); }
.tool-dot-warn { background: #eab308; }
.tool-dot-off { background: var(--muted, #555); }
.tool-status-name {
  font-size: 0.8rem;
  color: var(--fg, #e8e8e8);
}

/* ── Multi-skill manager ────────────────────────────────────────────────── */
.skills-layout {
  display: flex;
  gap: 12px;
  height: 420px;
  overflow: hidden;
}
.skills-sidebar {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 8px;
  overflow: hidden;
}
.skills-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface-2, #1c1c1c);
  border-bottom: 1px solid var(--border, #2a2a2a);
}
.skills-sidebar-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted, #888);
}
.btn-icon-sm {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid var(--border, #2a2a2a);
  background: transparent;
  color: var(--fg, #e8e8e8);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.btn-icon-sm:hover { background: var(--surface-3, #252525); }
.skills-list {
  list-style: none;
  padding: 6px 4px;
  margin: 0;
  flex: 1;
  overflow-y: auto;
}
.skills-list-empty {
  font-size: 0.75rem;
  color: var(--muted, #888);
  padding: 8px;
  text-align: center;
}
.skills-list-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--fg, #e8e8e8);
  transition: background 0.12s;
  overflow: hidden;
}
.skills-list-item:hover { background: var(--surface-3, #252525); }
.skills-list-item.active {
  background: var(--surface-3, #252525);
  color: var(--accent, #4f8ef7);
}
.skill-icon { flex-shrink: 0; font-size: 0.85rem; }
.skill-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.skills-editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.skills-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted, #888);
  font-size: 0.85rem;
  text-align: center;
  border: 1px dashed var(--border, #2a2a2a);
  border-radius: 8px;
  padding: 20px;
}
.skills-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.skill-editing-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted, #888);
  font-family: monospace;
}
.btn-danger-sm {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 5px;
  border: 1px solid #f87171;
  background: transparent;
  color: #f87171;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger-sm:hover { background: rgba(248,113,113,.1); }
#stab-skill textarea#skill-editor {
  flex: 1;
  resize: none;
  min-height: 0;
}

/* ── Workspace role badge + readonly banner ─────────────────────────────── */
.role-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 10px;
  vertical-align: middle;
}
.role-owner   { background: rgba(34,197,94,.15);  color: #22c55e; border: 1px solid rgba(34,197,94,.3); }
.role-manager { background: rgba(79,142,247,.15); color: #4f8ef7; border: 1px solid rgba(79,142,247,.3); }
.role-member  { background: rgba(156,163,175,.1); color: #9ca3af; border: 1px solid rgba(156,163,175,.3); }

.settings-readonly-banner {
  background: rgba(248,113,113,.08);
  border: 1px solid rgba(248,113,113,.25);
  color: #f87171;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.8rem;
  margin-bottom: 16px;
  line-height: 1.5;
}
