#team-conversation-status, #team-speaker-indicator, #team-status-bar { display: none !important; }
* { margin: 0; padding: 0; box-sizing: border-box; }
/* Dark scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #161b22; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3d4451; }
* { scrollbar-width: thin; scrollbar-color: #30363d #161b22; }
:root {
  --bg: #0d1117; --surface: #161b22; --border: #30363d;
  --text: #e6edf3; --text-dim: #8b949e; --accent: #58a6ff;
  --accent-dim: #1f6feb; --danger: #f85149; --success: #3fb950;
  --rail-width: 52px;
  --panel-map-width: 50vw;
  --panel-default-width: 396px;
  --rail-bg: #1a1a1a;
  --panel-bg: #141414;
  --node-active: #00d4aa;
  --node-idle: #555;
  --node-user: #f5c542;
  --status-pending: #888;
  --status-in-progress: #f5a623;
  --status-completed: #00d4aa;
}
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }

/* ── Login ── */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100%; padding: 20px;
}
#login-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px; width: 100%; max-width: 360px; text-align: center;
}
#login-box h1 { font-size: 24px; margin-bottom: 24px; }
#login-box input {
  width: 100%; padding: 12px 16px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 16px; margin-bottom: 16px; outline: none;
}
#login-box input:focus { border-color: var(--accent); }
#login-box button {
  width: 100%; padding: 12px; background: var(--accent-dim); color: white;
  border: none; border-radius: 8px; font-size: 16px; cursor: pointer;
}
#login-box button:active { opacity: 0.8; }
#login-error { color: var(--danger); font-size: 14px; margin-top: 8px; display: none; }

/* ── Chat ── */
#chat-screen { display: none; height: 100vh; height: 100dvh; flex-direction: column; }

/* ── Left sidebar rail ── */
#left-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 52px; z-index: 50;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width 200ms ease;
  overflow: hidden;
}
#left-sidebar.expanded { width: 256px; }

/* Inner content always laid out at full width; clipped by overflow:hidden on container */
#sidebar-inner {
  min-width: 232px; width: 232px;
  display: flex; flex-direction: column;
  height: 100%;
  padding: 0 12px;
}
#left-sidebar.expanded #sidebar-inner {
  width: 100%;
  min-width: unset;
}

/* Sidebar header: logo left, toggle right */
#left-sidebar .sidebar-top {
  display: flex; flex-direction: row; align-items: center; justify-content: space-between;
  padding: 0 44px 0 0; flex-shrink: 0; height: 50px;
}
#left-sidebar .sidebar-logo {
  display: flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 18px; color: var(--text);
  white-space: nowrap; padding-left: 2px;
}
.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
#conversation-search-trigger {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
#conversation-search-trigger:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
}
/* Hide logo when collapsed; toggle button is position:absolute so unaffected */
#left-sidebar:not(.expanded) .sidebar-logo { display: none; }
#left-sidebar:not(.expanded) .sidebar-top { height: 0; padding: 0; }

#sidebar-toggle-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 6px; flex-shrink: 0;
  position: absolute; top: 7px; left: 8px; z-index: 2;
}
#left-sidebar.expanded #sidebar-toggle-btn {
  left: auto; right: 10px;
}
#sidebar-toggle-btn:hover { background: rgba(255,255,255,0.12); color: var(--text); }

/* Status dot next to logo text */
#sidebar-status-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--success);
  flex-shrink: 0;
}
#sidebar-status-dot.disconnected { background: var(--danger); }
#sidebar-status-dot.working { background: var(--accent); animation: pulse 1s infinite; }
#sidebar-status-dot.busy { background: #f0883e; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Dead session indicator in sidebar */
.session-dead-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); flex-shrink: 0; margin-left: 6px;
}

/* Session status dot in sidebar (idle=green, working/thinking=blue, compacting=orange) */
.session-status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; margin-left: 6px; vertical-align: middle;
}
.session-status-dot.idle { background: #4CAF50; }
.session-status-dot.working,
.session-status-dot.thinking { background: #6699aa; animation: session-dot-pulse 1.2s ease-in-out infinite; }
.session-status-dot.compacting { background: #FFA500; animation: session-dot-pulse 1.2s ease-in-out infinite; }
@keyframes session-dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@media (max-width: 768px) {
  .session-status-dot { display: none; }
}

/* Restart overlay on input area */
#restart-overlay {
  display: none; position: absolute; inset: 0; z-index: 50;
  background: rgba(13, 17, 23, 0.85);
  border-radius: 8px;
  align-items: center; justify-content: center;
}
#restart-overlay.visible { display: flex; }
#restart-overlay button {
  position: relative; z-index: 51;
  padding: 12px 32px; background: var(--accent); color: white;
  border: none; border-radius: 8px; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: background 150ms;
  box-shadow: 0 2px 12px rgba(88, 166, 255, 0.4);
}
#restart-overlay button:hover { background: #79bbff; }
#restart-overlay button:disabled { opacity: 0.5; cursor: default; }

/* (Old #btn-new-session removed - replaced by per-section .sidebar-section-new buttons) */

/* Sidebar expanded content (session info, actions, list) */
#sidebar-expanded-content {
  display: flex; flex-direction: column; flex: 1; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none;
  padding: 0; min-width: 232px; margin-top: 8px;
}
/* Hide scrollbar visually while keeping scrolling functional */
#sidebar-expanded-content::-webkit-scrollbar { width: 0; display: none; }
#sidebar-expanded-content::-webkit-scrollbar-track { background: transparent; }
#sidebar-expanded-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
#sidebar-expanded-content::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
/* Hide expanded content text when collapsed, but keep layout */
#left-sidebar:not(.expanded) #sidebar-expanded-content {
  visibility: hidden;
}


/* Session list in the sidebar */
#sidebar-session-list {
  flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0; padding: 0;
}
/* Hide scrollbar visually while keeping scrolling functional */
#sidebar-session-list::-webkit-scrollbar { width: 0; display: none; }
#sidebar-session-list::-webkit-scrollbar-track { background: transparent; }
#sidebar-session-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
#sidebar-session-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* Main content offset for sidebar rail */
#app-container {
  margin-left: 52px;
  transition: margin-left 200ms ease;
}
#app-container.sidebar-expanded { margin-left: 256px; }

/* ── Mobile burger button ── */
#mobile-burger {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 1000;
  width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); cursor: pointer;
  align-items: center; justify-content: center;
}
#mobile-burger:active { opacity: 0.7; }

/* Mobile sidebar backdrop */
#mobile-sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 999;
}
#mobile-sidebar-backdrop.visible { display: block; }

/* Mobile behavior */
@media (max-width: 768px) {
  #left-sidebar {
    display: none; width: 280px; z-index: 1000;
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }
  #left-sidebar.mobile-open {
    display: flex; transform: translateX(0);
  }
  /* Always show expanded content on mobile */
  #left-sidebar.mobile-open #sidebar-expanded-content { visibility: visible !important; }
  #left-sidebar.mobile-open #sidebar-toggle-btn {
    left: auto;
    right: 10px;
  }
  #left-sidebar.mobile-open .sidebar-top {
    height: 50px;
    padding: 0 44px 0 0;
  }
  #left-sidebar.mobile-open .sidebar-logo {
    display: flex;
  }
  #left-sidebar.mobile-open #sidebar-inner {
    width: 100%;
    min-width: unset;
  }
  /* (Old mobile #btn-new-session styles removed) */

  #mobile-burger { display: flex; }
  #app-container { margin-left: 0 !important; }
  /* Add top padding so burger doesn't overlap content */
  #chat-screen #messages { padding-top: 56px; }
}

/* Messages */
#messages {
  padding: 16px;
  max-width: 900px; margin-left: auto; margin-right: auto; width: 100%;
}
#conversation-search-state {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 16px 24px;
  box-sizing: border-box;
  min-height: 100%;
}
.conversation-search-hero {
  padding: 8px 2px 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.conversation-search-hero h1 {
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  max-width: none;
  margin-bottom: 0;
  font-weight: 600;
}
#conversation-search-results {
  margin-top: 0;
  display: grid;
  gap: 0;
}
.conversation-search-message {
  padding: 8px 2px 14px;
  color: var(--text-dim);
  font-size: 13px;
}
.conversation-search-results-count {
  color: rgba(255,255,255,0.42);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-top: 10px;
  padding-bottom: 8px;
}
.conversation-search-result {
  width: 100%;
  text-align: left;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}
.conversation-search-result:hover {
  background: rgba(255,255,255,0.03);
}
.conversation-search-result-main {
  flex: 1;
  min-width: 0;
}
.conversation-search-result-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conversation-search-result-side {
  flex: 0 0 150px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
}
.conversation-search-result-date {
  color: rgba(255,255,255,0.38);
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
}
.conversation-search-result-meta {
  color: rgba(255,255,255,0.32);
  font-size: 0.68rem;
  line-height: 1.4;
  margin-top: 2px;
  white-space: nowrap;
  text-align: right;
}
.conversation-search-result-snippet {
  color: rgba(230,237,243,0.72);
  font-size: 12px;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.conversation-search-result-snippet mark {
  background: rgba(255,255,255,0.12);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}
.conversation-search-result-empty {
  opacity: 0.72;
}
#conversation-search-bar-shell {
  width: 100%;
  max-width: 900px;
  margin: 0 auto 12px;
  padding: 0 16px;
}
#conversation-search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
#conversation-search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  padding: 4px 6px;
}
#conversation-search-input::placeholder {
  color: rgba(255,255,255,0.38);
}
#conversation-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  cursor: pointer;
  opacity: 0.7;
  background: center / 14px 14px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.25 4.25l7.5 7.5M11.75 4.25l-7.5 7.5' stroke='rgba(255,255,255,0.45)' stroke-width='1.75' stroke-linecap='round'/%3E%3C/svg%3E");
}
#conversation-search-input::-webkit-search-cancel-button:hover {
  opacity: 1;
}
#conversation-search-submit {
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
#conversation-search-submit:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
}
#conversation-search-submit:disabled {
  opacity: 0.55;
  cursor: wait;
}
#conversation-search-feedback {
  min-height: 18px;
  padding: 8px 4px 0;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}
#input-area.search-mode #input-top-bar,
#input-area.search-mode #image-preview,
#input-area.search-mode #slash-command-menu,
#input-area.search-mode #mention-menu,
#input-area.search-mode #input-container {
  display: none !important;
}
#messages-scroll-wrapper.search-mode #messages {
  display: none;
}
#messages-scroll-wrapper.search-mode {
  scroll-behavior: smooth;
}
@media (max-width: 768px) {
  #conversation-search-state {
    padding-top: 72px;
  }
  .conversation-search-hero {
    padding: 6px 0 12px;
  }
  .conversation-search-hero h1 {
    font-size: 22px;
  }
  .conversation-search-result {
    gap: 10px;
    padding: 6px 0;
  }
  .conversation-search-result-side {
    flex-basis: 118px;
  }
  #conversation-search-bar-shell {
    padding: 0 12px;
  }
  #conversation-search-form {
    flex-direction: column;
    align-items: stretch;
  }
  #conversation-search-submit {
    width: 100%;
  }
}
.msg {
  max-width: 100%; margin-bottom: 24px; line-height: 1.35; font-size: 15px;
  word-wrap: break-word; overflow-wrap: break-word;
}
.msg.user {
  background: var(--accent-dim); color: white; padding: 10px 14px;
  border-radius: 12px 12px 4px 12px; margin-left: 40px;
  white-space: pre-wrap;
}
.msg.assistant {
  background: transparent; padding: 12px 16px;
  border-radius: 12px 12px 12px 4px; border: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}
.msg.assistant pre {
  background: var(--bg); padding: 10px; border-radius: 6px;
  overflow-x: auto; margin: 8px 0; font-size: 13px;
  white-space: pre-wrap; word-break: break-word;
}
.msg.assistant code {
  background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 13px;
}
.msg.assistant pre code { background: none; padding: 0; }
.code-block {
  position: relative;
  margin: 16px 0 24px 0;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;
}

.code-block-lang {
  position: absolute;
  top: 12px;
  left: 14px;
  font-size: 11px;
  font-family: monospace;
  color: rgba(255,255,255,0.35);
  text-transform: lowercase;
  pointer-events: none;
  z-index: 1;
  line-height: 1;
}

.code-block-copy {
  position: absolute;
  top: 7px;
  right: 8px;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 4px;
  padding: 5px;
  cursor: pointer;
  color: rgba(255,255,255,0.55);
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.code-block:hover .code-block-copy {
  opacity: 1;
}

.code-block-copy:hover {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
}

.msg .code-block pre {
  margin: 0;
  border-radius: 0;
  padding: 36px 14px 14px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  background: transparent;
}
.msg.assistant p { margin: 6px 0; }
.msg.assistant ul, .msg.assistant ol { margin: 6px 0; padding-left: 20px; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3 {
  margin: 12px 0 6px; font-size: 16px;
}
.msg.assistant strong { color: var(--accent); }
.msg.system {
  text-align: center; color: var(--text-dim); font-size: 13px;
  padding: 4px; font-style: italic;
}
.load-more-btn {
  display: block; margin: 8px auto; padding: 6px 18px;
  background: rgba(255,255,255,0.06); color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 4px;
  font-size: 13px; cursor: pointer; font-style: italic;
  transition: background 0.15s;
}
.load-more-btn:hover { background: rgba(255,255,255,0.12); }
.msg .images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg .images img {
  max-width: 200px; max-height: 150px; border-radius: 8px; cursor: pointer;
}
.msg .images img.broken-img { display: none; }
/* Tool icons - compact clickable row (v3 2026-03-01) */
.tool-icons {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin: 2px 0 8px;
  align-items: center;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 1px 0 3px;
  scrollbar-width: none;
}
.tool-icons::-webkit-scrollbar { display: none; }
.tool-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; cursor: pointer; opacity: 0.78;
  transition: opacity 0.15s ease, filter 0.15s ease, transform 0.15s ease; flex-shrink: 0;
}
.tool-icon:hover { opacity: 1; }
.tool-icon.active {
  opacity: 0.88;
  filter: drop-shadow(0 0 2px rgba(88, 166, 255, 0.18));
}
.tool-icon.running {
  opacity: 0.82;
}
.tool-icon.current-step {
  opacity: 1;
  color: #faf9f5;
  filter: drop-shadow(0 0 5px rgba(88, 166, 255, 0.42)) brightness(1.18);
  transform: translateY(-1px);
}
.tool-icon.active.current-step {
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(88, 166, 255, 0.48)) brightness(1.2);
}
.tool-icon svg { width: 16px; height: 16px; color: var(--accent); }

.tool-detail {
  background: #0d1117; border: 1px solid var(--border); border-radius: 6px;
  display: block;
  font-family: inherit;
  font-size: 13px; color: var(--text-dim); max-height: 200px; overflow-y: auto;
  padding: 10px 12px; margin-top: 10px; margin-bottom: 14px; line-height: 1.5; white-space: pre-wrap;
  width: min(780px, calc(100% - 4px));
  max-width: 100%;
  clear: both;
  flex: 0 0 auto;
  align-self: stretch;
  word-break: break-word;
}
.tool-detail .detail-label {
  color: var(--accent); font-weight: 600; margin-bottom: 2px; display: block;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
}
.tool-detail .detail-section { margin-bottom: 6px; }
.tool-detail .detail-section:last-child { margin-bottom: 0; }

/* Tool-only messages: strip bubble styling, just show icon row */
.msg.assistant.tool-only {
  background: none;
  border: none;
  padding: 8px 0 12px 16px;
  margin: 6px 0 18px;
  max-width: none;
}
.msg.assistant.tool-only .tool-icons {
  margin: 0 0 8px;
}
.msg.assistant.tool-only .tool-detail {
  margin-top: 12px;
  margin-bottom: 18px;
  max-width: min(780px, calc(100vw - 64px));
}
.agent-message-text {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.agent-message-text a {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.agent-message-text .local-file-link {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  text-decoration: none;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  padding: 0 4px;
}
/* Input area - VS Code inspired two-row container */
#input-area {
  flex-shrink: 0;
  max-width: 900px; margin-left: auto; margin-right: auto; width: 100%;
  padding: 0 16px 12px;
  position: relative;
}
@media (max-width: 768px) {
  #messages, #input-area { max-width: 100%; }
}

/* Message preview strip - quote-box style, sits in input-top-bar next to status */
#msg-preview {
  display: none;
  max-width: 66%;
  box-sizing: border-box;
  margin-left: auto;
}
#msg-preview-inner {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  color: white;
  font-size: 12px;
  line-height: 1.4;
  font-style: italic;
  opacity: 0.85;
  border-left: 3px solid rgba(255,255,255,0.4);
  background: var(--accent-dim, #1f6feb);
  padding: 4px 8px;
  border-radius: 0 4px 4px 0;
  text-align: right;
}

/* Top bar - wraps activity/status (left) and preview/queued indicators (right) */
#input-top-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  margin-bottom: 6px;
  gap: 4px 8px;
}
#msg-queued {
  display: none;
  width: 100%;
  text-align: center;
  padding: 4px 0;
  font-size: 12px;
  font-style: italic;
  color: var(--text-dim, #888);
  transition: opacity 0.5s;
  order: 10; /* push to its own row via flex-wrap */
}

/* Activity bar - left side of input-top-bar, only visible when working */
#status-bar {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #e8a040;
  white-space: nowrap;
}
#status-spinner {
  animation: spin 1s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
#status-timer { color: #888; margin-left: auto; }

/* Image preview row - above the container, only visible when images attached */
#image-preview {
  display: none; flex-wrap: wrap; gap: 8px; margin-bottom: 6px;
}
#image-preview .preview-item {
  position: relative; display: inline-block;
}
#image-preview img {
  max-height: 60px; border-radius: 6px; border: 1px solid var(--border);
}
#image-preview .remove-img {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  background: var(--danger); color: white; border: none; border-radius: 50%;
  font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* Slash command menu (styles injected by slash-commands.js) */

/* @ mention autocomplete dropdown */
#mention-menu {
  position: absolute;
  bottom: 100%;
  left: 16px;
  right: 16px;
  margin-bottom: 4px;
  background: #1a1a2e;
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
#mention-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
#mention-menu .mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.1s ease;
}
#mention-menu .mention-item:hover,
#mention-menu .mention-item.active {
  background: rgba(255,255,255,0.08);
}
#mention-menu .mention-item .mention-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
#mention-menu .mention-item .mention-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
#mention-menu .mention-item .mention-role {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
}
#mention-menu .mention-empty {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}
#mention-menu .mention-hidden { display: none; }

/* The bordered container (two rows) */
#input-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

/* Row 1: textarea */
#msg-input {
  width: 100%; padding: 10px 14px; background: transparent; border: none;
  color: var(--text); font-size: 16px; font-family: inherit;
  resize: none; min-height: 44px; max-height: 120px; outline: none; line-height: 1.4;
  display: block;
}

/* Row 2: toolbar */
#input-toolbar {
  display: flex;
  align-items: center;
  padding: 4px 8px 6px;
  gap: 4px;
}
#input-toolbar-left {
  display: flex;
  align-items: center;
  gap: 2px;
}
#input-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  margin-left: auto;
}

/* Toolbar icon buttons (slash, attach) */
.toolbar-btn {
  width: 28px; height: 28px; background: none; border: none;
  color: var(--text-dim); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.toolbar-btn:hover { color: var(--text); background: rgba(255,255,255,0.08); }

/* Send/Stop button in toolbar */
#btn-send {
  width: 28px; height: 28px; background: var(--accent-dim); border: none;
  border-radius: 6px; color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background 0.3s ease;
}
#btn-send:disabled { opacity: 0.4; cursor: not-allowed; }
/* Stop button - sits side-by-side with send button in toolbar flex layout */
#btn-stop {
  width: 28px; height: 28px; background: #ff6b6b; border: none;
  border-radius: 6px; color: white; cursor: pointer;
  display: none; align-items: center; justify-content: center; flex-shrink: 0;
  padding: 0;
  transition: background 0.3s ease;
}
#btn-stop:hover { background: #ff4444; }
#file-input { display: none; }

/* Compaction indicator - inline circle in toolbar */
#compaction-indicator {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}
@keyframes compaction-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
#compaction-indicator.pulsing {
  animation: compaction-pulse 1.5s ease-in-out infinite;
}
#compaction-text {
  font-style: italic;
  font-size: 11px;
  color: var(--text-dim);
  display: none;
  margin-left: 2px;
}

/* Model label (display only, change via Settings) */
#model-label {
  color: var(--text-dim);
  font-size: 11px;
  margin-left: 8px;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

/* Effort level pill */
#effort-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  cursor: default;
  user-select: none;
  vertical-align: middle;
  line-height: 16px;
}
#effort-pill[data-level="low"] { background: rgba(139,148,158,0.2); color: #8b949e; }
#effort-pill[data-level="medium"] { background: rgba(88,166,255,0.15); color: #58a6ff; }
#effort-pill[data-level="high"] { background: rgba(63,185,80,0.15); color: #3fb950; }
#effort-pill[data-level="max"] { background: rgba(210,153,34,0.15); color: #d29922; }

/* ── Message status line (under user messages) ── */
.msg-wrapper {
  display: flex; flex-direction: column; align-items: flex-end;
  margin-bottom: 16px; margin-left: 40px;
}
.msg-wrapper .msg.user {
  margin-bottom: 0; margin-left: 0; width: 100%;
}
.msg-status {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; min-height: 20px; padding: 2px 0;
  font-size: 12px; color: #9f9fa9; width: 100%;
  opacity: 0; transition: opacity 0.15s;
}
.msg-wrapper:hover .msg-status { opacity: 1; }
.msg-status.failed { color: #ef4444; }
.msg-status .copy-icon {
  background: none; border: none; cursor: pointer;
  color: #9f9fa9; padding: 0; display: flex; align-items: center;
  opacity: 0.4; transition: color 0.15s, opacity 0.15s;
}
.msg-status .copy-icon:hover { color: #faf9f5; opacity: 1; }
.msg-status .copy-icon.copied { color: var(--success); opacity: 1; }
.msg-status .status-text { opacity: 0.5; transition: opacity 0.15s; }
.msg-status .status-text:hover { opacity: 1; }

/* ── Copy button under AI messages ── */
.ai-msg-footer {
  display: flex; align-items: center; gap: 8px;
  min-height: 20px; padding: 2px 0 2px 16px; margin-bottom: 16px;
  font-size: 12px; color: #9f9fa9;
  opacity: 0; transition: opacity 0.15s;
}
.msg.assistant:hover + .ai-msg-footer,
.ai-msg-footer:hover { opacity: 1; }
.ai-msg-footer .copy-icon,
.ai-msg-footer .voice-read-btn {
  background: none; border: none; cursor: pointer;
  color: #9f9fa9; padding: 0; display: flex; align-items: center;
  opacity: 0.4; transition: color 0.15s, opacity 0.15s;
}
.ai-msg-footer .copy-icon:hover,
.ai-msg-footer .voice-read-btn:hover { color: #faf9f5; opacity: 1; }
.ai-msg-footer .copy-icon.copied { color: var(--success); opacity: 1; }
.ai-msg-footer .status-text { opacity: 0.5; transition: opacity 0.15s; }
.ai-msg-footer .status-text:hover { opacity: 1; }

/* (Old hamburger, sidebar backdrop, history-sidebar CSS removed - replaced by #left-sidebar) */

/* ── Archive button (above Owner card in sidebar) ── */
#archive-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px;
  background: none; border: none; border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px;
  cursor: pointer; transition: background 0.15s;
  flex-shrink: 0;
}
#archive-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
#archive-btn svg { flex-shrink: 0; opacity: 0.6; }
#archive-btn:hover svg { opacity: 1; }
.archive-label { flex: 1; text-align: left; }
.archive-count {
  background: rgba(255,255,255,0.1); color: var(--text-dim);
  font-size: 11px; font-weight: 600; padding: 1px 7px;
  border-radius: 10px; min-width: 20px; text-align: center;
}
/* Hide label when sidebar is collapsed */
#left-sidebar:not(.expanded) .archive-label { display: none; }
#left-sidebar:not(.expanded) .archive-count { display: none; }
#left-sidebar:not(.expanded) #archive-btn { justify-content: center; padding: 8px 0; }

/* ── Archived Agents Modal ── */
#archived-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 10000;
  align-items: center; justify-content: center;
}
#archived-modal-overlay.visible { display: flex; }
#archived-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; width: 90%; max-width: 420px;
  max-height: 70vh; max-height: 70dvh; display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
#archived-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#archived-modal-header h3 {
  margin: 0; font-size: 16px; font-weight: 600; color: var(--text);
}
.archived-modal-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 22px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.archived-modal-close:hover { color: var(--text); }
#archived-list {
  overflow-y: auto; padding: 8px 12px; flex: 1;
}
.archived-empty {
  padding: 24px; text-align: center; color: var(--text-dim); font-size: 14px;
}
.archived-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.archived-item:last-child { border-bottom: none; }
.archived-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: #fff;
  overflow: hidden;
}
.archived-avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.archived-info {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.archived-name {
  font-size: 14px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.archived-role {
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.archived-unretire-btn {
  background: rgba(255,255,255,0.08); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; padding: 5px 12px;
  border-radius: 6px; cursor: pointer; white-space: nowrap;
  transition: background 0.15s;
}
.archived-unretire-btn:hover {
  background: rgba(59,130,246,0.2); border-color: rgba(59,130,246,0.4);
  color: #58a6ff;
}

/* Session list sections */
#sidebar-session-list { padding: 0; }
.sidebar-section { margin-bottom: 4px; }
.sidebar-section-header {
  display: flex; align-items: center;
  padding: 6px 12px 6px 16px; font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(255,255,255,0.35); user-select: none;
}
.section-header-main {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 6px;
  cursor: pointer;
}
.section-header-meta {
  display: flex;
  align-items: center;
  gap: 4px;
}
.section-header-action {
  width: 36px;
  margin-left: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-section-entries { }
.sidebar-section-tmux .sidebar-section-new {
  background: rgba(74, 222, 128, 0.20);
  color: rgba(74, 222, 128, 0.9);
}
.sidebar-section-tmux .sidebar-section-new:hover {
  background: rgba(74, 222, 128, 0.30);
}
.sidebar-section-chat .sidebar-section-new {
  background: rgba(59, 130, 246, 0.20);
  color: rgba(59, 130, 246, 0.9);
}
.sidebar-section-chat .sidebar-section-new:hover {
  background: rgba(59, 130, 246, 0.30);
}
.sidebar-section-tmux .session-entry:hover {
  background: rgba(74, 222, 128, 0.10);
}
.sidebar-section-tmux .session-entry.active {
  background: rgba(74, 222, 128, 0.15);
  border-left-color: rgb(74, 222, 128);
}
.sidebar-section-chat .session-entry:hover {
  background: rgba(59, 130, 246, 0.10);
}
.sidebar-section-chat .session-entry.active {
  background: rgba(59, 130, 246, 0.15);
  border-left-color: rgb(59, 130, 246);
}

/* Session entries (unified card: LEFT info + RIGHT avatar with status border) */
.session-entry {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 16px; background: transparent;
  border: none; border-bottom: 1px solid rgba(255,255,255,0.06);
  border-left: 2px solid transparent;
  cursor: pointer; transition: background 0.15s;
  overflow: hidden;
}
.session-entry:hover { background: rgba(255,255,255,0.05); }
.session-entry:active { opacity: 0.8; }

/* LEFT side: info column (timestamp, name, role, message count) */
.session-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  order: 1;
}

/* Row 1: date/time */
.session-row-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 3px;
}
.session-entry .session-date {
  font-size: 0.7rem; color: rgba(255,255,255,0.35);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-entry .session-star-icon {
  color: #f5c542; font-size: 0.7rem; margin-right: 4px;
}

/* Row 2: session name */
.session-entry .session-name {
  font-size: 0.85rem; color: #fff; font-weight: 500; margin-bottom: 2px;
  padding: 0; border-radius: 3px;
  display: flex; align-items: center; gap: 5px; min-width: 0;
}
.session-entry .session-name .session-name-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.session-entry .session-name input {
  background: transparent; border: 1px solid rgba(59,130,246,0.5);
  color: inherit; font: inherit; width: 100%; border-radius: 3px;
  outline: none; padding: 0;
}
/* Per-contact agent count badge in sidebar */
.contact-agent-badge {
  flex-shrink: 0;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  background: var(--accent, #3b82f6);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  pointer-events: none;
}

/* Row 3: message count */
.session-entry .session-meta {
  font-size: 0.7rem; color: rgba(255,255,255,0.3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* RIGHT side: avatar with status border (placed after content via order) */
.session-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  overflow: visible;
  order: 2;
  position: relative;
  cursor: pointer;
  box-sizing: border-box;
  border: 2px solid transparent;
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}
.session-avatar .avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.session-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* Status border on avatar: replaces status dots */
/* status-idle: no visible border (dormant). Green border moved to status-dm-unread only. */
.session-avatar.status-idle {
  border: 2px solid transparent;
}
.session-avatar.status-working {
  border: 2px solid #58a6ff;
  animation: avatar-border-pulse 1.5s ease-in-out infinite;
}
.session-avatar.status-down {
  border: 2px solid #f85149;
  animation: avatar-border-pulse 1.5s ease-in-out infinite;
}
@keyframes avatar-border-pulse {
  0%, 100% { border-color: inherit; opacity: 1; }
  50% { opacity: 0.4; }
}
/* Fix: animate by class, inherit doesn't work in keyframe, use specific colors */
.session-avatar.status-working {
  animation: avatar-pulse-blue 1.5s ease-in-out infinite;
}
.session-avatar.status-down {
  animation: avatar-pulse-red 1.5s ease-in-out infinite;
}
@keyframes avatar-pulse-blue {
  0%, 100% { border-color: #58a6ff; }
  50% { border-color: rgba(88, 166, 255, 0.3); }
}
@keyframes avatar-pulse-red {
  0%, 100% { border-color: #f85149; }
  50% { border-color: rgba(248, 81, 73, 0.3); }
}

/* Status: spawning (process starting, no response yet) */
.session-avatar.status-spawning {
  border: 2px solid rgba(88, 166, 255, 0.4);
  animation: avatar-pulse-spawning 2.5s ease-in-out infinite;
}
@keyframes avatar-pulse-spawning {
  0%, 100% { border-color: rgba(88, 166, 255, 0.4); }
  50% { border-color: rgba(88, 166, 255, 0.1); }
}

/* Status: DM working (blue pulsing) */
.session-avatar.status-dm-working {
  border: 2px solid #58a6ff;
  animation: avatar-pulse-blue 1.5s ease-in-out infinite;
}
/* Status: DM unread (green solid) */
.session-avatar.status-dm-unread {
  border: 2px solid #3fb950;
}

/* Unread count badge on avatar */
.session-avatar .unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #6e7681;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  padding: 0 4px;
  z-index: 3;
  pointer-events: none;
}

/* Pencil edit overlay only on avatars that can actually open settings */
.session-avatar.settings-capable::after,
.session-avatar[data-agent-id]::after,
.contact-avatar::after {
  content: '✎';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 14px;
  line-height: 36px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 2;
  transform: scaleX(-1);
}
.session-avatar.settings-capable:hover::after,
.session-avatar[data-agent-id]:hover::after,
.contact-avatar:hover::after {
  opacity: 1;
}

/* Hide old "..." session menu button (replaced by avatar click for settings) */
.session-menu-btn {
  display: none;
}

/* Session dropdown menu */
.session-dropdown {
  position: absolute; top: 28px; right: 12px; z-index: 1100;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 0; min-width: 160px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  display: none;
}
.session-dropdown.open { display: block; }
.session-entry:has(.session-dropdown.open) { z-index: 100; }
.session-dropdown-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 14px; border: none; background: none;
  color: var(--text); font-size: 0.8rem; cursor: pointer;
  text-align: left; white-space: nowrap;
}
.session-dropdown-item:hover { background: rgba(255,255,255,0.06); }
.session-dropdown-item.danger { color: var(--danger); }
.session-dropdown-item.danger:hover { background: rgba(248,81,73,0.1); }

/* Transcript view (now rendered in main area, not sidebar) */
.history-loading {
  text-align: center; color: var(--text-dim); padding: 40px 16px; font-size: 14px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loading-spinner {
  width: 28px; height: 28px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto;
}


/* Active session highlight in sidebar */
.session-entry.active {
  border-left: 2px solid var(--accent, #3b82f6); background: rgba(255,255,255,0.08);
}

/* ── Image Lightbox ── */
#lightbox-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1100; background: rgba(0,0,0,0.85);
  align-items: center; justify-content: center; flex-direction: column;
}
#lightbox-overlay.visible { display: flex; }
#lightbox-overlay img {
  max-width: 90vw; max-height: 90vh; max-height: 90dvh; object-fit: contain; border-radius: 4px;
  user-select: none; -webkit-user-select: none;
}
#lightbox-close {
  position: absolute; top: 16px; right: 20px;
  width: 40px; height: 40px; border: none; background: none;
  color: white; font-size: 32px; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.8; transition: opacity 0.15s;
}
#lightbox-close:hover { opacity: 1; }
#lightbox-copy {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 10px 24px; background: var(--accent-dim); color: white;
  border: none; border-radius: 8px; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  opacity: 0.9; transition: opacity 0.15s, background 0.15s;
}
#lightbox-copy:hover { opacity: 1; }
#lightbox-copy.copied { background: var(--success); }

/* ── Text selection on messages ── */
.msg, .msg-text, .msg.assistant, .msg.user {
  -webkit-user-select: text; user-select: text;
}

/* Copy buttons now use .msg-status (user) and .ai-msg-footer (AI) — see above */

/* ── Lightbox download fallback button ── */
#lightbox-download {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 10px 24px; background: var(--accent-dim); color: white;
  border: none; border-radius: 8px; font-size: 14px; cursor: pointer;
  display: none; align-items: center; gap: 8px;
  opacity: 0.9; transition: opacity 0.15s;
  text-decoration: none;
}
#lightbox-download:hover { opacity: 1; }

/* Dashboard layout */
#app-container {
  display: flex;
  flex-direction: row;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#chat-screen {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 10;
}
#messages-scroll-wrapper {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

/* ── Floating task dashboard (vertically centered) ── */
#task-dash {
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  /* Center between collapsed sidebar (72px) and chat area.
     Chat is max-width 900px centered in remaining space.
     Remaining space starts at 72px, width = calc(100vw - 72px).
     Chat center = 72px + (100vw - 72px)/2 = (100vw + 72px)/2.
     Chat left edge = chat center - 450px.
     Dashboard sits in the gap between 72px and chat left edge.
     Dashboard center = 72px + (chat left edge - 72px)/2.
     Simplify: left = 72px + ((100vw + 72px)/2 - 450px - 72px)/2
              = 72px + ((100vw - 72px)/2 - 450px)/2
              = 72px + (100vw - 72px - 900px)/4
              = 72px + (100vw - 972px)/4
     Use calc for this: */
  left: calc(72px + (100vw - 972px) / 4);
  max-width: 280px;
  background: transparent;
  padding: 8px 0;
  z-index: 15;
  pointer-events: auto;
  font-size: 15px;
  display: none;
  transition: left 200ms ease;
}
/* Dashboard left position updated dynamically by toggleSidebar/initSidebar JS */
.dash-header {
  text-transform: none;
  font-size: 15px;
  letter-spacing: 0;
  cursor: pointer;
  padding: 6px 0;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dash-header[data-color="cyan"] { color: #4fc3f7; }
.dash-header[data-color="orange"] { color: #f5a623; }
.dash-header[data-color="white"] { color: rgba(255,255,255,0.7); }
.dash-header[data-color="gray"] { color: #666666; }
.dash-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.dash-section.expanded > .dash-items {
  max-height: 300px;
  overflow-y: auto;
}
.dash-section + .dash-section {
  border-top: 1px solid rgba(255,255,255,0.1);
}
.dash-items > div {
  font-size: 15px;
  padding: 2px 0 2px 8px;
  display: flex;
  align-items: center;
  min-width: 0;
}
.dash-items > div > .dash-item-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
@keyframes dash-slide-in {
  0% { opacity: 0; transform: translateX(-20px); background-color: rgba(255, 235, 59, 0.25); }
  30% { opacity: 1; transform: translateX(0); background-color: rgba(255, 235, 59, 0.25); }
  100% { opacity: 1; transform: translateX(0); background-color: transparent; }
}
.dash-items > div.dash-moved {
  animation: dash-slide-in 1s ease forwards;
}
.dash-items > div.dash-item-cyan { color: #4fc3f7; }
.dash-items > div.dash-item-orange { color: #f5a623; }
.dash-items > div.dash-item-white { color: rgba(255,255,255,0.7); }
.dash-items > div.dash-item-gray {
  color: #666666;
  text-decoration: line-through;
  opacity: 0.5;
}
.dash-item { position: relative; }
.agent-kill { opacity: 0; cursor: pointer; color: #ff6b6b; margin-left: 6px; font-size: 14px; transition: opacity 0.2s; flex-shrink: 0; }
.dash-items > div:hover .agent-kill { opacity: 0.6; }
.agent-kill:hover { opacity: 1 !important; }

#right-rail {
  width: var(--rail-width);
  min-width: var(--rail-width);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12px;
  padding-bottom: 4px;
  gap: 4px;
  border-left: 1px solid var(--border);
  z-index: 10;
  order: 2;
}

.rail-icon {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.rail-badge {
  position: absolute;
  right: 2px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  pointer-events: none;
}

.rail-badge-tmux {
  top: 2px;
  background: var(--success, #3fb950);
}

.rail-badge-server {
  bottom: 2px;
  background: #6e7681;
}

.rail-icon:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
}

.rail-icon.active {
  background: rgba(255,255,255,0.12);
  color: var(--accent);
}

.rail-spacer {
  flex: 1;
}

.rail-icon.restart-btn {
  color: var(--text-dim);
}
.rail-icon.restart-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--accent);
}
.rail-icon.restart-btn.restarting {
  opacity: 0.5;
  cursor: wait;
  pointer-events: none;
}
.rail-icon.restart-btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

#right-panel {
  --_panel-width: var(--panel-default-width);
  width: 0;
  overflow: hidden;
  transition: width 0.2s ease;
  order: 1;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

#right-panel.open {
  width: var(--_panel-width);
}

#right-panel.panel-map {
  --_panel-width: var(--panel-map-width);
}

#right-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
  min-width: var(--_panel-width);
}

#right-panel-header .panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

#right-panel-header .panel-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
}

#right-panel-header .panel-close:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text);
}

#right-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-width: var(--_panel-width);
}

.panel-section { display: none; }
.panel-section.active { display: block; }

/* Three.js map panel fills available space */
#panel-map.active {
  display: flex;
  flex-direction: column;
  height: 100%;
}
#panel-map.active #mind-map-container {
  flex: 1;
  min-height: 0;
}
#right-panel.panel-map #right-panel-content {
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Skills & Plugins inventory panels */
#right-panel.panel-capabilities { --_panel-width: var(--panel-map-width); }
#right-panel.panel-schedules { --_panel-width: var(--panel-default-width); }
#right-panel.panel-files { --_panel-width: var(--panel-map-width); }
#right-panel.panel-browser { --_panel-width: 50vw; }
#panel-browser.active {
  display: flex;
  flex-direction: column;
  height: 100%;
}
#right-panel.panel-browser #right-panel-content {
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}
#right-panel.panel-systemmap { --_panel-width: var(--panel-map-width); }
#right-panel.panel-systemmap #right-panel-content {
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}
#panel-systemmap.active {
  display: flex;
  flex-direction: column;
  height: 100%;
}
#panel-systemmap.active #system-map-container {
  flex: 1;
  min-height: 0;
}

/* File Explorer panel */
#panel-files.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
#right-panel.panel-files #right-panel-content {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
#file-explorer-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.fe-search-bar {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.fe-search-bar input {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.fe-search-bar input:focus {
  border-color: var(--accent);
}
.fe-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.fe-row {
  display: flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  gap: 4px;
  font-size: 13px;
  color: var(--text);
}
.fe-row:hover {
  background: rgba(255,255,255,0.06);
}
.fe-row.fe-active {
  background: rgba(88,166,255,0.12);
  color: var(--accent);
}
.fe-row.fe-hidden {
  display: none;
}
.fe-hidden {
  display: none !important;
}
.fe-indent {
  display: inline-block;
  width: 16px;
  flex-shrink: 0;
}
.fe-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  opacity: 0.75;
}
.fe-name {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.fe-search-name {
  font-size: 12px;
  direction: rtl;
  text-align: left;
}
.fe-size {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
  flex-shrink: 0;
  padding-left: 8px;
}
.fe-loading {
  padding: 8px 24px;
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}
.fe-empty {
  padding: 24px 16px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

/* ── File Explorer Split Layout ─────────────────────────────────────── */
.fe-split {
  display: flex;
  flex-direction: row;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.fe-tree-col {
  display: flex;
  flex-direction: column;
  width: var(--fe-tree-width, 220px);
  min-width: 150px;
  max-width: calc(100% - 200px);
  flex-shrink: 0;
  overflow: hidden;
  border-left: 1px solid var(--border);
}
.fe-divider {
  width: 4px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s;
  position: relative;
  z-index: 1;
}
.fe-divider:hover,
.fe-divider.fe-dragging {
  background: var(--accent);
}
.fe-preview-col {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.fe-preview {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  min-height: 0;
  position: relative;
}
.fe-preview-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
}
.fe-preview-content {
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  padding: 0 2rem;
}
.fe-preview-content.fe-preview-code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
}
.fe-preview-unavailable {
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}
/* ── File explorer preview header layout ─────────────────────────────── */
.fe-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.fe-header-path {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fe-edit-btn {
  flex-shrink: 0;
  padding: 2px 10px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.fe-edit-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}
.fe-edit-btn.fe-edit-btn-active {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── WYSIWYG toolbar (sits in fe-preview-col flow, above scroll area) ─ */
.fe-edit-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary, var(--bg));
  flex-shrink: 0;
}
/* Keep toolbar in flow (reserving space) even when hidden, to prevent layout shift */
.fe-edit-toolbar.fe-hidden {
  display: flex !important;
  visibility: hidden;
  border-bottom-color: transparent;
}
.fe-toolbar-btn {
  padding: 3px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-dim);
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  min-width: 28px;
  text-align: center;
}
.fe-toolbar-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.07);
  border-color: var(--border);
}

/* ── Contenteditable edit mode ───────────────────────────────────────── */
.doc-typography.fe-editing {
  outline: 1px solid var(--accent);
  border-radius: 4px;
  cursor: text;
  min-height: 200px;
}
.doc-typography.fe-editing:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--accent);
}

/* ── Slim scrollbar (lifted from NEO globals.css) ────────────────────── */
.scrollbar-slim {
  overflow-y: auto;
  scrollbar-width: thin !important;
  scrollbar-color: rgba(120, 120, 120, 0.3) transparent;
}
.scrollbar-slim::-webkit-scrollbar {
  width: 4px !important;
}
.scrollbar-slim::-webkit-scrollbar-track {
  background: transparent;
}
.scrollbar-slim::-webkit-scrollbar-thumb {
  background-color: rgba(120, 120, 120, 0.3);
  border-radius: 4px;
}
.scrollbar-slim::-webkit-scrollbar-thumb:hover {
  background-color: rgba(120, 120, 120, 0.5);
}

/* ── doc-typography (lifted from NEO globals.css, NLC vars) ─────────── */
.doc-typography {
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
}
.doc-typography p {
  color: var(--text);
  font-size: inherit;
  line-height: inherit;
  margin-bottom: 1rem;
}
.doc-typography p:last-child {
  margin-bottom: 0;
}
.doc-typography h1 {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 1em 0 0.5em 0;
  color: var(--text);
}
.doc-typography > h1:first-child,
.doc-typography > div:first-child > h1:first-child {
  margin-top: 0;
}
.doc-typography h2 {
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 1.5em 0 0.5em 0;
  color: var(--text);
}
.doc-typography h3 {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 1.25em 0 0.5em 0;
  color: var(--text);
}
.doc-typography h4 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 1.5em 0 0.5em 0;
  color: var(--text);
}
.doc-typography ul,
.doc-typography ol {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  padding-left: 1.5em;
  list-style-position: outside;
}
.doc-typography ul {
  list-style-type: disc;
}
.doc-typography ol {
  list-style-type: decimal;
}
.doc-typography li {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
  color: var(--text);
}
.doc-typography li::marker {
  color: var(--text);
}
.doc-typography li p {
  margin-top: 0;
  margin-bottom: 0;
}
.doc-typography p + ul,
.doc-typography p + ol {
  margin-top: 0;
}
.doc-typography ul + p,
.doc-typography ol + p {
  margin-top: 1rem;
}
.doc-typography ul ul,
.doc-typography ol ol,
.doc-typography ul ol,
.doc-typography ol ul {
  margin: 0.25em 0;
}
.doc-typography hr {
  border: none;
  border-top: 1px solid var(--border);
  opacity: 0.3;
  margin: 1.5em 0;
}
.doc-typography code {
  background-color: rgba(255,255,255,0.07);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  font-family: 'Courier New', Courier, monospace;
  color: var(--text);
}
.doc-typography pre {
  background-color: rgba(255,255,255,0.07);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.5em 0;
}
.doc-typography pre code {
  background: none;
  padding: 0;
}
.doc-typography blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  font-style: italic;
  color: var(--text-dim);
  margin: 0.5em 0;
}
.doc-typography a {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.doc-typography strong {
  font-weight: 700;
}
.doc-typography em {
  font-style: italic;
}
.doc-typography table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: inherit;
  line-height: 1.5;
}
.doc-typography thead {
  border-bottom: 2px solid var(--border);
}
.doc-typography th {
  text-align: left;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  color: var(--text);
}
.doc-typography td {
  padding: 0.5rem 0.75rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.doc-typography tbody tr:last-child td {
  border-bottom: none;
}

/* Schedules panel */
#right-panel.panel-schedules #right-panel-content {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
#panel-schedules.active { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; padding: 16px; box-sizing: border-box; }
.schedule-panel-top { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.schedule-new-btn {
  padding: 5px 14px; background: var(--accent-dim); color: #fff; border: none;
  border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.schedule-new-btn:hover { background: var(--accent); }
/* "Schedule New Task" button — swapped: hover color is default, default is hover */
#panel-schedules .me-save-btn { background: var(--accent-dim); }
#panel-schedules .me-save-btn:hover { background: var(--accent); }

.schedule-interval-row { display: flex; gap: 8px; margin-top: 4px; width: 100%; }
.schedule-interval-group { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.schedule-interval-group input[type="number"] {
  flex: 1; min-width: 0; width: 100%; padding: 6px 6px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px; text-align: center; outline: none;
  font-family: inherit; -moz-appearance: textfield;
}
.schedule-interval-group input[type="number"]::-webkit-inner-spin-button,
.schedule-interval-group input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.schedule-interval-group input[type="number"]:focus { border-color: var(--accent); }
.schedule-interval-group .interval-label { font-size: 13px; color: var(--text-dim); font-weight: 600; }

.schedule-timeline-header { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-bottom: 10px; }
.schedule-timeline { display: flex; flex-direction: column; gap: 8px; flex: 1; overflow-y: auto; min-height: 0; }

/* Redesigned schedule cards */
.schedule-entry {
  padding: 12px; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; background: rgba(255,255,255,0.04);
  display: flex; flex-direction: column; gap: 6px;
}

/* Row 1: status left, agent right */
.sch-row-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sch-status { display: flex; align-items: center; gap: 5px; }
.sch-status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sch-status-text { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.sch-agent-id { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sch-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; text-transform: uppercase;
}
.sch-agent-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }

/* Row 2: instruction preview */
.sch-task {
  font-size: 13px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* Row 3: metadata */
.sch-meta { font-size: 11px; color: var(--text-dim); opacity: 0.6; }

/* Row 4: action buttons */
.sch-actions { display: flex; gap: 4px; margin-top: 4px; }
.sch-btn {
  flex: 1; border: 1px solid var(--border); border-radius: 4px; font-size: 11px; padding: 5px 4px;
  cursor: pointer; font-family: inherit; transition: background 0.15s, color 0.15s, border-color 0.15s;
  background: none; color: var(--text-dim); text-align: center; white-space: nowrap;
}
.sch-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.sch-btn-run { border-color: rgba(74,222,128,0.4); color: #4ade80; }
.sch-btn-run:hover { background: rgba(74,222,128,0.12); border-color: #4ade80; color: #4ade80; }
.sch-btn-pause { border-color: rgba(245,158,11,0.4); color: #f59e0b; }
.sch-btn-pause:hover { background: rgba(245,158,11,0.12); border-color: #f59e0b; color: #f59e0b; }
.sch-btn-neutral { color: var(--text-dim); }
.sch-btn-delete { border-color: rgba(248,81,73,0.4); color: #f85149; }
.sch-btn-delete:hover { background: rgba(248,81,73,0.12); border-color: #f85149; color: #f85149; }

/* Failed badge */
.schedule-failed { color: #f85149; font-size: 11px; margin-left: 4px; }

.schedule-empty { color: #555; font-size: 13px; text-align: center; padding: 24px 0; }

/* ── Schedule archive button (panel footer) ── */
#schedule-archive-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px;
  background: none; border: none; border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px;
  cursor: pointer; transition: background 0.15s;
  flex-shrink: 0; margin-top: auto;
}
#schedule-archive-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
#schedule-archive-btn svg { flex-shrink: 0; opacity: 0.6; }
#schedule-archive-btn:hover svg { opacity: 1; }
.schedule-archive-label { flex: 1; text-align: left; }
.schedule-archive-count {
  background: rgba(255,255,255,0.1); color: var(--text-dim);
  font-size: 11px; font-weight: 600; padding: 1px 7px;
  border-radius: 10px; min-width: 20px; text-align: center;
}

/* ── Archived Schedules Modal ── */
#schedule-archived-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 10000;
  align-items: center; justify-content: center;
}
#schedule-archived-modal-overlay.visible { display: flex; }
#schedule-archived-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; width: 90%; max-width: 480px;
  max-height: 70vh; display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
#schedule-archived-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#schedule-archived-modal-header h3 {
  margin: 0; font-size: 16px; font-weight: 600; color: var(--text);
}
#schedule-archived-list {
  overflow-y: auto; padding: 8px 12px; flex: 1;
}

/* New/Edit Schedule Modal — same shell as #member-editor-modal */
#schedule-editor-modal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 10001;
  align-items: center; justify-content: center;
}
#schedule-editor-modal.visible { display: flex; }
#schedule-editor-modal-inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; width: 90%; max-width: 1350px; aspect-ratio: 16/9;
  max-height: 90vh; max-height: 90dvh; overflow: hidden;
  position: relative; display: flex; flex-direction: column;
}
#schedule-editor-modal-inner h3 {
  margin: 0 0 16px; font-size: 20px; font-weight: 700; color: var(--text); flex-shrink: 0;
}
#schedule-editor-modal .modal-close-btn {
  position: absolute; top: 16px; right: 16px; background: none; border: none;
  color: var(--text-dim); font-size: 22px; cursor: pointer; padding: 4px 8px;
  border-radius: 4px; line-height: 1; z-index: 1;
}
#schedule-editor-modal .modal-close-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }
/* Modal contact select */
/* Custom searchable agent picker */
.sap-wrapper { position: relative; width: 100%; }
.sap-display {
  width: 100%; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px; font-family: inherit;
  box-sizing: border-box; cursor: pointer; user-select: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sap-display:hover { border-color: var(--accent); }
.sap-wrapper.open .sap-display { border-color: var(--accent); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.sap-dropdown {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 1000;
  background: var(--surface); border: 1px solid var(--accent); border-top: none;
  border-bottom-left-radius: 6px; border-bottom-right-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.sap-wrapper.open .sap-dropdown { display: block; }
.sap-search {
  width: 100%; padding: 8px 10px; background: var(--bg); border: none; border-bottom: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-family: inherit; outline: none; box-sizing: border-box;
}
.sap-search:focus { border-bottom-color: var(--accent); }
.sap-list { max-height: 200px; overflow-y: auto; }
.sap-option {
  padding: 8px 10px; font-size: 13px; color: var(--text); cursor: pointer;
  transition: background 0.1s;
}
.sap-option:hover { background: rgba(255,255,255,0.07); }
.sap-option-selected { background: rgba(88,166,255,0.12); color: var(--accent); }
.sap-option-placeholder { color: var(--text-dim); cursor: default; }
.sap-option-empty { color: var(--text-dim); font-style: italic; cursor: default; }
/* Textarea inside modal fills right column */
#schedule-editor-modal .me-prompt-section { flex: 1; display: flex; flex-direction: column; }
#schedule-editor-modal #schedule-modal-textarea {
  flex: 1; min-height: 0; width: 100%; padding: 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text);
  font-size: 14px; font-family: inherit; resize: none; outline: none; box-sizing: border-box;
}
#schedule-editor-modal #schedule-modal-textarea:focus { border-color: var(--accent); }
@media (max-width: 768px) {
  #schedule-editor-modal-inner { aspect-ratio: auto; max-width: 95%; padding: 16px; }
}

.inventory-list { display: flex; flex-direction: column; gap: 0; padding: 8px 12px; }
.inventory-loading { color: var(--text-secondary, #888); text-align: center; padding: 40px 0; font-size: 14px; }

.inventory-category { border: none; border-radius: 0; overflow: hidden; padding: 16px 12px; }
.inventory-category + .inventory-category { margin-top: 8px; }
.inventory-category:not(:last-child) { border-bottom: 1px solid rgba(255,255,255,0.06); }
.inventory-category-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; margin-bottom: 8px; cursor: pointer; user-select: none;
  transition: background 0.15s; border-radius: 4px;
}
.inventory-category-header:hover { background: rgba(255,255,255,0.05); }
.inventory-category-title { font-size: 0.85rem; font-weight: 700; color: #fff; text-transform: uppercase; letter-spacing: 0.08em; }
.inventory-category-count {
  font-size: 11px; color: var(--text-dim, #8b949e);
  background: none; padding: 0; border-radius: 0;
}
.inventory-category-chevron { color: var(--text-dim, #8b949e); transition: transform 0.2s; font-size: 10px; }
.inventory-category.collapsed .inventory-category-chevron { transform: rotate(-90deg); }
.inventory-category.collapsed .inventory-category-items { display: none; }
.inventory-category-items { border-top: none; padding-top: 4px; }

.inventory-item { padding: 10px 16px; margin-bottom: 4px; border-bottom: none; border-radius: 4px; transition: background 0.15s; }
.inventory-item:hover { background: rgba(255,255,255,0.05); }
.inventory-item-name { font-size: 14px; font-weight: 500; color: #fff; margin-bottom: 1px; font-family: inherit; }
.inventory-item-desc { font-size: 14px; color: rgba(255,255,255,0.55); line-height: 1.3; }
.inventory-item-benefit { font-size: 14px; color: #6a9955; margin-top: 2px; }
.inventory-item-meta { font-size: 11px; color: #555; margin-top: 2px; font-style: italic; }
.inventory-summary { font-size: 12px; color: rgba(255,255,255,0.45); padding: 8px 16px 12px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.harness-dot, .mcp-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.harness-dot.active, .mcp-dot.available { background: #50fa7b; }
.harness-dot.orphaned { background: #ff5555; }
.mcp-dot.misconfigured { background: #ff5555; }
.mcp-dot.unknown { background: #f0883e; }

/* Capabilities tabs */
.cap-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin: 0 16px 16px;
}
.cap-tab {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  user-select: none;
}
.cap-tab:hover {
  color: rgba(255,255,255,0.6);
}
.cap-tab.active {
  color: #fff;
  border-bottom-color: var(--accent, #89b4fa);
}
.cap-tab-content {
  display: none;
}
.cap-tab-content.active {
  display: block;
}

/* Mobile: right rail becomes bottom bar */
@media (max-width: 768px) {
  #app-container {
    flex-direction: column;
  }

  #right-rail {
    width: 100%;
    min-width: unset;
    height: var(--rail-width);
    flex-direction: row;
    justify-content: center;
    padding-top: 0;
    gap: 16px;
    border-left: none;
    border-top: 1px solid var(--border);
    order: 3;
  }

  .rail-spacer {
    display: none;
  }

  #right-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 52px;
    width: 100vw !important;
    z-index: 100;
    transform: translateX(100%);
    border-left: none;
  }

  #right-panel.open {
    transform: translateX(0);
  }

  #chat-screen {
    order: 1;
  }

  #task-dash { display: none !important; }
}

/* Markdown tables */
.md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.03);
}
.md-table th,
.md-table td {
  border: 1px solid rgba(255,255,255,0.1);
  padding: 8px 12px;
  text-align: left;
}
.md-table th {
  background: rgba(255,255,255,0.06);
  font-weight: 600;
}
.md-table tr:hover {
  background: rgba(255,255,255,0.02);
}
/* ── Three.js Mind Map tooltip ── */
#mind-map-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  background: rgba(10, 10, 20, 0.92);
  border: 1px solid rgba(0, 212, 170, 0.4);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: #e6edf3;
  z-index: 100;
  max-width: 220px;
  backdrop-filter: blur(4px);
}
#mind-map-tooltip .tt-name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
#mind-map-tooltip .tt-status { color: #8b949e; font-size: 11px; }
#mind-map-tooltip .tt-duration { color: #58a6ff; font-size: 11px; margin-top: 2px; }

#mind-map-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Team Conversation ── */

/* Sidebar section - gold accent premium styling */
.sidebar-section-team .sidebar-section-header {
  color: rgba(243, 156, 18, 0.6);
}
.sidebar-section-team .sidebar-section-new {
  background: rgba(243, 156, 18, 0.20);
  color: rgba(243, 156, 18, 0.9);
}
.sidebar-section-team .sidebar-section-new:hover {
  background: rgba(243, 156, 18, 0.30);
}
.sidebar-section-team .session-entry:hover {
  background: rgba(243, 156, 18, 0.10);
}
.sidebar-section-team .session-entry.active {
  background: rgba(243, 156, 18, 0.15);
  border-left: 2px solid #F39C12;
}

/* Team conversation entry in sidebar - matches .session-entry dimensions */
.team-entry {
  position: relative;
  padding: 10px 16px; background: transparent;
  border: none; border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer; transition: background 0.15s;
}
.team-entry:hover { background: rgba(243, 156, 18, 0.10); }
.team-entry .session-menu-btn {
  display: block; position: absolute; top: 8px; right: 8px;
  background: none; border: none; color: rgba(255,255,255,0.5);
  font-size: 1.1rem; cursor: pointer; padding: 2px 6px;
  opacity: 0; transition: opacity 0.15s ease; z-index: 2;
  pointer-events: auto;
}
.team-entry:hover .session-menu-btn,
.team-entry .session-menu-btn:focus { opacity: 1; }
.team-entry.active { background: rgba(243, 156, 18, 0.15); border-left: 2px solid #F39C12; }
.team-entry:has(.session-dropdown.open) { z-index: 100; }
.team-entry-topic {
  font-size: 0.85rem; color: #fff; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.team-entry-meta {
  font-size: 0.7rem; color: rgba(255,255,255,0.3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#sidebar-team-list {
  overflow-y: auto;
  scrollbar-width: none;
}
#sidebar-team-list::-webkit-scrollbar { width: 0; display: none; }
#sidebar-team-list::-webkit-scrollbar-track { background: transparent; }
#sidebar-team-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
#sidebar-team-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* Stacked mini avatar circles for team members in sidebar */
.team-mini-avatars {
  display: flex;
  align-items: center;
  margin-bottom: 0;
}
.team-mini-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  margin-left: -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: white;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 0 4px 1px rgba(255,255,255,0.12), 0 0 0 1px rgba(255,255,255,0.15);
}
.team-mini-avatar:first-child {
  margin-left: 0;
}
.team-mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Nested team members design ── */

/* Wrapper for a team card + its nested members */
.team-entry-wrapper {
  position: relative;
}

/* Team card body: rows 2+3 with chevron on right */
.team-card-row1 {
  margin-bottom: 4px;
}
.team-card-body {
  display: flex;
  align-items: center;
  gap: 8px;
}
.team-card-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* Chevron button */
.team-chevron {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: rgba(255,255,255,0.4);
  font-size: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  line-height: 1;
  margin-top: 2px;
}
.team-chevron:hover {
  background: rgba(243, 156, 18, 0.15);
  color: #F39C12;
}

/* Nested member cards container */
.team-nested-members {
  padding: 2px 0 4px;
}

/* Individual nested member card: indent only, inherits everything else from .session-entry */
.team-nested-card {
  margin-left: 6%;
}

/* Typing indicator - pulsing avatar */
@keyframes typing-pulse { 0% { box-shadow: 0 0 0 0 rgba(0,212,170,0.6); } 70% { box-shadow: 0 0 0 6px rgba(0,212,170,0); } 100% { box-shadow: 0 0 0 0 rgba(0,212,170,0); } }
.team-typing-indicator {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 8px 18px 8px 0;
  margin-bottom: 4px;
}
.team-typing-avatars {
  display: flex;
  flex-direction: row;
  align-items: center;
}
.team-typing-indicator .typing-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  animation: typing-pulse 1.5s ease-in-out infinite;
  margin-left: -8px;
}
.team-typing-indicator .typing-avatar:first-child {
  margin-left: 0;
}
.team-typing-indicator .typing-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.team-typing-indicator .typing-name {
  margin-left: 8px;
  font-size: 13px;
  color: var(--text-dim);
}
#messages:has(.team-typing-indicator:last-child) {
  padding-bottom: 2px;
}

.team-avatar-overflow {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #60a5fa;
  box-sizing: content-box;
  margin-left: -4px;
  background: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

/* Team message - Telegram group chat style */
.team-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  max-width: 85%;
  align-items: flex-end;
}
.team-msg.team-user {
  margin-left: auto;
  flex-direction: row-reverse;
  gap: 0;
}

/* Avatar circle */
.team-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.team-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.team-msg.team-user .team-avatar {
  display: none;
}

/* Team builder modal */
#team-builder-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 999;
  align-items: center;
  justify-content: center;
}
#team-builder-modal.open {
  display: flex;
}
#team-builder-modal .modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 40vw;
  width: 90%;
  max-height: 80vh;
  max-height: 80dvh;
  overflow-y: auto;
}
.team-name-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  font-family: inherit;
  outline: none;
  margin-bottom: 16px;
}
.team-members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.team-member-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.team-member-card:hover {
  border-color: var(--accent);
  background: rgba(255,255,255,0.04);
}
.team-member-card .card-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 8px;
  overflow: hidden;
}
.team-member-card .card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.team-member-card .card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.team-member-card .card-role {
  font-size: 11px;
  color: var(--text-dim);
}
.team-member-card .card-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(192, 57, 43, 0.8);
  color: white;
  border: none;
  font-size: 12px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}
.team-member-card:hover .card-remove {
  display: flex;
}
.team-member-card .card-type-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(243, 156, 18, 0.2);
  color: #F39C12;
  display: none;
}
.team-member-card.is-facilitator .card-type-badge {
  display: block;
}
.btn-add-member {
  width: 100%;
  padding: 12px;
  background: none;
  border: 2px dashed var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  margin-bottom: 16px;
}
.btn-add-member:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.add-member-dropdown {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}
.add-member-dropdown.open {
  display: block;
}
.add-member-search {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.add-member-list {
  max-height: 200px;
  overflow-y: auto;
}
/* Filter + selection hiding for team builder modal lists. Toggled by
   modal-team-builder.js to avoid DOM rebuilds on every search keystroke. */
.tb-hidden {
  display: none !important;
}
.add-member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.add-member-item:hover {
  background: rgba(255,255,255,0.06);
}
.add-member-item .item-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.add-member-item .item-name {
  font-size: 13px;
  color: var(--text);
}
.add-member-item .item-role {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
}
.btn-create-new-member {
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn-create-new-member:hover {
  background: rgba(255,255,255,0.04);
}

/* Message content wrapper */
.team-msg-content {
  min-width: 0;
}
.team-msg.team-user .team-msg-content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* Member name inside bubble */
.team-member-name {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  display: block;
}
.team-msg.team-user .team-member-name {
  display: none;
}

/* Chat bubble */
.team-bubble {
  position: relative;
  isolation: isolate;
  padding: 8px 12px;
  border-radius: 12px 12px 12px 0;
  line-height: 1.5;
  font-size: 15px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  border: none;
  display: inline-block;
  max-width: 100%;
}
.team-bubble::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: -10px;
  width: 12px;
  height: 16px;
  z-index: -1;
  clip-path: polygon(100% 0, 100% 100%, 0 100%, 20% 80%, 60% 40%);
}
.team-msg.team-user .team-bubble {
  border-radius: 12px 12px 0 12px;
  color: var(--text);
  width: fit-content;
}
.team-msg.team-user .team-bubble::before {
  left: auto;
  right: -10px;
  width: 12px;
  z-index: -1;
  clip-path: polygon(0 0, 0 100%, 100% 100%, 80% 80%, 40% 40%);
}

/* Bubble inner elements */
.team-bubble p { margin: 6px 0; }
.team-bubble p:first-child { margin-top: 0; }
.team-bubble p:last-child { margin-bottom: 0; }
.team-bubble pre {
  background: var(--bg); padding: 10px; border-radius: 6px;
  overflow-x: auto; margin: 8px 0; font-size: 13px;
  white-space: pre-wrap; word-break: break-word;
}
.team-bubble code {
  background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 13px;
}
.team-bubble pre code { background: none; padding: 0; }
.team-bubble ul, .team-bubble ol { margin: 6px 0; padding-left: 20px; }
.team-bubble h1, .team-bubble h2, .team-bubble h3 {
  margin: 12px 0 6px; font-size: 16px;
}
.team-bubble strong { color: var(--accent); }
.team-bubble .tool-icons {
  margin: 0 0 6px;
}
.team-bubble.team-bubble-tool-only,
.team-bubble-tool-only {
  padding-top: 10px;
  padding-bottom: 10px;
}

/* Team member dynamic colors via CSS custom property */
.team-msg .team-member-name {
  color: var(--member-color, var(--text));
}
.team-msg .team-bubble {
  background: color-mix(in srgb, var(--member-color, #888) 15%, var(--bg));
}
.team-msg .team-bubble::before {
  background: color-mix(in srgb, var(--member-color, #888) 15%, var(--bg));
}
/* User team bubble - match regular chat blue */
.team-msg.team-user .team-bubble {
  background: var(--accent-dim);
}
.team-msg.team-user .team-bubble::before {
  background: var(--accent-dim);
}

/* Skipped turn styling */
.team-msg.team-message-skipped .team-bubble {
  background: transparent;
}
.team-msg.team-message-skipped .team-bubble::before {
  background: transparent;
}
.team-msg.team-message-skipped .team-bubble-body {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-style: italic;
}
.team-msg.team-message-skipped .team-member-name {
  opacity: 1;
}
.team-msg.team-message-skipped .team-avatar {
  opacity: 1;
}

/* Team conversation toolbar buttons */
.team-toolbar-btn {
  width: 28px; height: 28px; background: none; border: 1px solid rgba(243, 156, 18, 0.3);
  border-radius: 6px; color: #F39C12; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.team-toolbar-btn:hover { background: rgba(243, 156, 18, 0.15); border-color: #F39C12; }
.team-toolbar-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.team-toolbar-btn.playing { background: rgba(243, 156, 18, 0.15); border-color: #F39C12; }

/* ── New Team modal (unified) ── */
#new-team-modal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 9999;
  align-items: center; justify-content: center;
}
#new-team-modal.visible { display: flex; }
#new-team-modal-inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; width: 90%; max-width: 900px; aspect-ratio: 16/9;
  max-height: 85vh; max-height: 85dvh; overflow-y: auto;
  position: relative; display: flex; flex-direction: column;
}
#new-team-modal-inner h3 {
  margin: 0 0 16px; font-size: 20px; font-weight: 700; color: var(--text);
  flex-shrink: 0;
}
#new-team-modal .modal-close-btn {
  position: absolute; top: 16px; right: 16px; background: none; border: none;
  color: var(--text-dim); font-size: 22px; cursor: pointer; padding: 4px 8px;
  border-radius: 4px; line-height: 1;
}
#new-team-modal .modal-close-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.new-team-top-row {
  display: flex; gap: 12px; margin-bottom: 20px; flex-shrink: 0;
}
.new-team-top-row input {
  flex: 1; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 15px; font-family: inherit; outline: none;
}
.new-team-top-row input:focus { border-color: var(--accent); }
.new-team-preset-wrap {
  position: relative; flex: 1;
}
.new-team-preset-wrap input {
  width: 100%; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 15px; font-family: inherit; outline: none;
}
.new-team-preset-wrap input:focus { border-color: var(--accent); }
.new-team-preset-dropdown {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  max-height: 200px; overflow-y: auto; margin-top: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.new-team-preset-dropdown.open { display: block; }
.preset-team-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer;
  transition: background 0.1s;
}
.preset-team-item:hover { background: rgba(255,255,255,0.06); }
.preset-team-item .preset-name { font-weight: 600; color: var(--text); font-size: 14px; }
.preset-team-item .preset-count { font-size: 12px; color: var(--text-dim); margin-left: auto; }

/* ── Team select view (State 1) ── */
#team-select-view { display: none; }
#team-select-view.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#team-create-view { display: none; }
#team-create-view.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.team-select-list {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; flex: 1; min-height: 0; overflow-y: auto;
}
.team-select-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.team-select-item:hover { border-color: var(--accent); background: rgba(243, 156, 18, 0.06); }
.team-select-item.selected { border-color: var(--accent); background: rgba(243, 156, 18, 0.1); }
.team-select-avatars {
  display: flex; flex-shrink: 0;
}
.team-select-avatars .ts-avatar {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; border: 2px solid var(--surface); margin-left: -8px;
}
.team-select-avatars .ts-avatar:first-child { margin-left: 0; }
.team-select-avatars .ts-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.team-select-info { flex: 1; min-width: 0; }
.team-select-name { font-weight: 600; color: var(--text); font-size: 15px; }
.team-select-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.team-select-create-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 16px;
  background: transparent; border: 2px dashed var(--border); border-radius: 10px; cursor: pointer;
  color: var(--text-dim); font-size: 15px; font-weight: 600; font-family: inherit;
  transition: border-color 0.15s, color 0.15s; flex-shrink: 0;
}
.team-select-create-btn:hover { border-color: var(--accent); color: var(--accent); }
#team-select-preview { margin-top: 16px; display: none; }
#team-select-preview.active { display: block; }
#team-select-preview .preview-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px;
}
@media (max-width: 768px) {
  #team-select-preview .preview-grid { grid-template-columns: 1fr; }
}
.ts-start-btn {
  display: block; width: 100%; padding: 12px; background: var(--accent); color: #000;
  font-size: 16px; font-weight: 700; border: none; border-radius: 8px; cursor: pointer;
  font-family: inherit; transition: opacity 0.15s;
}
.ts-start-btn:hover { opacity: 0.85; }

/* Member card grid */
.new-team-members-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px;
  flex: 1; min-height: 0; overflow-y: auto; align-content: start;
}
@media (max-width: 768px) {
  .new-team-members-grid { grid-template-columns: 1fr; }
  #new-team-modal-inner { aspect-ratio: auto; max-width: 95vw; padding: 16px; }
  .new-team-top-row { flex-direction: column; }
}

/* Member identity card */
.nt-member-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; position: relative; transition: background 0.15s, border-color 0.15s;
  aspect-ratio: 1.586 / 1;
}
.nt-member-card:hover { background: rgba(255,255,255,0.03); }
.nt-card-top {
  display: flex; align-items: flex-end; gap: 12px; margin-bottom: 8px;
}
.nt-card-avatar {
  width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 24px; font-weight: 700; color: #fff; flex-shrink: 0;
  overflow: hidden;
}
.nt-card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.nt-card-info { flex: 1; min-width: 0; }
.nt-card-name { font-size: 17px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nt-card-role { font-size: 13px; color: #c8a44e; font-weight: 600; }
.nt-card-prompt {
  font-size: 14px; color: var(--text-dim); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis;
}
.nt-card-edit {
  position: absolute;
  top: 8px;
  right: 8px;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  font-size: 18px;
  opacity: 0.7;
  cursor: pointer;
  border: none;
  color: var(--text-muted);
}
.nt-card-edit:hover { opacity: 1; background: rgba(255,255,255,0.12); color: var(--text); }
.nt-card-lock {
  position: absolute;
  top: 8px;
  right: 40px;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  opacity: 0.7;
  color: var(--text-dim);
  pointer-events: none;
}
.nt-card-minus {
  position: absolute; top: 8px; right: 40px;
  border-radius: 50%; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06); opacity: 0.7; cursor: pointer;
  border: none; color: var(--text-dim);
}
.nt-card-minus:hover { opacity: 1; background: rgba(255,255,255,0.12); color: var(--danger); }
/* Add member card */
.nt-add-card {
  background: transparent; border: 2px dashed var(--border); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; aspect-ratio: 1.586 / 1;
  cursor: pointer; color: var(--text-dim); font-size: 15px; font-weight: 600;
  transition: border-color 0.15s, color 0.15s;
}
.nt-add-card:hover { border-color: var(--accent); color: var(--accent); }

/* Start conversation button */
.nt-start-btn {
  display: block; margin-left: auto; padding: 10px 28px; background: #c8a44e;
  color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background 0.15s; flex-shrink: 0;
}
.nt-start-btn:hover { background: #b8943e; }
.nt-start-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Add Member modal ── */
#add-member-modal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 10000;
  align-items: center; justify-content: center;
}
#add-member-modal.visible { display: flex; }
#add-member-modal-inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; width: 90%; max-width: 520px; max-height: 80vh; max-height: 80dvh; overflow-y: auto;
  position: relative;
}
#add-member-modal-inner h3 { margin: 0 0 10px; font-size: 16px; font-weight: 700; color: var(--text); }
#add-member-modal .modal-close-btn {
  position: absolute; top: 10px; right: 12px; background: none; border: none;
  color: var(--text-dim); font-size: 20px; cursor: pointer; padding: 2px 6px;
  border-radius: 4px; line-height: 1;
}
#add-member-modal .modal-close-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }
#add-member-search-input {
  width: 100%; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px; font-family: inherit;
  outline: none; margin-bottom: 10px; box-sizing: border-box;
}
#add-member-search-input:focus { border-color: var(--accent); }
.am-members-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 10px;
}
@media (max-width: 600px) {
  .am-members-grid { grid-template-columns: 1fr; }
}
.am-member-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.am-member-item:hover { border-color: var(--accent); background: rgba(255,255,255,0.04); }
.am-member-avatar {
  width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
  overflow: hidden;
}
.am-member-avatar img { width: 100%; height: 100%; object-fit: cover; }
.am-member-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.am-member-role { font-size: 11px; color: var(--text-dim); margin-left: auto; white-space: nowrap; }
.am-create-btn {
  width: 100%; padding: 8px; background: none; border: 1px dashed var(--border);
  border-radius: 6px; color: var(--text-dim); font-size: 13px; font-weight: 600;
  cursor: pointer; margin-bottom: 8px; transition: border-color 0.15s, color 0.15s;
}
.am-create-btn:hover { border-color: var(--accent); color: var(--accent); }
.am-cancel-btn {
  display: block; margin-left: auto; padding: 6px 20px; background: var(--bg);
  color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; cursor: pointer;
}
.am-cancel-btn:hover { background: rgba(255,255,255,0.06); }

/* ── New Agent modal ── */
#new-agent-modal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 10000;
  align-items: center; justify-content: center;
}
#new-agent-modal.visible { display: flex; }
#new-agent-modal-inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px 24px 20px; width: min(92vw, 860px); max-width: 860px;
  min-height: 620px; max-height: 85vh; max-height: 85dvh; overflow-y: auto;
  position: relative; display: flex; flex-direction: column;
}
#new-agent-modal-inner h3 {
  width: min(100%, 760px); margin: 0 auto 16px; font-size: 20px; font-weight: 700; color: var(--text);
  flex-shrink: 0;
}
#new-agent-modal .modal-close-btn {
  position: absolute; top: 16px; right: 16px; background: none; border: none;
  color: var(--text-dim); font-size: 22px; cursor: pointer; padding: 4px 8px;
  border-radius: 4px; line-height: 1; z-index: 1;
}
#new-agent-modal .modal-close-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }
#new-agent-name-input {
  width: min(100%, 760px); padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; box-sizing: border-box; display: block; margin: 0 auto;
}
#new-agent-name-input:focus { border-color: var(--accent); }

/* ── New Freelancer modal ── */
#new-freelancer-modal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 10000;
  align-items: center; justify-content: center;
}
#new-freelancer-modal.visible { display: flex; }
#new-freelancer-modal-inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px 24px 20px; width: min(92vw, 860px); max-width: 860px;
  min-height: 620px; max-height: 85vh; max-height: 85dvh; overflow-y: auto;
  position: relative; display: flex; flex-direction: column;
}
#new-freelancer-modal-inner h3 {
  width: min(100%, 760px); margin: 0 auto 16px; font-size: 20px; font-weight: 700; color: var(--text);
  flex-shrink: 0;
}
#new-freelancer-modal .modal-close-btn {
  position: absolute; top: 16px; right: 16px; background: none; border: none;
  color: var(--text-dim); font-size: 22px; cursor: pointer; padding: 4px 8px;
  border-radius: 4px; line-height: 1; z-index: 1;
}
#new-freelancer-modal .modal-close-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }
#new-freelancer-name-input {
  width: min(100%, 760px); padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; box-sizing: border-box; display: block; margin: 0 auto;
}
#new-freelancer-name-input:focus { border-color: var(--accent); }

/* ── Shared modal utility classes ── */
.modal-subtitle {
  width: min(100%, 760px); font-size: 0.8rem; color: var(--text-dim); margin: 0 auto 18px;
  flex-shrink: 0;
}
.engine-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  width: min(100%, 760px);
  margin: auto auto;
  align-content: start;
}
.engine-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 124px;
  padding: 18px 22px 18px 54px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,0.02);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.engine-card::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.02);
  transform: translateY(-50%);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.engine-card::after {
  content: "";
  position: absolute;
  left: 27px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transform: translateY(-50%) scale(0.7);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.engine-card[data-runtime="codex"] {
  order: 0;
}
.engine-card[data-runtime="claude"] {
  order: 1;
}
.engine-card:hover {
  border-color: rgba(255,255,255,0.26);
  background: rgba(255,255,255,0.05);
}
.engine-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.engine-card.selected {
  border-color: var(--accent);
  background: rgba(88,166,255,0.08);
  box-shadow: 0 0 0 1px rgba(88,166,255,0.22);
}
.engine-card.selected::before {
  border-color: rgba(88,166,255,0.9);
  box-shadow: 0 0 0 4px rgba(88,166,255,0.12);
  background: rgba(88,166,255,0.06);
}
.engine-card.selected::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}
.engine-card-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 0;
  flex-shrink: 0;
  overflow: hidden;
}
.engine-card-logo svg,
.engine-card-logo img {
  width: 100%;
  height: 100%;
  display: block;
}
.engine-card-logo--claude { background: transparent; }
.engine-card-logo--codex { background: transparent; }
.engine-card-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  min-width: 0;
  flex: 1;
}
.engine-card-wordmark {
  display: flex;
  align-items: center;
  min-height: 52px;
}
.engine-card-wordmark img,
.engine-card-wordmark svg {
  display: block;
  max-width: 100%;
  height: 52px;
  width: auto;
}
.engine-card-wordmark--claude {
  color: #f2f4f8;
}
.engine-card-wordmark--codex {
  color: #f2f4f8;
}
.engine-card-wordmark--claude svg {
  height: 52px;
}
.engine-card-wordmark--codex svg {
  height: 52px;
}
.engine-card-subtitle {
  display: none;
}
.modal-footer-actions { display: flex; justify-content: flex-end; gap: 8px; width: min(100%, 760px); margin: auto auto 0; padding-top: 0; }
.modal-cancel-btn {
  background: transparent; border: 1px solid rgba(255,255,255,0.15); color: var(--text-dim);
  border-radius: 6px; padding: 9px 16px; font-size: 0.9rem; cursor: pointer;
}
.modal-cancel-btn:hover { background: rgba(255,255,255,0.06); }
.modal-primary-btn {
  background: var(--accent); border: none; color: #fff;
  border-radius: 6px; padding: 9px 16px; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.modal-primary-btn:hover { opacity: 0.85; }

@media (max-width: 960px) {
  #new-agent-modal-inner,
  #new-freelancer-modal-inner {
    width: 95vw;
    max-width: 95vw;
    min-height: auto;
  }
  .engine-picker {
    grid-template-columns: 1fr;
  }
}

/* ── Member Editor modal ── */
#member-editor-modal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 10001;
  align-items: center; justify-content: center;
}
#member-editor-modal.visible { display: flex; }
#member-editor-modal-inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; width: 90%; max-width: 1350px; aspect-ratio: 16/9;
  max-height: 85vh; max-height: 85dvh; overflow-y: auto;
  position: relative; display: flex; flex-direction: column;
}
#member-editor-modal-inner h3 {
  margin: 0 0 16px; font-size: 20px; font-weight: 700; color: var(--text);
  flex-shrink: 0;
}
#member-editor-modal .modal-close-btn {
  position: absolute; top: 16px; right: 16px; background: none; border: none;
  color: var(--text-dim); font-size: 22px; cursor: pointer; padding: 4px 8px;
  border-radius: 4px; line-height: 1; z-index: 1;
}
#member-editor-modal .modal-close-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }

/* 2-column layout */
.me-columns {
  display: flex; gap: 24px; flex: 1; min-height: 0;
}
.me-left-col {
  width: 20%; flex-shrink: 0; display: flex; flex-direction: column;
  align-items: flex-start; gap: 16px;
}
.me-right-col {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  padding-top: 0; margin-top: 0;
}

.me-avatar-col {
  display: flex; flex-direction: column; align-items: center; flex-shrink: 0;
  margin-top: 20px; width: 100%;
}
.me-avatar-preview {
  width: 80%; aspect-ratio: 1; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 40px; font-weight: 700; color: #fff;
  overflow: hidden; cursor: pointer; position: relative;
}
.me-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.me-avatar-edit-icon {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 28px; height: 28px;
  border-radius: 50%; background: rgba(0,0,0,0.5); display: flex;
  align-items: center; justify-content: center; cursor: pointer;
  opacity: 0; transition: opacity 0.15s; color: #fff; z-index: 2;
}
.me-avatar-preview::after {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0); transition: background 0.15s; border-radius: 50%;
  pointer-events: none;
}
.me-avatar-col:hover .me-avatar-preview::after { background: rgba(0,0,0,0.3); }
.me-avatar-col:hover .me-avatar-edit-icon { opacity: 1; }

.me-left-col > .me-field { width: 100%; max-width: 100%; }
.me-field label {
  display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 4px;
}
.me-field input[type="text"],
.me-field textarea {
  width: 100%; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  box-sizing: border-box;
}
/* .me-field select: uses .nlc-select base pattern */
.me-field select {
  width: 100%; padding: 8px 32px 8px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  box-sizing: border-box; cursor: pointer;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}
.me-field input[type="text"]:focus,
.me-field textarea:focus { border-color: var(--accent); }
.me-field select:focus { border-color: var(--accent); outline: 2px solid var(--accent-dim); outline-offset: 1px; }
.me-field select option { background: var(--surface); color: var(--text); }

/* Channel icons row */
.me-channel-icons {
  display: flex; gap: 12px; justify-content: center; margin-top: 4px; width: 100%;
}
.me-channel-icon {
  width: 22px; height: 22px; opacity: 0.3; cursor: default;
  color: var(--text-dim);
}
.me-channel-icon[data-channel="whatsapp"] { color: #25D366; }
.me-channel-icon[data-channel="telegram"] { color: #26A5E4; }
.me-channel-icon[data-channel="discord"] { color: #5865F2; }
.me-channel-icon[data-channel="slack"] { color: #36C5F0; }

/* Right column: system prompt fills height */
.me-right-col .me-prompt-section {
  flex: 1; display: flex; flex-direction: column; margin-bottom: 0;
}
.me-prompt-section label {
  display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 4px;
  flex-shrink: 0;
}
.me-prompt-section textarea {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; resize: none; flex: 1; min-height: 120px; box-sizing: border-box;
}
.me-prompt-section textarea:focus { border-color: var(--accent); }

.me-left-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
  width: 100%;
}

.me-left-action-link {
  background: var(--accent-dim);
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}
.me-left-action-link:hover {
  background: var(--accent);
}
.me-left-action-link.me-convert-link.to-freelancer {
  background: #2a8a4a;
}
.me-left-action-link.me-convert-link.to-freelancer:hover {
  background: #33a35a;
}
.me-left-action-link.me-retire-link {
  background: #45475a;
}
.me-left-action-link.me-retire-link:hover {
  background: #585b70;
}
.me-left-action-link.me-delete-link {
  background: var(--danger, #e05252);
}
.me-left-action-link.me-delete-link:hover {
  background: #c93f3f;
}

.me-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px;
  flex-shrink: 0;
}
.me-cancel-btn {
  padding: 8px 24px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 14px; cursor: pointer;
}
.me-cancel-btn:hover { background: rgba(255,255,255,0.06); }
.me-save-btn {
  padding: 8px 24px; background: var(--accent); color: white;
  border: none; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.me-save-btn:hover { background: var(--accent-dim); }

/* Mobile: stack columns vertically, drop aspect ratio */
@media (max-width: 768px) {
  #member-editor-modal-inner {
    aspect-ratio: auto; max-width: 95%; padding: 16px;
  }
  .me-columns { flex-direction: column; gap: 16px; }
  .me-left-col { width: 100%; }
  .me-left-col > .me-field { max-width: none; }
  .me-avatar-col { margin-top: 0; }
  .me-prompt-section textarea { min-height: 200px; }
}

/* ── Decisions button (above task dash) ── */
#decisions-btn {
  display: none;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  left: calc(72px + (100vw - 972px) / 4);
  z-index: 101;
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 4px;
  margin-top: -180px;
  transition: color 0.2s, left 200ms ease;
}
#decisions-btn:hover { color: rgba(255,255,255,0.85); }

/* ── Decisions modal ── */
#decisions-modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}
#decisions-modal-overlay.open { display: flex; }
#decisions-modal {
  background: #1a1a2e;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 90vw;
  max-height: 80vh;
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#decisions-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
#decisions-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
#decisions-modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}
#decisions-modal-close:hover { color: var(--text); }
#decisions-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}
#decisions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
#decisions-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-weight: 600;
  white-space: nowrap;
}
#decisions-table td {
  padding: 10px 10px;
  color: var(--text);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: top;
}
#decisions-table tr:last-child td { border-bottom: none; }
#decisions-table tr:hover td { background: rgba(255,255,255,0.02); }
.decision-status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.decision-status-proposed { background: rgba(245,166,35,0.2); color: #f5a623; }
.decision-status-decided { background: rgba(63,185,80,0.2); color: #3fb950; }
.decision-status-actioned { background: rgba(139,148,158,0.2); color: #8b949e; }
#decisions-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
  font-size: 14px;
}
@media (max-width: 768px) {
  #decisions-btn { display: none !important; }
  #decisions-modal { width: calc(100% - 16px); max-width: none; max-height: 90vh; max-height: 90dvh; border-radius: 8px; }
  #decisions-table { font-size: 12px; }
  #decisions-table th, #decisions-table td { padding: 6px 6px; }
}

/* ── Unified Contact System: 5-section sidebar ── */

/* Section header with collapse arrow */
.sidebar-section-header {
  cursor: pointer;
  user-select: none;
  gap: 6px;
}
.sidebar-section-header .section-arrow {
  font-size: 0.55rem;
  color: rgba(255,255,255,0.3);
  margin-right: 4px;
  width: 10px;
  display: inline-block;
}
.sidebar-section-header .section-count {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.25);
  font-weight: 400;
}

.section-add-btn {
  background: transparent;
  border: none;
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 999px;
  color: inherit;
  opacity: 0.7;
  flex-shrink: 0;
  transition: opacity 0.15s, background-color 0.15s;
}

.section-add-btn:hover {
  opacity: 1;
  background: rgba(255,255,255,0.08);
}

/* Team Chats section colors */
.sidebar-section-teams .sidebar-section-header {
  background: rgba(243,156,18,0.15);
  color: rgba(255,255,255,0.9);
}
.sidebar-section-teams .section-add-btn {
  color: rgba(243,156,18,0.9);
}
/* Assistants section colors (green) */
.sidebar-section-assistants .sidebar-section-header {
  background: rgba(74,222,128,0.15);
  color: rgba(255,255,255,0.9);
}
.sidebar-section-assistants .section-add-btn {
  color: rgba(74,222,128,0.9);
}
.sidebar-section-assistants .session-entry:hover,
.sidebar-section-assistants .contact-entry:hover {
  background: rgba(74, 222, 128, 0.10);
}
.sidebar-section-assistants .session-entry.active,
.sidebar-section-assistants .contact-entry.active {
  background: rgba(74, 222, 128, 0.15);
  border-left-color: rgb(74, 222, 128);
}

/* Team Members section colors (purple) */
.sidebar-section-team-members .sidebar-section-header {
  color: rgba(168, 130, 255, 0.6);
}
.sidebar-section-team-members .session-entry:hover,
.sidebar-section-team-members .contact-entry:hover {
  background: rgba(168, 130, 255, 0.10);
}
.sidebar-section-team-members .session-entry.active,
.sidebar-section-team-members .contact-entry.active {
  background: rgba(168, 130, 255, 0.15);
  border-left-color: rgb(168, 130, 255);
}

/* Freelancers section colors (blue) */
.sidebar-section-freelancers .sidebar-section-header {
  background: rgba(59,130,246,0.15);
  color: rgba(255,255,255,0.9);
}
.sidebar-section-freelancers .section-add-btn {
  color: rgba(59,130,246,0.9);
}
.sidebar-section-freelancers .session-entry:hover,
.sidebar-section-freelancers .contact-entry:hover {
  background: rgba(59, 130, 246, 0.10);
}
.sidebar-section-freelancers .session-entry.active,
.sidebar-section-freelancers .contact-entry.active {
  background: rgba(59, 130, 246, 0.15);
  border-left-color: rgb(59, 130, 246);
}

/* Retired section colors (gray) */
.sidebar-section-retired .sidebar-section-header {
  color: rgba(139, 148, 158, 0.5);
}
.sidebar-section-retired .session-entry:hover,
.sidebar-section-retired .contact-entry:hover {
  background: rgba(139, 148, 158, 0.08);
}
.sidebar-section-retired .session-entry.active,
.sidebar-section-retired .contact-entry.active {
  background: rgba(139, 148, 158, 0.12);
  border-left-color: rgb(139, 148, 158);
}
.sidebar-section-retired .session-entry,
.sidebar-section-retired .contact-entry {
  opacity: 0.6;
}

/* Agents section (orphan tmux) */
.sidebar-section-agents .sidebar-section-header {
  background: rgba(74,222,128,0.15);
  color: rgba(255,255,255,0.9);
}
.sidebar-section-agents .section-add-btn {
  color: rgba(74,222,128,0.9);
}
.sidebar-section-agents .session-entry:hover {
  background: rgba(74, 222, 128, 0.10);
}
.sidebar-section-agents .session-entry.active {
  background: rgba(74, 222, 128, 0.15);
  border-left-color: rgb(74, 222, 128);
}

/* Chats section (orphan chat sessions) */
.sidebar-section-chats .sidebar-section-header {
  color: rgba(59, 130, 246, 0.6);
}
.sidebar-section-chats .session-entry:hover {
  background: rgba(59, 130, 246, 0.10);
}
.sidebar-section-chats .session-entry.active {
  background: rgba(59, 130, 246, 0.15);
  border-left-color: rgb(59, 130, 246);
}

/* Contact entry (unified card: LEFT info + RIGHT avatar with status border) */
.contact-entry {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: background 0.15s;
}

/* Contact avatar (RIGHT side via order) */
.contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
  order: 2;
  cursor: pointer;
  box-sizing: border-box;
}
.contact-avatar .avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.contact-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* Status border on contact avatar */
/* status-idle: no visible border (dormant). Green border moved to status-dm-unread only. */
.contact-avatar.status-idle {
  border: 2px solid transparent;
}
.contact-avatar.status-working {
  border: 2px solid #58a6ff;
  animation: avatar-pulse-blue 1.5s ease-in-out infinite;
}
.contact-avatar.status-down {
  border: 2px solid #f85149;
  animation: avatar-pulse-red 1.5s ease-in-out infinite;
}

/* Contact info (LEFT side via order) */
.contact-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  order: 1;
}
.contact-name {
  font-size: 0.85rem;
  color: #fff;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-role {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hide old contact menu button and dropdown (replaced by avatar -> settings modal) */
.contact-menu-btn {
  display: none;
}
.contact-dropdown {
  display: none;
}

/* ── Mobile modal overrides ── */
@media (max-width: 768px) {
  #team-builder-modal .modal-content { max-width: 95vw; }
  #member-editor-modal-inner { max-width: 95vw; }
  #add-member-modal-inner { max-width: 95vw; }
}

/* ── Relay Setup Wizard Modal ── */
#relay-wizard-modal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 10002;
  align-items: center; justify-content: center;
}
#relay-wizard-modal.visible { display: flex; }
#relay-wizard-modal-inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; width: 90%; max-width: 560px;
  max-height: 85vh; max-height: 85dvh; overflow-y: auto;
  position: relative; display: flex; flex-direction: column;
}
#relay-wizard-modal-inner h3 {
  margin: 0 0 16px; font-size: 18px; font-weight: 700; color: var(--text); flex-shrink: 0;
}
#relay-wizard-modal .modal-close-btn {
  position: absolute; top: 16px; right: 16px; background: none; border: none;
  color: var(--text-dim); font-size: 22px; cursor: pointer; padding: 4px 8px;
  border-radius: 4px; line-height: 1; z-index: 1;
}
#relay-wizard-modal .modal-close-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }

/* Channel views: only .active one is shown */
.relay-channel-view { display: none; flex-direction: column; flex: 1; }
.relay-channel-view.active { display: flex; }

/* Step views: only .active one is shown — reuses same pattern as team-select-view */
.relay-step { display: none; flex-direction: column; flex: 1; gap: 12px; }
.relay-step.active { display: flex; }

.relay-step-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.relay-step-subtitle { font-size: 14px; color: var(--text-dim); margin-bottom: 4px; }

/* Numbered instruction list */
.relay-instructions { padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--text); line-height: 1.5; }
.relay-instructions li { padding-left: 4px; }
.relay-instructions code { background: rgba(255,255,255,0.08); border-radius: 4px; padding: 1px 5px; font-family: monospace; font-size: 12px; }
.relay-instructions-inline { font-size: 13px; color: var(--text); line-height: 1.5; }
.relay-instructions-inline code { background: rgba(255,255,255,0.08); border-radius: 4px; padding: 1px 5px; font-family: monospace; font-size: 12px; }

.relay-note { font-size: 12px; color: var(--text-dim); font-style: italic; }

/* Input fields */
.relay-field { display: flex; flex-direction: column; gap: 4px; }
.relay-field label { font-size: 13px; color: var(--text-dim); }
.relay-field input {
  padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px; font-family: inherit; outline: none;
  width: 100%;
}
.relay-field input:focus { border-color: var(--accent); }
.relay-field-hint { font-size: 11px; color: var(--text-dim); }

/* Action buttons row */
.relay-step-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.relay-btn-primary {
  padding: 8px 18px; background: var(--accent-dim); color: white;
  border: none; border-radius: 6px; font-size: 14px; cursor: pointer;
}
.relay-btn-primary:hover { background: var(--accent); }
.relay-btn-secondary {
  padding: 8px 18px; background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 6px; font-size: 14px; cursor: pointer;
}
.relay-btn-secondary:hover { background: rgba(255,255,255,0.06); color: var(--text); }

/* QR code display */
.relay-qr-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--text-dim); font-size: 13px;
  margin: 16px auto; width: 100%; text-align: center;
}
.relay-spinner {
  width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: relay-spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes relay-spin { to { transform: rotate(360deg); } }
.relay-qr-img {
  display: block; max-width: 240px; max-height: 240px; border-radius: 8px;
  margin: 8px auto; border: 2px solid var(--border);
}

/* Connected success state */
.relay-success-icon {
  font-size: 48px; color: var(--success); text-align: center; margin: 8px 0;
}
.relay-connected-msg {
  font-size: 15px; color: var(--text); text-align: center; line-height: 1.5;
}

/* Channel icon: clickable when in member editor */
.me-channel-icon[data-channel] { cursor: pointer; transition: opacity 0.15s ease; }
.me-channel-icon[data-channel]:hover { opacity: 0.8 !important; }

@media (max-width: 768px) {
  #relay-wizard-modal-inner { max-width: 95vw; padding: 16px; }
}

/* Inline Visualizer */
.nlc-viz-outer { margin: 12px 0; }
.nlc-viz-wrapper { border-radius: 8px; overflow: hidden; border: 1px solid #2d3748; }
.nlc-viz-header { display: flex; justify-content: center; align-items: center; padding: 2px 8px; opacity: 0.6; }
.nlc-viz-label { font-size: 10px; color: #94a3b8; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0; transition: opacity 0.2s; }
.nlc-viz-wrapper:hover .nlc-viz-label { opacity: 1; }
.nlc-viz-footer { display: flex; justify-content: flex-end; padding: 2px 0; }
.nlc-viz-toggle { background: transparent; border: none; color: #64748b; cursor: pointer; font-size: 11px; padding: 2px 4px; }
.nlc-viz-toggle:hover { color: #818cf8; text-decoration: underline; }
.nlc-viz-iframe { display: block; width: 100%; overflow: auto; }
.nlc-viz-source { background: #0f172a; border: 1px solid #2d3748; border-radius: 4px; margin: 4px 0 0 0; padding: 12px; font-size: 12px; overflow-x: auto; max-height: 300px; overflow-y: auto; }

/* Health panel — CPU/RAM sparklines above Owner button */
#health-panel {
  padding: 6px 12px;
  display: block;
}
.health-panel-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.health-label {
  font-size: 10px;
  opacity: 0.6;
  min-width: 26px;
}
#health-panel canvas {
  display: block;
  flex: 1;
  min-width: 0;
  height: 28px;
}
.health-pct {
  font-size: 10px;
  min-width: 28px;
  text-align: right;
}
/* Clickable health panel */
#health-panel { cursor: pointer; }
#health-panel:hover { background: rgba(255,255,255,0.04); border-radius: 6px; }

/* Collapsed sidebar: hide labels and percentages, hide panel entirely to avoid overflow */
#left-sidebar:not(.expanded) #health-panel {
  display: none;
}


/* Process monitor floating dock */
#process-panel {
  display: none;
  position: fixed;
  bottom: 12px;
  left: 268px;
  width: 40vh;
  height: 40vh;
  background: var(--surface, #1a1a2e);
  border: 1px solid var(--border, #30363d);
  border-radius: 8px;
  z-index: 99;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
#process-panel.open {
  display: flex;
}
#process-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, #30363d);
  font-weight: 600;
  font-size: 13px;
  color: #e6edf3;
  flex-shrink: 0;
}
#process-panel-close {
  background: none;
  border: none;
  color: #8b949e;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}
#process-panel-close:hover {
  color: #e6edf3;
}
#process-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.process-row {
  display: flex;
  align-items: center;
  padding: 5px 14px;
  font-size: 12px;
  color: #c9d1d9;
  gap: 8px;
}
.process-row:hover {
  background: rgba(255,255,255,0.04);
}
.process-name {
  width: 130px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.process-cpu {
  width: 45px;
  text-align: right;
  font-family: monospace;
  flex-shrink: 0;
}
.process-mem {
  width: 55px;
  text-align: right;
  font-family: monospace;
  color: #8b949e;
  flex-shrink: 0;
}
.process-bar {
  flex: 1;
  height: 4px;
  background: #21262d;
  border-radius: 2px;
  overflow: hidden;
  min-width: 30px;
}
.process-bar-fill {
  height: 100%;
  border-radius: 2px;
}
.proc-empty {
  padding: 8px 0;
  text-align: center;
  font-size: 11px;
  color: #484f58;
  width: 100%;
}
/* When sidebar is collapsed */
#left-sidebar:not(.expanded) ~ #process-panel {
  left: 64px;
}

/* ── Settings Modal ── */
/* ── Settings Modal (mirrors member-editor pattern) ── */
#settings-modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); z-index: 10001;
  align-items: center; justify-content: center;
}
#settings-modal-overlay.visible { display: flex; }
#settings-modal-inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; width: 90%; max-width: 1350px; aspect-ratio: 16/9;
  max-height: 85vh; max-height: 85dvh; overflow-y: auto;
  position: relative; display: flex; flex-direction: column;
}
#settings-modal-inner h3 {
  margin: 0 0 16px; font-size: 20px; font-weight: 700; color: var(--text);
  flex-shrink: 0;
}
#settings-modal-overlay .modal-close-btn {
  position: absolute; top: 16px; right: 16px; background: none; border: none;
  color: var(--text-dim); font-size: 22px; cursor: pointer; padding: 4px 8px;
  border-radius: 4px; line-height: 1; z-index: 1;
}
#settings-modal-overlay .modal-close-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }

/* 2-column layout (mirrors .me-columns) */
.se-columns {
  display: flex; gap: 24px; flex: 1; min-height: 0;
}
.se-left-col {
  width: 20%; flex-shrink: 0; display: flex; flex-direction: column;
  align-items: flex-start; gap: 2px; padding-top: 4px;
  border-right: 1px solid var(--border); padding-right: 24px;
}
.se-right-col {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  padding-top: 0; padding-bottom: 24px; margin-top: 0;
}

/* Tab buttons (left column) */
.se-tab {
  background: none; border: none; border-radius: 6px;
  padding: 8px 12px; text-align: left; color: var(--text-dim);
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: background 0.15s, color 0.15s;
  width: 100%;
}
.se-tab:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.se-tab.active {
  background: rgba(88,166,255,0.15); color: var(--accent); cursor: default;
}

/* Panels (right column) */
.se-panel { display: none; flex: 1; flex-direction: column; padding-bottom: 8px; }
.se-panel.active { display: flex; }

/* Field styling (mirrors .me-field) */
.se-field { margin-bottom: 20px; }
.se-field label {
  display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 4px;
}
/* .se-field select: uses .nlc-select base pattern */
.se-field select {
  width: 100%; padding: 8px 32px 8px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  box-sizing: border-box; cursor: pointer;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}
.se-field select:focus { border-color: var(--accent); outline: 2px solid var(--accent-dim); outline-offset: 1px; }
.se-field select option { background: var(--surface); color: var(--text); }

/* Appearance option (static pill) */
.se-option-row { display: flex; gap: 8px; align-items: center; }
.se-option-active {
  background: rgba(88,166,255,0.15); color: var(--accent);
  padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
}

/* System prompt section (mirrors .me-prompt-section) */
.se-prompt-section {
  flex: 1; display: flex; flex-direction: column; margin-bottom: 0;
}
.se-prompt-section label {
  display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 4px;
  flex-shrink: 0;
}
#settings-system-prompt {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; resize: none; flex: 1; min-height: 120px; box-sizing: border-box;
}
#settings-system-prompt:focus { border-color: var(--accent); }

/* Hint text */
.se-hint {
  font-size: 11px; color: var(--text-dim); margin-top: 8px;
  line-height: 1.4;
}

/* Left column divider and logout button */
.se-left-divider {
  border: none; border-top: 1px solid var(--border); margin: 8px 0;
}
.se-logout-btn {
  width: 100%; padding: 8px 12px; border-radius: 6px; border: none;
  background: transparent; font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: left; color: #e05252;
  transition: background 0.15s, color 0.15s;
}
.se-logout-btn:hover { background: rgba(224,82,82,0.1); }

/* AI Provider tab styles */
.se-section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 12px;
}
.se-provider-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border); margin-bottom: 0;
}
.se-provider-row:last-of-type { border-bottom: none; }
.se-provider-label {
  display: flex; flex-direction: column; gap: 4px; flex: 1;
}
.se-provider-name {
  font-size: 13px; color: var(--text); font-weight: 500;
}
.se-provider-status, .se-provider-email {
  font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 8px;
}
.se-provider-status.not-running { color: #e09a2e; }
.se-disconnect-btn {
  background: none; border: none; color: var(--accent); font-size: 12px;
  cursor: pointer; padding: 0; text-decoration: underline;
}
.se-disconnect-btn:disabled { color: var(--text-dim); cursor: default; text-decoration: none; }
.se-api-key-input {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px; padding: 8px 12px;
  width: 100%; margin-top: 4px; box-sizing: border-box; font-family: inherit;
}
.se-api-key-input:focus { outline: none; border-color: var(--accent); }
.se-api-key-input:-webkit-autofill,
.se-api-key-input:-webkit-autofill:hover,
.se-api-key-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #0d1117 inset;
  -webkit-text-fill-color: var(--text);
  transition: background-color 5000s ease-in-out 0s;
}

/* ── Masked API Key Display ── */
.masked-key-container {
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  margin-top: 4px;
  box-sizing: border-box;
  cursor: default;
}
.masked-key-dots {
  font-family: monospace;
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: 2px;
  user-select: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.masked-key-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 150ms ease;
  padding: 0 0 0 8px;
}
.masked-key-container:hover .masked-key-actions {
  opacity: 1;
}
.masked-key-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  padding: 0;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}
.masked-key-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.08);
  border-color: var(--border);
}
.masked-key-btn svg {
  flex-shrink: 0;
}
.masked-key-edit-mode {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.masked-key-edit-mode .se-api-key-input {
  margin-top: 0;
}
.masked-key-edit-actions {
  display: flex;
  gap: 6px;
}
.masked-key-save-btn,
.masked-key-cancel-btn {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 150ms ease, border-color 150ms ease;
}
.masked-key-save-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.masked-key-save-btn:hover {
  background: var(--accent-dim);
}
.masked-key-cancel-btn {
  background: transparent;
  color: var(--text-dim);
}
.masked-key-cancel-btn:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
}
.masked-key-btn .copied-feedback {
  font-size: 10px;
  font-family: inherit;
  color: var(--success);
}

/* Toggle (radio styled as pill) */
.se-toggle {
  position: relative; display: inline-block; width: 36px; height: 20px;
  flex-shrink: 0; cursor: pointer;
}
.se-toggle input {
  opacity: 0; width: 0; height: 0; position: absolute;
}
.se-toggle-track {
  position: absolute; inset: 0; background: var(--border); border-radius: 10px;
  transition: background 0.2s;
}
.se-toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform 0.2s;
}
.se-toggle input:checked + .se-toggle-track {
  background: var(--accent);
}
.se-toggle input:checked + .se-toggle-track::after {
  transform: translateX(16px);
}

/* AI settings tab — sub-panels, account row, status badges, Ollama loading, model search */
.se-ai-sub-panel {
  /* shown/hidden via JS — base state is visible (JS hides the inactive ones via display:none inline style) */
  margin-top: 12px;
}
.se-account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.se-connect-btn {
  padding: 8px 16px;
  background: #1f6feb;
  color: #e6edf3;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.se-connect-btn:hover { background: #388bfd; }
.se-ai-divider {
  height: 1px;
  background: #30363d;
  margin: 16px 0 12px 0;
}
.se-account-email {
  flex: 1;
  font-size: 13px;
  opacity: 0.8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.se-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 500;
}
.se-status-badge--green {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}
.se-status-badge--yellow {
  background: rgba(245, 158, 11, 0.16);
  color: #f59e0b;
}
.se-status-badge--red {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}
.se-ollama-loading-wrap {
  margin: 10px 0;
}
.se-ollama-loading-label {
  font-size: 12px;
  opacity: 0.6;
  margin-bottom: 6px;
  display: block;
}
.se-ollama-loading-bar {
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.se-ollama-loading-fill {
  height: 100%;
  width: 40%;
  border-radius: 2px;
  animation: se-loading-slide 1.4s ease-in-out infinite;
  background: var(--accent);
}
@keyframes se-loading-slide {
  0% { transform: translateX(-200%); }
  100% { transform: translateX(400%); }
}
.se-model-search {
  margin-bottom: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  width: 100%;
  box-sizing: border-box;
  font-size: 14px;
}

/* ── OpenRouter searchable combobox ── */
.or-combobox {
  position: relative;
  width: 100%;
}
.or-combobox-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  box-sizing: border-box;
  text-align: left;
  outline: none;
}
.or-combobox-trigger:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-dim);
  outline-offset: 1px;
}
.or-combobox-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.or-combobox-chevron {
  flex-shrink: 0;
  margin-left: 8px;
  color: var(--text-dim);
  transition: transform 0.15s ease;
}
.or-combobox.open .or-combobox-chevron {
  transform: rotate(180deg);
}
.or-combobox-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  overflow: hidden;
}
.or-combobox.open .or-combobox-dropdown {
  display: block;
}
.or-combobox-search {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: rgba(255,255,255,0.05);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  outline: none;
}
.or-combobox-search::placeholder {
  color: var(--text-dim);
}
.or-combobox-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 240px;
  overflow-y: auto;
}
.or-combobox-list::-webkit-scrollbar {
  width: 6px;
}
.or-combobox-list::-webkit-scrollbar-track {
  background: transparent;
}
.or-combobox-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.or-combobox-item {
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.or-combobox-item:hover {
  background: rgba(255,255,255,0.08);
}
.or-combobox-item.selected {
  background: rgba(88,166,255,0.15);
  color: var(--accent);
}
.or-combobox-item.hidden {
  display: none;
}

.se-ollama-status-row {
  margin-bottom: 8px;
}

/* ── Memory tab (extraction settings) ── */
.se-extraction-toggle-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-top: 4px;
}
.se-extraction-toggle-info {
  display: flex; flex-direction: column; gap: 4px; flex: 1;
}
.se-extraction-toggle-label {
  font-size: 15px; font-weight: 600; color: var(--text);
}
.se-extraction-toggle-desc {
  font-size: 13px; color: var(--text-dim); line-height: 1.5;
}
.se-extraction-hint {
  font-size: 12px; color: var(--text-dim); line-height: 1.4;
}
.se-extraction-warning {
  font-size: 12px; color: #f0a040; margin-top: 6px; line-height: 1.4;
}
.se-extraction-free-warning {
  background: rgba(240, 160, 64, 0.08); border: 1px solid rgba(240, 160, 64, 0.25);
  border-radius: 8px; padding: 12px 14px; font-size: 13px; color: #f0a040;
  line-height: 1.5; margin-top: 12px;
}
.se-extraction-info {
  font-size: 12px; color: var(--text-dim); line-height: 1.5;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* Tier cards */
.se-tier-cards {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-top: 8px;
}
.se-tier-card {
  position: relative; cursor: pointer;
}
.se-tier-card input[type="radio"] {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.se-tier-card-inner {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 4px; padding: 16px 10px; border-radius: 10px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.se-tier-card-inner:hover {
  border-color: rgba(88,166,255,0.3); background: rgba(88,166,255,0.04);
}
.se-tier-card input[type="radio"]:checked + .se-tier-card-inner {
  border-color: var(--accent); background: rgba(88,166,255,0.08);
  box-shadow: 0 0 0 1px var(--accent);
}
.se-tier-name {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.se-tier-model {
  font-size: 11px; color: var(--text-dim); opacity: 0.7;
}
.se-tier-price {
  font-size: 13px; font-weight: 600; color: var(--accent); margin-top: 4px;
}
.se-tier-detail {
  font-size: 11px; color: var(--text-dim); line-height: 1.3; margin-top: 2px;
}

/* Mobile: stack columns vertically, drop aspect ratio */
@media (max-width: 768px) {
  #settings-modal-inner {
    aspect-ratio: auto; max-width: 95%; padding: 16px;
  }
  .se-columns { flex-direction: column; gap: 16px; }
  .se-left-col { width: 100%; border-right: none; padding-right: 0; border-bottom: 1px solid var(--border); padding-bottom: 12px; flex-direction: row; flex-wrap: wrap; }
  #settings-system-prompt { min-height: 200px; }
  .se-tier-cards { grid-template-columns: repeat(2, 1fr); }
  .engine-picker { grid-template-columns: 1fr; }
}

/* PDF attachment display */
.pdf-attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  max-width: 300px;
  transition: background 0.15s;
}
.pdf-attachment:hover {
  background: rgba(255, 255, 255, 0.15);
}
.pdf-attachment-icon {
  width: 32px;
  height: 32px;
  background: #e74c3c;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.pdf-attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  opacity: 0.9;
}
#image-preview .pdf-attachment {
  padding: 4px 8px;
  max-width: 200px;
}
#image-preview .pdf-attachment-icon {
  width: 24px;
  height: 24px;
  font-size: 9px;
}
#image-preview .pdf-attachment-name {
  font-size: 11px;
}

.ai-provider-row--disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.ai-provider-row--disabled * {
  pointer-events: none;
}

/* ── Unified dropdown (nlc-select) ── */
.nlc-select {
  width: 100%; padding: 8px 32px 8px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  box-sizing: border-box; cursor: pointer;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}
.nlc-select:focus { border-color: var(--accent); outline: 2px solid var(--accent-dim); outline-offset: 1px; }
.nlc-select option { background: var(--surface); color: var(--text); }

/* ── No-provider banner ── */
.no-provider-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(13, 17, 23, 0.95);
  border-radius: 8px;
  font-size: 14px;
  color: #f0a040;
  z-index: 10;
}
.no-provider-banner button {
  padding: 6px 14px;
  background: #1f6feb;
  color: #e6edf3;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.no-provider-banner button:hover { background: #388bfd; }

/* ── Provider hint text ── */
.se-hint-text {
  font-size: 12px;
  color: #f0a040;
  margin: 4px 0 8px 0;
  min-height: 0;
}

.se-providers-intro {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 18px;
}
.se-providers-intro-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.se-providers-intro-copy {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}

.se-runtime-section,
.se-codex-auth-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.se-runtime-section {
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.se-runtime-section-header,
.se-codex-auth-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.se-runtime-section-title,
.se-codex-auth-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.se-runtime-section-copy,
.se-codex-auth-copy {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
}

.se-codex-auth-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.se-codex-auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.se-codex-auth-meta,
.se-codex-auth-note {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
}

.se-codex-auth-code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  font-size: 12px;
  color: var(--text);
}

.se-codex-auth-code strong {
  letter-spacing: 0.08em;
}

.se-codex-auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.se-codex-auth-link {
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.se-codex-auth-link:hover {
  text-decoration: underline;
}

.se-oc-intro {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.se-oc-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  color: var(--text);
}
.se-oc-copy {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}
.se-oc-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.se-oc-requirements {
  margin-top: 14px;
}
.se-oc-requirements-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.se-oc-requirements-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.se-oc-requirement {
  position: relative;
  padding-left: 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.se-oc-requirement::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 0;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.48);
}
.se-oc-inline-error {
  margin-top: 10px;
  color: #f87171;
  font-size: 12px;
}
.se-oc-model-field {
  margin-top: 18px;
}
.se-oc-model-placeholder {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: transparent;
}
.se-oc-model-placeholder strong {
  font-size: 13px;
  color: var(--text);
}
.se-oc-model-placeholder span {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.se-oc-model-placeholder-note {
  margin-top: 4px;
}
.se-oc-pair-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-top: 14px;
}
.se-oc-qr-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(240,244,248,0.98));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
}
#se-oc-qr-img {
  width: 160px;
  height: 160px;
  display: block;
}
.se-oc-pair-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  justify-content: center;
}
#se-oc-pairing-link {
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}
.se-oc-link-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.se-oc-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.se-oc-link-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-1px);
}
.se-oc-link-btn--primary {
  background: linear-gradient(180deg, #1f6feb, #1858bd);
  border-color: rgba(255,255,255,0.08);
  color: #f8fbff;
}
.se-oc-link-btn--primary:hover {
  background: linear-gradient(180deg, #388bfd, #1f6feb);
}
.se-oc-waiting-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.se-oc-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45);
  animation: se-oc-pulse 1.6s ease-out infinite;
}
@keyframes se-oc-pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
  100% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); }
}
.se-oc-expiry,
.se-oc-copy-feedback,
.se-oc-field-note {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}
.se-oc-field-note {
  display: block;
  margin-top: 10px;
}
.se-oc-copy-feedback {
  color: #93c5fd;
}
.se-oc-cancel-btn {
  margin-top: 12px;
}
.oc-combobox-list {
  max-height: 320px;
}
.or-combobox-item.oc-combobox-item {
  padding-left: 22px;
}
.oc-combobox-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  min-height: 36px;
}
.oc-combobox-separator-label {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  opacity: 0.82;
}
.oc-combobox-separator-line {
  display: block;
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
}
.oc-combobox-item.hidden,
.oc-combobox-separator.hidden {
  display: none;
}
@media (max-width: 700px) {
  .se-oc-pair-layout {
    grid-template-columns: 1fr;
  }
  .se-oc-qr-shell {
    width: 100%;
    max-width: 180px;
  }
}

/* ── Browser panel reset button ── */
#browser-reset-btn {
  background: transparent;
  border: none;
  color: #5f6368;
  cursor: pointer;
  padding: 4px 7px;
  font-size: 15px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#browser-reset-btn:hover { color: #202124; background: rgba(0,0,0,0.06); }

/* ── Agent settings Voice tab ─────────────────────────────────────── */
.me-tabs { display:flex; gap:4px; margin-bottom:12px; border-bottom:1px solid var(--border,#333); }
.me-tab-btn { background:none; border:none; padding:6px 14px; cursor:pointer; color:var(--text-secondary,#aaa); font-size:13px; border-bottom:2px solid transparent; margin-bottom:-1px; }
.me-tab-btn.active { color:var(--text,#eee); border-bottom-color:var(--accent,#7c6ff7); }
.me-tab-panel { display:none; }
.me-tab-panel.active { display:flex; flex-direction:column; flex:1; min-height:0; }
.me-voice-url-row { display:flex; align-items:center; gap:6px; margin-bottom:10px; flex-wrap:wrap; flex-shrink:0; }
.me-voice-url-input { flex:1; min-width:0; padding:5px 8px; border:1px solid var(--border,#444); border-radius:4px; background:var(--input-bg,#1e1e1e); color:var(--text,#eee); font-size:12px; }
.me-voice-url-input.error { border-color:#e53e3e; }
.me-voice-url-add { padding:5px 10px; background:var(--accent,#7c6ff7); color:#fff; border:none; border-radius:4px; cursor:pointer; font-size:12px; white-space:nowrap; }
.me-voice-list { display:flex; flex-direction:column; gap:4px; flex:1; overflow-y:auto; margin-bottom:0; min-height:0; }
.me-voice-row { display:flex; align-items:center; gap:8px; padding:6px 8px; border:1px solid var(--border,#333); border-radius:6px; cursor:pointer; }
.me-voice-row:hover { background:var(--hover-bg,#2a2a2a); }
.me-voice-row.selected { border-color:var(--accent,#7c6ff7); background:var(--accent-subtle,#1e1b3a); }
.me-voice-radio { width:10px; height:10px; border-radius:50%; border:2px solid var(--border,#555); flex-shrink:0; }
.me-voice-row.selected .me-voice-radio { background:var(--accent,#7c6ff7); border-color:var(--accent,#7c6ff7); }
.me-voice-name { font-size:13px; font-weight:500; color:var(--text,#eee); flex:1; }
.me-voice-desc { font-size:11px; color:var(--text-secondary,#888); }
.me-voice-play-btn, .me-voice-remove-btn { background:none; border:none; cursor:pointer; padding:2px 4px; color:var(--text-secondary,#888); border-radius:3px; flex-shrink:0; }
.me-voice-play-btn:hover { color:var(--accent,#7c6ff7); }
.me-voice-remove-btn:hover { color:#e53e3e; }
.me-voice-model-row { display:flex; align-items:center; gap:8px; flex-shrink:0; margin-bottom:8px; }
.me-voice-model-row label { font-size:12px; color:var(--text-secondary,#aaa); min-width:60px; display:inline-block; }
.me-voice-model-row select { padding:4px 6px; background:var(--input-bg,#1e1e1e); border:1px solid var(--border,#444); border-radius:4px; color:var(--text,#eee); font-size:12px; }
.me-voice-browse-link { margin-bottom:8px; flex-shrink:0; }
.me-voice-browse-link a { font-size:12px; color:var(--accent,#7c6ff7); text-decoration:none; }
.me-voice-browse-link a:hover { text-decoration:underline; }
.me-voice-provider-row { display:flex; align-items:center; gap:8px; flex-shrink:0; margin-bottom:8px; }
.me-voice-provider-row label { font-size:12px; color:var(--text-secondary,#aaa); min-width:60px; display:inline-block; }
.me-voice-provider-row select { padding:4px 6px; background:var(--input-bg,#1e1e1e); border:1px solid var(--border,#444); border-radius:4px; color:var(--text,#eee); font-size:12px; }
