:root {
  --toolbar-height: 56px;
}

body {
  margin: 0;
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.hurozo-app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1f1f1f 0%, #2d2d2d 100%);
  color: #ddd;
  font-family: 'Inter', sans-serif;
  overflow: hidden;
}

#window-hurozo-app .window-content {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  overflow: hidden;
  background: transparent;
}

.hurozo-app-shell #app-container,
.hurozo-app-shell .app-container {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.hurozo-app-shell .modal-overlay,
.hurozo-app-shell .loading-overlay,
.hurozo-app-shell #settings-section {
  position: absolute;
  inset: 0;
}

.hurozo-app-shell #load-dialog,
.hurozo-app-shell #manage-dialog,
.hurozo-app-shell #unauthorized-modal,
.hurozo-app-shell #disabled-modal,
.hurozo-app-shell #org-modal,
.hurozo-app-shell #script-modal,
.hurozo-app-shell #token-modal,
.hurozo-app-shell #reasoning-credentials-modal,
.hurozo-app-shell #admin-modal,
.hurozo-app-shell #python-modal {
  position: absolute !important;
  inset: 0;
}

#toolbar {
  position: absolute;
  top: 0;
  left: 80px;
  right: 0;
  padding: 5px 10px;
  background: rgba(30, 30, 30, 0.95);
  border-bottom: 1px solid #444;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  z-index: 20;
  font-size: 14px;
  display: flex;
  align-items: center;
  backdrop-filter: blur(4px);
  min-height: var(--toolbar-height);
}
#toolbar select, #toolbar button {
  margin-right: 8px;
}
#toolbar button {
  background: #444;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease;
}
#toolbar button:hover {
  background: #555;
}
.toolbar-icon {
  position: relative;
  width: 36px;
  height: 36px;
  margin-right: 8px;
  padding: 0;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #3a3a3a;
  border: 1px solid #565656;
  font-size: 18px;
  line-height: 1;
}
.toolbar-icon .icon {
  pointer-events: none;
}
.toolbar-icon:hover {
  background: #555;
  border-color: #6a6a6a;
}
.toolbar-icon.active {
  background: #4a5c85;
  border-color: #6f8bff;
}
#approval-tasks-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ff5f5f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);
}
#approval-tasks-btn.has-pending #approval-tasks-count {
  display: flex;
}
.agent-name {
  margin-right: 8px;
  font-style: italic;
}

#tab-bar {
  display: flex;
  align-items: center;
  margin-right: 8px;
}

#tabs {
  display: flex;
  align-items: center;
}

.tab {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: #333;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  margin-right: 4px;
}

.tab.active {
  background: #555;
}

.tab .close-tab {
  margin-left: 8px;
  cursor: pointer;
}

.tab .close-tab:hover {
  color: #f66;
}

#add-tab-btn {
  margin-right: 8px;
}
#graph-canvas {
  position: absolute;
  top: var(--toolbar-height);
  left: 0;
  width: 100%;
  height: calc(100% - var(--toolbar-height));
}

#sidebar-panel {
  position: absolute;
  top: var(--toolbar-height);
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 6px 8px;
  background: rgba(30, 30, 30, 0.95);
  border-right: 1px solid #444;
  z-index: 11;
  bottom: 0;
}

.sidebar-logo {
  line-height: 0;
}

.sidebar-logo img {
  display: block;
  width: 72px;
  height: auto;
}

#node-toolbar {
  display: grid;
  grid-template-columns: repeat(2, 32px);
  grid-auto-rows: 32px;
  gap: 4px;
  padding: 4px;
}

/* Flyout submenu shown to the right of the node toolbar */
.toolbar-flyout {
  position: absolute;
  background: rgba(30, 30, 30, 0.98);
  border: 1px solid #444;
  border-radius: 6px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(4, 32px);
  grid-auto-rows: 32px;
  gap: 4px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
  z-index: 1000;
}

#node-toolbar button {
  width: 32px;
  height: 32px;
  background: #444;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#node-toolbar button.active {
  background: #666;
}

#node-toolbar.drop-target {
  outline: 2px dashed #7af;
  cursor: copy;
}

#node-toolbar .pinned-btn {
  position: relative;
  font-size: 18px;
  cursor: grab;
}
#node-toolbar .pinned-btn:active {
  cursor: grabbing;
}
#node-toolbar .pinned-btn .emoji {
  line-height: 32px;
}
#node-toolbar .pinned-btn .monogram {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 9px;
  padding: 0 2px;
  border-radius: 2px;
  pointer-events: none;
}
#node-toolbar .dock-placeholder {
  width: 32px;
  height: 32px;
  border: 2px dashed #7af;
  border-radius: 4px;
}
#node-toolbar .color-btn {
  border: 1px solid #222;
}
#colors-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
#colors-menu-btn .fill-icon {
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none;
}
#node-toolbar .shape-btn {
  border: 1px solid #222;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
#node-toolbar .shape-btn canvas {
  width: 20px;
  height: 20px;
  pointer-events: none;
}
/* Shapes menu icon in the toolbar */
#shapes-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
#shapes-menu-btn .shapes-icon {
  width: 22px;
  height: 22px;
  pointer-events: none;
  display: block;
}
/* Shapes flyout buttons: dark background, centered icon */
.toolbar-flyout .shape-btn {
  width: 32px;
  height: 32px;
  background: #2b2b2b;
  border: 1px solid #222;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.toolbar-flyout .shape-btn:hover {
  background: #333;
}
.toolbar-flyout .shape-btn canvas {
  width: 20px;
  height: 20px;
}
.toolbar-flyout .color-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #222;
  border-radius: 4px;
}
/* Collapsible output panel */
#output-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  max-height: 80%;
  background: #111;
  color: #0f0;
  margin: 0;
  overflow: hidden;
  font-family: monospace;
  display: none;
  flex-direction: column;
  z-index: 200;
}
#output-container.collapsed {
  height: 24px;
}
#output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  user-select: none;
  cursor: ns-resize;
}
#output-header button {
  cursor: pointer;
}
#output-container.collapsed pre {
  display: none;
}
#output {
  margin: 0;
  padding: 10px;
  overflow: auto;
  flex: 1;
}
#toggle-output-btn {
  background: none;
  border: none;
  color: #0f0;
  cursor: pointer;
}

/* Org/Admin compact controls */
#org-admin-toggle {
  background: #3a3a3a;
  border: 1px solid #4a4a4a;
  border-radius: 6px;
  line-height: 1;
}
.org-admin-group select {
  max-width: 220px;
}
.org-admin-group button {
  margin-right: 0;
}

/* Manage agents dialog */
#manage-agent-list li {
  margin-bottom: 0.5em;
}

#manage-dialog button {
  background: #444;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease;
}

#manage-dialog button:hover {
  background: #555;
}

/* Agent settings dialog */
#agent-settings-dialog .dialog-content {
  background: #232323;
  color: #eee;
  padding: 2em;
  border-radius: 12px;
  min-width: 300px;
  max-width: 80vw;
}

#agent-settings-dialog ul {
  list-style: none;
  padding: 0;
  margin-top: 1em;
  max-height: 300px;
  overflow-y: auto;
}

#agent-settings-dialog .share-controls {
  margin-top: 1em;
  display: flex;
  gap: 0.5em;
  align-items: center;
}

#agent-settings-dialog .share-controls .login-input {
  flex: 1;
  width: auto;
  margin-bottom: 0;
}

#agent-settings-dialog .share-secrets-label {
  display: flex;
  align-items: center;
  gap: 0.25em;
}

#agent-settings-dialog .share-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5em;
}

#agent-settings-dialog textarea {
  width: 100%;
  background: #1e1e1e;
  color: #eee;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 0.5em;
  margin-top: 1em;
  min-height: 80px;
}

#agent-settings-dialog .share-actions {
  display: flex;
  gap: 0.5em;
  align-items: center;
}

#agent-settings-dialog button {
  background: #444;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease;
}

#agent-settings-dialog button:hover {
  background: #555;
}

/* Emoji picker */
.emoji-picker {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #1e1e1e;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 0.5em;
  margin-top: 0.25em;
  z-index: 100000;
  box-shadow: 0 10px 24px rgba(0,0,0,0.5);
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding: 0.25em;
}
.emoji-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 20px;
  background: #2b2b2b;
  border: 1px solid #3a3a3a;
}
.emoji-cell:hover { background: #3a3a3a; }

/* Collapsible input panel */
#input-panel {
  position: absolute;
  top: 40px;
  right: 0;
  height: calc(100% - 40px);
  width: 300px;
  background: #111;
  color: #eee;
  border-left: 1px solid #444;
  display: flex;
  flex-direction: column;
  transition: width 0.2s;
}

#input-panel.collapsed {
  width: 24px;
}

#input-panel.collapsed #input-fields,
#input-panel.collapsed #input-header span {
  display: none;
}

#input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px;
  background: #222;
}

#input-fields {
  flex: 1;
  overflow: auto;
  padding: 10px;
}

#input-fields .input-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}

#input-fields .input-row input {
  padding: 4px;
  border: 1px solid #555;
  border-radius: 4px;
}

#input-fields .input-row input.missing {
  border-color: #e55;
}

#toggle-input-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
}

#load-dialog li {
  padding: 0.5em;
  cursor: pointer;
  border-bottom: 1px solid #444;
}

#load-dialog li:hover {
  background: #444;
}

.login-box {
  background: #1e1e1e;
  padding: 2.5rem 2rem;
  border-radius: 1rem;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  text-align: center;
  max-width: 400px;
  width: 100%;
  animation: fadeInUp 0.5s ease;
}
.login-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: #fff;
  font-weight: 700;
  letter-spacing: 1px;
}
.login-subtitle {
  font-size: 1rem;
  color: #aaa;
  margin-bottom: 1.5rem;
}
.login-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background-color: #2b2b2b;
  color: #f1f1f1;
  border: 1px solid #444;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.login-input::placeholder {
  color: #888;
}
.login-input:focus {
  border-color: #5c7cfa;
  outline: none;
}
.login-button {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background: #5c7cfa;
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.2s ease;
}
.login-button:hover {
  background: #4c6ef5;
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

html, body {
  height: 100%;
}

#login-section {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #232526 0%, #414345 100%);
}
.login-wrapper {
  height: 100%;
}

#settings-section {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  color: #ddd;
}
.settings-box {
  background: #1e1e1e;
  padding: 2rem;
  border-radius: 1rem;
  max-width: 500px;
  width: 90%;
  text-align: left;
}
.settings-box h2, .settings-box h3 {
  text-align: center;
  margin: 0 0 1rem;
}
#secrets-list,
#agent-secrets-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}
#secrets-list li,
#agent-secrets-list li {
  margin: 0.5rem 0;
}
#secrets-list .secret-name,
#agent-secrets-list .secret-name {
  font-weight: bold;
}
#secrets-list .secret-value,
#agent-secrets-list .secret-value {
  margin-left: 0.5rem;
  letter-spacing: 0.1em;
}
#secrets-list .remove-secret-btn,
#agent-secrets-list .remove-secret-btn {
  margin-left: 1rem;
  background: #e55;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
}
#secrets-list .remove-secret-btn:hover,
#agent-secrets-list .remove-secret-btn:hover {
  background: #c44;
}
#secret-name, #secret-value,
#agent-secret-name, #agent-secret-value {
  width: 40%;
  margin-bottom: 0.5rem;
  margin-right: 0.5rem;
}
#secret-value,
#agent-secret-value {
  width: 50%;
}

#agent-variables-list li {
  margin: 0.5rem 0;
}
#agent-variables-list .variable-name {
  font-weight: bold;
}
#agent-variables-list .variable-value {
  margin-left: 0.5rem;
}
#agent-variables-list .remove-variable-btn {
  margin-left: 1rem;
  background: #e55;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
}
#agent-variables-list .remove-variable-btn:hover {
  background: #c44;
}
#variable-name, #variable-value {
  width: 40%;
  margin-bottom: 0.5rem;
  margin-right: 0.5rem;
}
#variable-value {
  width: 50%;
}
#tokens-list,
#agent-tokens-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}
#tokens-list li,
#agent-tokens-list li {
  margin: 0.5rem 0;
}
#tokens-list .token-name,
#agent-tokens-list .token-name {
  font-weight: bold;
}
.remove-token-btn, .toggle-token-btn, .rename-token-btn {
  margin-left: 0.5rem;
  border: none;
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
}
.remove-token-btn {
  background: #e55;
  color: #fff;
}
.remove-token-btn:hover {
  background: #c44;
}
.toggle-token-btn, .rename-token-btn {
  background: #5c7cfa;
  color: #fff;
}
.toggle-token-btn:hover, .rename-token-btn:hover {
  background: #4c6ef5;
}
#token-name, #agent-token-name {
  margin-bottom: 0.5rem;
  margin-right: 0.5rem;
}
#token-name,
#agent-token-name {
  width: 60%;
}
#add-secret-btn, #add-token-btn {
  padding: 0.5rem 1rem;
  background: #5c7cfa;
  color: #fff;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
}
#add-secret-btn:hover, #add-token-btn:hover {
  background: #4c6ef5;
}
.reasoning-credentials-actions {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
#set-reasoning-credentials-btn,
#refresh-reasoning-credentials-btn {
  padding: 0.5rem 1rem;
  background: #5c7cfa;
  color: #fff;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: background 0.2s ease;
}
#set-reasoning-credentials-btn:hover,
#refresh-reasoning-credentials-btn:not([disabled]):hover {
  background: #4c6ef5;
}
#refresh-reasoning-credentials-btn[disabled] {
  background: #2f2f2f;
  color: #8c8c8c;
  cursor: not-allowed;
}
#close-settings-btn {
  margin-top: 1rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: #5c7cfa;
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  cursor: pointer;
}
#close-settings-btn:hover {
  background: #4c6ef5;
}

.hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100000;
}

.modal-content {
  background: #232323;
  color: #f2f2f2;
  border-radius: 14px;
  padding: 1.5rem;
  width: min(560px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-secondary-btn,
.modal-close-btn {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.modal-secondary-btn {
  padding: 0.45rem 0.85rem;
  background: #4c6ef5;
  color: #fff;
  font-weight: 600;
}

.modal-secondary-btn:hover {
  background: #3b5bdb;
}

.modal-close-btn {
  padding: 0.25rem 0.5rem;
  background: transparent;
  color: #bbb;
  font-size: 1.2rem;
  line-height: 1;
}

.modal-close-btn:hover {
  color: #fff;
  background: #3a3a3a;
}

.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.chat-window {
  width: min(520px, 92vw);
  max-height: min(620px, 86vh);
  background: #1f1f1f;
  color: #f3f3f3;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-window-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.15rem;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: grab;
}

.chat-window-titlebar:active {
  cursor: grabbing;
}

.chat-window-title-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.chat-window-icon {
  font-size: 1.35rem;
}

.chat-window-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.chat-window-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chat-window-action {
  padding: 0.35rem 0.7rem;
  background: rgba(31, 31, 31, 0.9);
  color: #e8e8e8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.chat-window-action:hover,
.chat-window-action:focus-visible {
  background: rgba(55, 55, 55, 0.95);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.chat-window-action[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-window-body {
  flex: 1 1 auto;
  padding: 1rem 1.2rem 0.75rem;
  overflow-y: auto;
}

.chat-window-history {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: calc(100% - 0.5rem);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.chat-bubble {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 18px;
  line-height: 1.45;
  font-size: 0.95rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  background: #2f2f37;
  color: #f2f4ff;
  white-space: pre-wrap;
  word-break: break-word;
  align-self: flex-start;
}

.chat-bubble.assistant {
  border-top-left-radius: 6px;
}

.chat-bubble.user {
  background: #4c6ef5;
  color: #fff;
  align-self: flex-end;
  border-top-right-radius: 6px;
}

.chat-bubble.error {
  background: #7a1c1c;
  color: #ffe3e3;
}

.chat-bubble.pending {
  opacity: 0.8;
  font-style: italic;
}

.chat-window-input-area {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  padding: 0.85rem 1.2rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 15, 15, 0.9);
}

.chat-window-input {
  flex: 1 1 auto;
  min-height: 2.75rem;
  max-height: 9rem;
  padding: 0.75rem 0.9rem;
  background: #1d1d24;
  border: 1px solid #363649;
  border-radius: 12px;
  color: #f2f4ff;
  font-size: 0.95rem;
  line-height: 1.4;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-window-input:focus {
  outline: none;
  border-color: #4c6ef5;
  box-shadow: 0 0 0 2px rgba(76, 110, 245, 0.25);
}

.chat-window-send {
  align-self: center;
  min-width: 5.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  background: #4c6ef5;
  color: #fff;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.chat-window-send:hover {
  background: #3b5bdb;
}

.chat-window-send:disabled {
  background: rgba(76, 110, 245, 0.4);
  cursor: not-allowed;
}

.empty-state {
  margin: 0;
  padding: 2rem 0;
  text-align: center;
  color: #b5b5b5;
}

.approval-task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.approval-task {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #363636;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.approval-task.expiring {
  border-color: #f97316;
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.25);
}

.approval-task-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.approval-task-description {
  margin: 0;
  color: #d1d1d1;
  line-height: 1.45;
}

.approval-task-meta {
  font-size: 0.85rem;
  color: #9da3b0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.approval-task-node {
  font-size: 0.85rem;
  color: #b3c5ff;
}

.approval-task-actions {
  display: flex;
  justify-content: flex-end;
}

.approval-task-open-btn {
  background: #5c7cfa;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.approval-task-open-btn:hover {
  background: #4c6ef5;
}

.dropdown {
  position: relative;
  margin-right: 8px;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #333;
  padding: 5px;
  border-radius: 4px;
  display: none;
  max-height: 300px;
  overflow: auto;
  z-index: 1000;
}

.submenu-container {
  position: relative;
  white-space: nowrap;
}

.submenu-arrow {
  margin-right: 4px;
}

.dropdown-submenu {
  position: absolute;
  top: 0;
  left: 100%;
  background: #333;
  padding: 5px;
  border-radius: 4px;
  max-height: 300px;
  overflow: auto;
  z-index: 1100; /* above parent menu */
}

#org-submenu {
  left: auto;
  right: 100%;
}

#org-submenu div {
  padding: 3px 0;
  cursor: pointer;
}

#org-submenu div:hover {
  background: #444;
  text-decoration: underline;
}
#org-submenu div.active {
  font-weight: 600;
}
#saved-agents-menu .menu-separator {
  height: 1px;
  margin: 6px 0;
  background: #444;
}
#saved-agents-menu .menu-heading {
  font-weight: 600;
  font-size: 12px;
  color: #ddd;
  background: #3a3a3a;
  padding: 3px 4px;
  border-radius: 3px;
  margin-bottom: 4px;
}
#agents-dropdown-menu {
  white-space: nowrap;
  width: max-content;
  min-width: 100%;
}

#agents-dropdown-menu div {
  padding: 3px 0;
  cursor: pointer;
}

#agents-dropdown-menu div:hover {
  background: #444;
  text-decoration: underline;
}
#user-dropdown-menu {
  left: auto;
  right: 0;
  /* Allow the org submenu to overflow to the left without being clipped */
  overflow: visible;
}
#user-dropdown-menu div {
  padding: 3px 0;
  cursor: pointer;
}

#user-dropdown-menu div:hover {
  background: #444;
  text-decoration: underline;
}
.category {
  font-weight: bold;
  margin: 5px 0;
  cursor: pointer;
  position: relative;
  padding-left: 15px;
}
.category::before {
  content: "\25B6";
  position: absolute;
  left: 0;
  display: inline-block;
  transition: transform 0.2s;
}
.category.open::before {
  transform: rotate(90deg);
}
.subcategory {
  margin-left: 15px;
  display: none;
}
.category.open > .subcategory {
  display: block;
}
.node-item {
  padding: 3px 0;
  cursor: pointer;
}
.node-item:hover {
  text-decoration: underline;
}

/* Node palette search */
#node-dropdown-menu .node-search-wrap {
  padding: 0.5em 0.75em;
  border-bottom: 1px solid #3a3a3a;
  background: rgba(30, 30, 30, 0.96);
  position: sticky;
  top: 0;
  z-index: 2;
}

#node-search-input {
  width: 100%;
  padding: 0.4em 0.6em;
  border-radius: 6px;
  border: 1px solid #555;
  background: #1a1a1a;
  color: #eee;
  font-size: 0.9em;
}

#node-search-input:focus {
  outline: none;
  border-color: #3a86ff;
  box-shadow: 0 0 0 2px rgba(58, 134, 255, 0.25);
}

#node-search-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 0.5em;
}

.node-search-empty {
  padding: 0.5em 0.25em;
  color: #aaa;
  font-style: italic;
}

#node-search-results .node-item {
  padding: 0.35em 0.25em;
  border-radius: 4px;
}

#node-search-results .node-item:hover {
  text-decoration: none;
  background: rgba(80, 80, 80, 0.5);
}

/* Tutorial overlay */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5000;
}

.tutorial-overlay.hidden {
  display: none;
}

.tutorial-panel {
  pointer-events: auto;
  position: absolute;
  top: 90px;
  right: 24px;
  width: 320px;
  max-height: calc(100% - 140px);
  display: flex;
  flex-direction: column;
  gap: 1em;
  background: rgba(20, 20, 20, 0.96);
  border: 1px solid rgba(90, 90, 90, 0.7);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}

.tutorial-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75em;
}

.tutorial-header-text h2 {
  margin: 0;
  font-size: 1.1em;
}

.tutorial-header-text span {
  display: block;
  font-size: 0.75em;
  color: #9aa0aa;
  margin-top: 0.2em;
}

.tutorial-header button {
  background: #444;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 0.35em 0.9em;
  cursor: pointer;
  font-size: 0.85em;
}

.tutorial-header button:hover {
  background: #575757;
}

.tutorial-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1em;
}

.tutorial-step-copy h3 {
  margin: 0 0 0.4em;
  font-size: 1em;
  color: #e5e9f0;
}

.tutorial-step-copy p {
  margin: 0 0 0.6em;
  font-size: 0.9em;
  color: #cfd3dc;
  line-height: 1.4;
}

.tutorial-hint {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.tutorial-hint button {
  align-self: flex-start;
  background: none;
  border: none;
  color: #8ab4ff;
  cursor: pointer;
  padding: 0;
  font-size: 0.85em;
}

.tutorial-hint button:hover {
  text-decoration: underline;
}

.tutorial-hint p {
  margin: 0;
  font-size: 0.85em;
  color: #9aa0aa;
  line-height: 1.4;
}

#tutorial-progress-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35em;
}

.tutorial-progress-item {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.35em 0.45em;
  border-radius: 6px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  font-size: 0.85em;
  color: #d0d5e0;
  transition: background 0.2s ease, border 0.2s ease;
}

.tutorial-progress-item:hover {
  background: rgba(148, 163, 184, 0.07);
}

.tutorial-progress-item.active {
  border-color: rgba(138, 180, 255, 0.55);
  background: rgba(138, 180, 255, 0.12);
}

.tutorial-progress-item.done::before {
  content: "✔";
  color: #8fce84;
  font-size: 0.85em;
}

.tutorial-progress-item.skipped::before {
  content: "⏭";
  color: #ffad66;
  font-size: 0.9em;
}

.tutorial-progress-label-item {
  flex: 1;
}

.tutorial-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.5em;
}

.tutorial-footer button {
  flex: 1;
  padding: 0.5em 0.75em;
  border-radius: 6px;
  border: none;
  background: #3a3a3a;
  color: #fff;
  cursor: pointer;
  font-size: 0.9em;
}

.tutorial-footer button:hover:not(:disabled) {
  background: #4a4a4a;
}

.tutorial-footer button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Loading overlay */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 1em;
  font-size: 1.2em;
  color: #333;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 8px solid #ccc;
  border-top-color: #3a86ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 100000;
}

.toast.show {
  opacity: 1;
}

/* Admin modal styling */
#admin-user-list {
  margin-top: 0.25rem;
}
#admin-user-list li.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #2e2e2e;
}
#admin-user-list li.admin-user-row:last-child {
  border-bottom: none;
}
#admin-user-list .admin-user-info {
  color: #ddd;
}
#admin-user-list .admin-user-actions .btn {
  background: #444;
  color: #fff;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
  margin-left: 0.5rem;
}
#admin-user-list .admin-user-actions .btn:hover {
  background: #555;
}
#admin-user-list .admin-user-actions .btn-impersonate {
  background: #5c7cfa;
}
#admin-user-list .admin-user-actions .btn-impersonate:hover {
  background: #4c6ef5;
}
#admin-user-list .admin-user-actions .btn-danger {
  background: #e55;
}
#admin-user-list .admin-user-actions .btn-danger:hover {
  background: #c44;
}

#quota-info {
  margin-bottom: 1rem;
}

/* Zoom controls (bottom-right) */
.zoom-controls {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}
.zoom-controls .zoom-btn {
  min-width: 44px;
  height: 36px;
  padding: 0 10px;
  background: rgba(40, 40, 40, 0.95);
  color: #eee;
  border: 1px solid #444;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}
.zoom-controls .zoom-btn:hover {
  background: #3a3a3a;
}

.app-version-badge {
  position: fixed;
  left: 16px;
  bottom: 16px;
  padding: 6px 14px;
  border-radius: 8px;
  background: rgba(24, 24, 24, 0.85);
  color: #a7a7a7;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
}

.app-version-badge[hidden] {
  display: none;
}

#waitinglist-screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(12, 12, 16, 0.92);
  z-index: 100000;
}

.waitinglist-panel {
  max-width: 480px;
  width: 100%;
  text-align: left;
}

.waitinglist-panel textarea {
  min-height: 140px;
  resize: vertical;
}

.waitinglist-label {
  display: block;
  font-size: 0.95em;
  font-weight: 600;
  margin: 0.75em 0 0.35em;
}

.waitinglist-panel .login-button {
  width: 100%;
}

.waitinglist-status {
  font-size: 0.9em;
  color: #a7b4d1;
}

.brain-window-host {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 950;
}

.brain-window {
  position: fixed;
  top: clamp(2rem, 12vh, 10rem);
  left: clamp(2rem, 20vw, 24rem);
  min-width: 320px;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  transition: box-shadow 0.2s ease;
}

.brain-window:focus-within,
.brain-window.active {
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.brain-window.minimized {
  display: none;
}

.account-brain-window {
  position: fixed;
  display: flex;
  flex-direction: column;
  width: min(960px, 95vw);
  height: min(640px, 85vh);
  background: #1f1f1f;
  color: #f3f3f3;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.account-brain-window.dragging {
  cursor: grabbing;
}

.account-brain-window.dragging .account-brain-titlebar {
  cursor: grabbing;
}

.account-brain-titlebar {
  cursor: grab;
}

.account-brain-titlebar:active {
  cursor: grabbing;
}

.account-brain-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, rgba(82, 82, 82, 0.4), rgba(35, 35, 35, 0.8));
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.account-brain-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.account-brain-icon {
  font-size: 1.25rem;
}

.account-brain-titlebar h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.account-brain-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.account-brain-sync {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: rgba(243, 243, 243, 0.82);
}

.account-brain-sync-spinner {
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid rgba(243, 243, 243, 0.2);
  border-top-color: rgba(243, 243, 243, 0.85);
  border-radius: 999px;
  animation: account-brain-sync-spin 0.8s linear infinite;
}

.account-brain-sync-text {
  letter-spacing: 0.01em;
}

@keyframes account-brain-sync-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.account-brain-actions {
  display: flex;
  gap: 0.5rem;
}

.account-brain-action {
  background: rgba(255, 255, 255, 0.08);
  color: #f3f3f3;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.account-brain-action:hover,
.account-brain-action:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.18);
}

.account-brain-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.account-brain-sidebar {
  width: 240px;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(28, 28, 28, 0.95);
  padding: 0.75rem;
  overflow-y: auto;
}

.account-brain-tree {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.account-brain-tree-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.account-brain-tree-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  color: #e8e8e8;
  font-size: 0.9rem;
  user-select: none;
}

.account-brain-tree-label:hover,
.account-brain-tree-label:focus-visible {
  background: rgba(95, 95, 95, 0.25);
}

.account-brain-tree-label.active {
  background: rgba(126, 175, 255, 0.25);
  color: #fff;
}

.account-brain-tree-label.drop-target {
  border: 1px dashed rgba(126, 175, 255, 0.6);
  background: rgba(126, 175, 255, 0.18);
}

.account-brain-tree ul {
  list-style: none;
  margin: 0 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.account-brain-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem 1rem;
  min-width: 0;
  gap: 0.75rem;
}

.account-brain-dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  color: rgba(240, 240, 240, 0.85);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.account-brain-dropzone:focus-visible {
  outline: 2px solid #7ea7ff;
  outline-offset: 2px;
}

.account-brain-dropzone.dragging {
  border-color: rgba(126, 167, 255, 0.9);
  background: rgba(126, 167, 255, 0.1);
}

.account-brain-drop-text {
  margin: 0;
  font-size: 0.95rem;
}

.account-brain-status {
  font-size: 0.9rem;
  color: rgba(235, 235, 235, 0.75);
  padding: 0.5rem 0.25rem;
  min-height: 1.5rem;
}

.account-brain-list {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  background: rgba(22, 22, 22, 0.9);
  overflow-y: auto;
  padding: 0.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
}

.account-brain-entry {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(38, 38, 38, 0.9);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.account-brain-entry.drop-target {
  border: 1px dashed rgba(126, 175, 255, 0.6);
  background: rgba(126, 175, 255, 0.15);
}

.account-brain-entry:hover,
.account-brain-entry:focus-visible {
  border-color: rgba(126, 167, 255, 0.65);
  background: rgba(58, 58, 58, 0.95);
  transform: translateY(-2px);
}

.account-brain-entry-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.account-brain-entry-icon {
  font-size: 1.4rem;
}

.account-brain-entry-name {
  flex: 1;
  font-size: 0.95rem;
  word-break: break-word;
}

.account-brain-entry-actions {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
}

.account-brain-entry-button {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #f3f3f3;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.account-brain-entry-button:hover,
.account-brain-entry-button:focus-visible {
  background: rgba(255, 255, 255, 0.22);
}

.account-brain-download {
  background: rgba(126, 167, 255, 0.18);
  color: #dce7ff;
}

.account-brain-download:hover,
.account-brain-download:focus-visible {
  background: rgba(126, 167, 255, 0.3);
}

.account-brain-delete {
  background: rgba(255, 102, 102, 0.2);
  color: #ffd6d6;
}

.account-brain-delete:hover,
.account-brain-delete:focus-visible {
  background: rgba(255, 102, 102, 0.32);
}

.account-brain-entry.folder {
  cursor: pointer;
}

.account-brain-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: rgba(235, 235, 235, 0.7);
  padding: 2rem 1rem;
  font-size: 0.95rem;
}

.account-brain-processing {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(2px);
  z-index: 15;
}

.account-brain-processing:not(.hidden) {
  display: flex;
}

.account-brain-processing-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(30, 30, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.85rem 1.25rem;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}

.account-brain-processing-spinner {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(126, 167, 255, 0.9);
  animation: account-brain-spinner 0.9s linear infinite;
}

.account-brain-processing-text {
  font-size: 0.95rem;
  color: rgba(235, 235, 235, 0.9);
}

@keyframes account-brain-spinner {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .brain-window {
    top: 1.5rem;
    left: 0.5rem;
    right: 0.5rem;
  }
  .account-brain-window {
    width: calc(100vw - 1rem);
    height: calc(100vh - 4rem);
  }
  .account-brain-sidebar {
    display: none;
  }
  .account-brain-main {
    padding: 1rem;
  }
  .account-brain-list {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
  .brain-window-tray {
    bottom: 0.5rem;
  }
}
.brain-window-tray {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 960;
}

.brain-window-tray.hidden {
  display: none;
}

.brain-window-tray button {
  pointer-events: auto;
  background: rgba(31, 31, 31, 0.88);
  color: #f3f3f3;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.brain-window-tray button:hover,
.brain-window-tray button:focus-visible {
  background: rgba(55, 55, 55, 0.95);
  border-color: rgba(255, 255, 255, 0.18);
}
