* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #06080f;
  color: #f9fafb;
  overflow: hidden;
}

body.config-open {
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 100vh;
}

/* ── Page-load entrance animation ─────────────────────── */

.app:not(.is-ready) {
  opacity: 0;
}

.app:not(.is-ready) .app-main {
  transition: none !important;
}

.app.is-ready {
  animation: entrance-fade 0.36s ease both;
}

@keyframes entrance-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes reveal-up {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: row;
  height: 100vh;
  position: relative;
  margin-left: 280px;
  margin-right: 56px;
  transition: margin-left 0.25s ease;
}

.app-sidebar.is-collapsed ~ .app-main {
  margin-left: 62px;
}

/* ── Split title bars (one per pane) ────────────────────── */

.split-titlebar {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  background: #080d1a;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  gap: 10px;
  user-select: none;
}

.split-titlebar-path {
  font-size: 12px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.split-titlebar-ws {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.split-titlebar-ws.is-hidden {
  display: none;
}

.split-titlebar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── App titlebar: active app header ─────────────────── */

.split-titlebar-app-icon {
  flex-shrink: 0;
}

.split-titlebar-app-icon img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  border-radius: 4px;
  display: block;
}

.split-titlebar-app-icon .app-icon-letter {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.15);
  border-radius: 4px;
  color: #818cf8;
}

.split-titlebar-app-name {
  font-size: 11.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.split-titlebar-close {
  border: 0;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.4);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
  transition: background 0.18s, color 0.18s;
}

.split-titlebar-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.split-titlebar-close.is-hidden {
  display: none;
}

body.is-resizing-tab {
  user-select: none;
}
body.is-resizing-tab.is-resizing-h { cursor: col-resize; }
body.is-resizing-tab.is-resizing-v { cursor: row-resize; }

body.is-resizing-tab .tab-panel,
body.is-resizing-tab .tab-panel.is-open,
body.is-resizing-tab .zone-top,
body.is-resizing-tab .zone-bottom {
  transition: none !important;
}

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

.zone-top,
.zone-bottom {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  flex: 0 0 0%;
  transition: opacity 0.2s ease;
}

.zone-top {
  flex-direction: row;
}

.zone-bottom {
  flex-direction: column;
}

.zone-top.has-panel,
.zone-bottom.has-panel {
  flex: 1 1 0%;
}

.zone-top.has-panel ~ .tab-resizer--v ~ .zone-bottom.has-panel {
  flex: 0 0 35%;
}

/* ── Tab Panel System ─────────────────────────────────── */

.tab-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  flex: 0 0 0%;
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
  position: relative;
  transition:
    opacity   0.2s ease,
    transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-panel.is-open {
  flex: 1 1 0%;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.tab-titlebar {
  height: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: #080d1a;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 11.5px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.02em;
  user-select: none;
  transition: opacity 0.2s;
}

/* Space panel background — matches canvas tone (#060810 → #0a0c18) with slight shift */
.tab-panel--space {
  background:
    radial-gradient(ellipse at 20% 15%, rgba(58, 32, 98, 0.04), transparent 48%),
    radial-gradient(ellipse at 80% 80%, rgba(24, 62, 88, 0.03), transparent 44%),
    linear-gradient(150deg, #060810 0%, #07091a 45%, #090b16 100%);
}

/* Chat panel atmospheric background + subtle grid */
.tab-panel--chat {
  background:
    radial-gradient(ellipse at 30% 0%, rgba(99, 102, 241, 0.04), transparent 50%),
    radial-gradient(ellipse at 70% 100%, rgba(30, 58, 95, 0.04), transparent 45%),
    linear-gradient(180deg, #05070e 0%, #070a16 50%, #080c18 100%);
  position: relative;
}

.tab-panel--chat::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image:
    linear-gradient(rgba(99,102,241,0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.3) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at 50% 60%, black 5%, transparent 65%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 60%, black 5%, transparent 65%);
  z-index: 0;
}

.tab-panel--chat > * {
  position: relative;
  z-index: 1;
}

/* When chat is the only open panel, titlebar blends into the background */
.tab-panel--chat.is-solo .tab-titlebar {
  background: transparent;
  border-bottom-color: transparent;
}

.tab-panel--chat.is-solo .tab-titlebar-label {
  color: rgba(255,255,255,0.12);
}

.tab-panel--chat.is-solo .tab-path-prompt {
  color: rgba(99, 102, 241, 0.25);
}

.tab-panel--chat.is-solo .tab-path-cwd {
  color: rgba(255,255,255,0.08);
}

.tab-panel--chat.is-solo .tab-path-sep {
  color: rgba(255,255,255,0.06);
}

.tab-titlebar-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
}

.tab-titlebar-label.is-path {
  color: rgba(255,255,255,0.3);
  font-weight: 400;
  letter-spacing: 0.03em;
}

.tab-path-prompt {
  color: rgba(99, 102, 241, 0.6);
  font-weight: 600;
  margin-right: 2px;
}

.tab-path-cwd {
  color: rgba(255,255,255,0.2);
}

.tab-path-sep {
  color: rgba(255,255,255,0.12);
  margin: 0 1px;
}

/* Active session title in the path bar */
.tab-titlebar-label:not(.is-path) {
  color: rgba(255,255,255,0.45);
}

.tab-titlebar-label:not(.is-path) .tab-path-prompt {
  color: rgba(99, 102, 241, 0.5);
}

.tab-titlebar-label:not(.is-path) .tab-path-cwd {
  color: rgba(255,255,255,0.18);
}

.tab-titlebar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.tab-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.tab-close-btn:hover {
  background: rgba(248, 81, 73, 0.1);
  color: #f85149;
}

.tab-panel--chat.is-solo .tab-close-btn {
  opacity: 0;
  pointer-events: none;
}

/* tab-resizer: only visible between two adjacent open panels */
.tab-resizer {
  display: none;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.tab-resizer.is-visible {
  display: block;
}

/* Horizontal resizer (vertical bar between side-by-side panels) */
.tab-resizer--h {
  width: 1px;
  cursor: col-resize;
  background: rgba(255,255,255,0.07);
}

.tab-resizer--h::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: -4px;
  width: 9px;
  z-index: 1;
}

.tab-resizer--h::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 1px;
  background: transparent;
  transition: background 0.15s, box-shadow 0.15s;
}

.tab-resizer--h:hover::after,
.tab-resizer--h.is-dragging::after {
  background: #818cf8;
  box-shadow: 0 0 8px rgba(129, 140, 248, 0.4);
}

/* Vertical resizer (horizontal bar between top and bottom zones) */
.tab-resizer--v {
  height: 1px;
  cursor: row-resize;
  background: rgba(255,255,255,0.07);
}

.tab-resizer--v::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: -4px;
  height: 9px;
  z-index: 1;
}

.tab-resizer--v::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 1px;
  background: transparent;
  transition: background 0.15s, box-shadow 0.15s;
}

.tab-resizer--v:hover::after,
.tab-resizer--v.is-dragging::after {
  background: #818cf8;
  box-shadow: 0 0 8px rgba(129, 140, 248, 0.4);
}

.chat-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.space-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Space back button ─────────────────────────────── */

.space-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  margin-right: 4px;
}
.space-back-btn:hover {
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.06);
}
.space-back-btn.is-hidden { display: none; }

/* ── Space listing view ────────────────────────────── */

.space-listing {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 28px 32px;
  overflow-y: auto;
  scrollbar-width: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.space-listing::-webkit-scrollbar { display: none; }
.space-listing.is-hidden { display: none; }
#space-canvas-wrap.is-hidden { display: none; }

/* ── Template cards ──────────────────────────────── */

.ws-templates-section { margin-bottom: 24px; flex-shrink: 0; }

.ws-section-label {
  margin: 0 0 8px;
  font-size: 10.5px;
  font-weight: 500;
  color: #4a5568;
  letter-spacing: 0.02em;
}

.ws-templates-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.ws-tpl-group { display: flex; flex-direction: column; }
.ws-tpl-group--templates { flex: 1; min-width: 0; }
.ws-tpl-group-cards { display: flex; gap: 10px; flex-wrap: wrap; }

.ws-tpl {
  display: flex;
  flex-direction: column;
  width: 240px;
  padding: 14px 16px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  position: relative;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  text-align: left;
}

.ws-tpl-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.ws-tpl-icon {
  flex-shrink: 0;
  color: #475569;
  transition: color 0.15s;
}

.ws-tpl-name {
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
}

.ws-tpl-desc {
  font-size: 11.5px;
  color: #4a5568;
  line-height: 1.45;
  text-align: left;
}

.ws-tpl-badge {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  color: #334155;
  margin-left: auto;
}

/* New workspace card */
.ws-tpl--new {
  cursor: pointer;
  border-color: rgba(99, 102, 241, 0.18);
  background: rgba(99, 102, 241, 0.05);
}
.ws-tpl--new .ws-tpl-icon { color: #6366f1; }
.ws-tpl--new .ws-tpl-name { color: #a5b4fc; }
.ws-tpl--new .ws-tpl-desc { color: #6366f1; opacity: 0.5; }
.ws-tpl--new:hover {
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.1);
}
.ws-tpl--new:hover .ws-tpl-icon { color: #818cf8; }
.ws-tpl--new:active { transform: scale(0.98); }

/* Placeholder templates */
.ws-tpl--soon {
  cursor: default;
  opacity: 0.35;
}
.ws-tpl--soon:hover {
  transform: none;
  box-shadow: none;
}

/* ── Recent section ──────────────────────────────────── */

.ws-recent-section { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ws-section-title kept for compat, uses ws-section-label now */

.ws-explorer-header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.02);
}

.ws-col {
  font-size: 10.5px;
  font-weight: 500;
  color: #4a5568;
  user-select: none;
}
.ws-col--icon { width: 36px; flex-shrink: 0; }
.ws-col--name { flex: 1; min-width: 0; }
.ws-col--status { width: 120px; flex-shrink: 0; }
.ws-col--actions { width: 180px; flex-shrink: 0; text-align: right; }

.ws-explorer-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #1e293b transparent;
}
.ws-explorer-body::-webkit-scrollbar { width: 4px; }
.ws-explorer-body::-webkit-scrollbar-track { background: transparent; }
.ws-explorer-body::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 2px; }

.ws-explorer-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 40px 20px;
  text-align: center;
}
.ws-explorer-empty-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  color: #192030;
  margin-bottom: 4px;
}
.ws-explorer-empty-text { font-size: 13px; font-weight: 500; color: #283040; }
.ws-explorer-empty-sub { font-size: 11px; color: #334155; }

/* ── Workspace row ───────────────────────────────────── */

.workspace-row {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 44px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.015);
}
.workspace-row:hover { background: rgba(255, 255, 255, 0.04); }
.workspace-row.is-live { background: rgba(52, 211, 153, 0.02); }
.workspace-row.is-live:hover { background: rgba(52, 211, 153, 0.04); }

.ws-file-icon { color: #334155; transition: color 0.12s; }
.workspace-row:hover .ws-file-icon { color: #7a8ba4; }
.workspace-row.is-live .ws-file-icon { color: #4ade80; }

.ws-row-name-text {
  font-size: 13px;
  font-weight: 500;
  color: #8896ab;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.workspace-row:hover .ws-row-name-text { color: #c6d4ee; }

.ws-row-status-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #1e293b;
  margin-right: 7px;
  vertical-align: middle;
}
.ws-row-status-dot.is-live {
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}
.ws-row-status-label {
  font-size: 11px;
  color: #4a5568;
}
.workspace-row.is-live .ws-row-status-label { color: #6ee7b7; }

.ws-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.ws-row-action-btn {
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  font-family: inherit;
}
.ws-row-action-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}
.ws-row-action-btn span { font-size: 10.5px; font-weight: 500; }

.ws-row-action-btn--run {
  min-width: 66px;
  justify-content: center;
  color: #6ee7b7;
  background: rgba(52, 211, 153, 0.06);
}
.ws-row-action-btn--run:hover {
  background: rgba(52, 211, 153, 0.12);
  color: #6ee7b7;
}
.ws-row-action-btn--run.is-live {
  background: rgba(248, 113, 113, 0.06);
  color: #fca5a5;
}
.ws-row-action-btn--run.is-live:hover {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
}

.ws-row-action-btn--danger {
  color: #475569;
  width: 28px;
  padding: 0;
  justify-content: center;
}
.ws-row-action-btn--danger:hover {
  background: rgba(248, 113, 113, 0.08);
  color: #f87171;
}

/* ── Listing entrance animations ─────────────────────── */

@keyframes listing-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.space-listing:not(.is-hidden) .ws-templates-section {
  animation: listing-fade-in 0.3s ease both;
}

.space-listing:not(.is-hidden) .ws-recent-section {
  animation: listing-fade-in 0.35s ease 0.08s both;
}

.app-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-view-apps-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}


/* ── Chat landing ─────────────────────────────────────── */

.chat-landing {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.chat-landing.is-hidden {
  display: none;
}



/* Prompt box */

.chat-prompt-wrap {
  width: 100%;
}

.chat-prompt-box {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  background: rgba(255, 255, 255, 0.012);
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.35), 0 1px 8px rgba(0, 0, 0, 0.2);
  transition: border-color 0.25s, box-shadow 0.25s;
}

.chat-prompt-box:focus-within {
  border-color: rgba(99, 102, 241, 0.08);
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.4), 0 1px 8px rgba(0, 0, 0, 0.25), 0 0 24px rgba(99, 102, 241, 0.03);
}

.chat-prompt-input-area {
  padding: 16px 18px 0;
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.chat-prompt-input-area::before {
  content: "›";
  flex-shrink: 0;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 18px;
  line-height: 1.55;
  color: rgba(99, 102, 241, 0.4);
  pointer-events: none;
}

.chat-prompt-input {
  position: relative;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #c8d0dc;
  caret-color: transparent;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 16px;
  line-height: 1.55;
  outline: none;
  min-height: 25px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.chat-prompt-input:not(:empty) {
  caret-color: #818cf8;
}

.chat-prompt-input:empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.1);
  border-left: 2.5px solid #818cf8;
  padding-left: 9px;
  font-size: 16px;
  line-height: 1.55;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  animation: prompt-caret-blink 1.6s ease-in-out infinite;
  pointer-events: none;
}

.chat-prompt-input:empty:focus::before {
  content: "";
}

@keyframes prompt-caret-blink {
  0%, 100% { border-left-color: rgba(129, 140, 248, 0.7); }
  50% { border-left-color: rgba(129, 140, 248, 0); }
}

/* Command-mode text coloring */
.chat-prompt-input.is-command {
  color: #60a5fa;
}

/* Mention chip (shared design for input, user bubble, and assistant bubble) */
.ref-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.88em;
  line-height: 1.5;
  vertical-align: baseline;
  color: #fdba74;
  background: rgba(253, 186, 116, 0.13);
}
.ref-chip--action {
  color: #7dd3fc;
  background: rgba(125, 211, 252, 0.13);
}
.ref-chip--agent {
  color: #d8b4fe;
  background: rgba(216, 180, 254, 0.13);
}
.ref-chip--trigger {
  color: #fde047;
  background: rgba(253, 224, 71, 0.13);
}

/* Icon inside ref-chip */
.ref-chip-icon {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  object-fit: contain;
  flex-shrink: 0;
  vertical-align: middle;
}

/* Input-specific chip additions */
.chat-prompt-input .ref-chip {
  cursor: default;
  user-select: all;
}

.chat-prompt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 10px;
}

.chat-prompt-left,
.chat-prompt-right {
  display: flex;
  align-items: center;
  gap: 2px;
}

.chat-prompt-action {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.15s;
}

.chat-prompt-action:hover {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.4);
}

.chat-prompt-send {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.1);
  color: #818cf8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}

.chat-prompt-send:hover {
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  transform: scale(1.04);
}

.chat-prompt-send:active {
  transform: scale(0.96);
}

.chat-prompt-send.is-streaming {
  opacity: 0.35;
  pointer-events: none;
}

/* Key button active state */

/* ── Model selector ──────────────────────────────────── */

.chat-prompt-left {
  position: relative;
}

@keyframes chatPopIn {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-model-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  width: auto !important;
  padding: 0 10px !important;
  font-size: 12.5px;
  font-family: inherit;
  color: #94a3b8;
  white-space: nowrap;
}

.chat-model-btn.has-model {
  color: #c4b5fd;
}

.chat-model-label {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-model-chevron {
  opacity: 0.4;
  flex-shrink: 0;
}

.chat-model-popover {
  position: fixed;
  width: 360px;
  background: rgba(10, 13, 22, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  z-index: 10000;
  animation: chatPopIn 0.18s ease-out;
  max-height: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-model-popover.is-hidden {
  display: none;
}

.chat-model-popover-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 8px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-model-search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 0 10px;
  transition: border-color 0.15s, background 0.15s;
}

.chat-model-search-wrap:focus-within {
  border-color: rgba(139, 92, 246, 0.25);
  background: rgba(255, 255, 255, 0.05);
}

.chat-model-search-icon {
  flex-shrink: 0;
  color: #475569;
}

.chat-model-search {
  flex: 1;
  border: 0;
  background: transparent;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 13px;
  padding: 7px 0;
  outline: none;
}

.chat-model-search::placeholder {
  color: #475569;
}

.chat-model-back-btn {
  width: 22px;
  height: 22px;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

.chat-model-back-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.chat-model-popover-close {
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 16px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.chat-model-popover-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.chat-model-list {
  overflow-y: auto;
  padding: 6px 8px 10px;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}

.chat-model-list.is-hidden {
  display: none;
}

.chat-model-pkg {
  margin-bottom: 2px;
}

.chat-model-pkg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
}

.chat-model-pkg-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.chat-model-pkg-chevron {
  transition: transform 0.2s ease;
  flex-shrink: 0;
  color: #475569;
  width: 10px;
  height: 10px;
}

.chat-model-pkg-header.is-open .chat-model-pkg-chevron {
  transform: rotate(90deg);
}

.chat-model-pkg-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
}

.chat-model-pkg-name {
  flex: 1;
}

.chat-model-pkg-count {
  font-size: 10.5px;
  color: #3e4c63;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 6px;
  border-radius: 8px;
}

.chat-model-pkg-body {
  padding: 2px 0 4px 10px;
}

.chat-model-pkg-body.is-hidden {
  display: none;
}

.chat-model-option {
  display: flex;
  align-items: center;
  border-radius: 7px;
  transition: background 0.12s;
  margin: 1px 0;
}

.chat-model-option:hover {
  background: rgba(255, 255, 255, 0.04);
}

.chat-model-option.is-active {
  background: rgba(139, 92, 246, 0.08);
}

.chat-model-option-select {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #94a3b8;
  padding: 7px 10px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.chat-model-option.is-active .chat-model-option-select {
  color: #c4b5fd;
}

.chat-model-option-name {
  font-size: 12.5px;
  font-weight: 500;
  color: #cbd5e1;
  line-height: 1.3;
}

.chat-model-option.is-active .chat-model-option-name {
  color: #e2e8f0;
}

.chat-model-option-id {
  font-size: 10.5px;
  color: #3e4c63;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-model-option-settings {
  width: 26px;
  height: 26px;
  border: 0;
  background: transparent;
  color: #3e4c63;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 4px;
  transition: background 0.12s, color 0.12s, opacity 0.12s;
  opacity: 0;
}

.chat-model-option-settings svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.chat-model-option:hover .chat-model-option-settings {
  opacity: 1;
}

.chat-model-option-settings:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

/* ── Model detail panel (separate floating panel) ───── */

.chat-model-detail-panel {
  position: fixed;
  width: 300px;
  max-height: 420px;
  background: rgba(10, 13, 22, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatPopIn 0.18s ease-out;
}

.chat-model-detail-panel.is-hidden {
  display: none;
}

.chat-model-detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-model-detail-panel-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-model-detail-panel-close {
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 16px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.chat-model-detail-panel-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.chat-model-detail-panel-body {
  overflow-y: auto;
  padding: 8px 16px 16px;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}

.chat-model-detail-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 10px;
}

.chat-model-detail-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-model-detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #556178;
  flex-shrink: 0;
}

.chat-model-detail-value {
  font-size: 13px;
  color: #cbd5e1;
}

.chat-model-detail-mono {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 12px;
  color: #8b95a8;
}

.chat-model-detail-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.05);
  margin: 8px 0;
}

.chat-model-detail-ctrl {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}

.chat-model-detail-ctrl-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #556178;
}

.chat-model-detail-ctrl-mount {
  padding: 4px 0;
}

.chat-model-detail-key-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0 2px;
}

.chat-model-detail-key-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #556178;
}

.chat-model-detail-select-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-model-detail-auto-match {
  font-size: 11px;
  color: #10b981;
  padding: 2px 0;
  opacity: 0.85;
}

.chat-model-detail-auto-match.is-hidden {
  display: none;
}

.chat-model-detail-select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2.5 3.5L5 6.5l2.5-3' stroke='%23475569' stroke-width='1.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.chat-model-detail-select:focus {
  border-color: rgba(139, 92, 246, 0.3);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.08);
}

.chat-model-detail-select option {
  background: #0f1219;
  color: #cbd5e1;
}

.chat-model-detail-add-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.chat-model-detail-add-btn:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.2);
  color: #a78bfa;
}

.chat-model-detail-create-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0 0;
}

.chat-model-detail-create-form.is-hidden {
  display: none;
}

.chat-model-detail-create-name,
.chat-model-detail-create-value {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-model-detail-create-name:focus,
.chat-model-detail-create-value:focus {
  border-color: rgba(139, 92, 246, 0.3);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.08);
}

.chat-model-detail-create-name::placeholder,
.chat-model-detail-create-value::placeholder {
  color: #3e4c63;
}

.chat-model-detail-create-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.chat-model-detail-create-save,
.chat-model-detail-create-cancel {
  padding: 6px 14px;
  border: 0;
  border-radius: 7px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, opacity 0.12s;
}

.chat-model-detail-create-save {
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
}

.chat-model-detail-create-save:hover {
  background: rgba(139, 92, 246, 0.3);
}

.chat-model-detail-create-save:disabled {
  opacity: 0.4;
  cursor: default;
}

.chat-model-detail-create-cancel {
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
}

.chat-model-detail-create-cancel:hover {
  background: rgba(255, 255, 255, 0.08);
}

.chat-model-detail-use {
  width: 100%;
  margin-top: 12px;
  padding: 10px 0;
  border: 0;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.14);
  color: #c4b5fd;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-model-detail-use:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.28);
}

.chat-model-detail-use:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ── Chat container & messages ────────────────────────── */

.chat-container {
  display: flex;
  flex-direction: column;
  position: absolute;
  inset: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}

.chat-messages.is-hidden {
  display: none;
}

.chat-messages.chat-fade-out {
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

.chat-messages.chat-fade-in {
  animation: chatFadeIn 0.25s ease-out both;
}

@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

.chat-input-bar {
  flex-shrink: 0;
  padding: 10px 28px 16px;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  position: relative;
}
.chat-input-bar.drag-over {
  outline: 2px solid rgba(94, 234, 212, 0.5);
  outline-offset: -2px;
  border-radius: 14px;
}

.chat-msg {
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  animation: chatMsgIn 0.25s ease-out;
}

.chat-msg + .chat-msg {
  margin-top: 8px;
}

@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg--user {
  justify-content: flex-end;
  margin-top: 20px;
  margin-bottom: 2px;
}

.chat-msg--user:first-child {
  margin-top: 0;
}

.chat-msg--assistant + .chat-msg--user,
.chat-tool-wrap + .chat-msg--user,
.chat-shell-row + .chat-msg--user {
  margin-top: 24px;
}

.chat-msg--assistant {
  align-items: flex-start;
  margin-top: 8px;
}

.chat-msg--user .chat-msg-content {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.15);
  color: #e2e8f0;
  padding: 10px 14px;
  border-radius: 8px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 75%;
}

/* chat-mention is now an alias for ref-chip (used in sent message bubbles) */

/* ── Media preview cards (pinned above text) ──────────── */

.chat-media-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 10px;
}
.chat-media-preview {
  display: block;
}
.chat-media-card {
  display: inline-block;
  max-width: 480px;
  border-radius: 10px;
  overflow: hidden;
  animation: mediaFadeIn 0.3s ease both;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.chat-media-card:hover {
  border-color: rgba(94, 234, 212, 0.25);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}
.chat-media-card-img {
  display: block;
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.1);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.chat-media-card-img.is-loaded {
  opacity: 1;
}
.chat-media-card-video {
  display: block;
  width: 100%;
  max-height: 400px;
  background: #000;
  outline: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.chat-media-card-video.is-loaded {
  opacity: 1;
}

@keyframes mediaFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
.chat-media-card-caption {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: transparent;
}
.chat-media-card-icon {
  flex-shrink: 0;
  font-size: 10px;
  opacity: 0.3;
}
.chat-media-card-name {
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 255, 255, 0.3);
}

.chat-msg--user .chat-media-card {
  max-width: 160px;
}
.chat-msg--user .chat-media-card-img {
  max-height: 120px;
}

/* ── Media Lightbox ──────────────────────────────────── */

.media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.media-lightbox-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  max-height: 88vh;
}
.media-lightbox-media {
  max-width: 90vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
.media-lightbox-media--image {
  transition: transform 0.08s ease;
  will-change: transform;
}
.media-lightbox-caption {
  margin-top: 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
}
.media-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 22px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.media-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* ── Tool card media ────────────────────────────────── */

.chat-tool-media-val {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-tool-media-val .chat-media-preview {
  margin: 10px 0 0;
}
.chat-tool-media-val .chat-media-card {
  max-width: 520px;
}
.chat-tool-media-val .chat-media-card-img {
  max-height: 420px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.15);
}
.chat-tool-media-val .chat-media-card-video {
  max-height: 420px;
}

.chat-msg-avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.08);
  color: rgba(129, 140, 248, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 11px;
}

.chat-msg-body {
  flex: 1;
  min-width: 0;
}

.chat-msg--assistant .chat-msg-content {
  color: rgba(180, 190, 205, 0.85);
  font-size: 13.5px;
  line-height: 1.65;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  word-break: break-word;
}

.chat-msg-text-segment:empty {
  display: none;
}

.chat-msg--assistant .chat-msg-content strong { color: #c8d0dc; }
.chat-msg--assistant .chat-msg-content em { color: rgba(129, 140, 248, 0.6); }

.chat-msg--error .chat-msg-content {
  color: #f87171;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.12);
}

/* Shell rows in chat — terminal style, no bubble */
.chat-shell-row {
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 0 2px;
  animation: chatMsgIn 0.18s ease-out;
}

.chat-shell-row--input {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-top: 6px;
}

.chat-shell-prompt {
  color: #a78bfa;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  user-select: none;
}

.chat-shell-cmd {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 13px;
  color: #e2e8f0;
}

.chat-shell-text {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  color: #94a3b8;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 2px 0 8px;
  padding: 0 0 0 18px;
}

.chat-shell-row--error .chat-shell-text {
  color: #f87171;
}

/* Command autocomplete popover */
.chat-cmd-popover {
  position: fixed;
  width: 260px;
  max-height: 160px;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.84);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 3px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  z-index: 10000;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.32);
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.26) transparent;
}

.chat-cmd-popover::-webkit-scrollbar { width: 4px; }
.chat-cmd-popover::-webkit-scrollbar-track { background: transparent; }
.chat-cmd-popover::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.26);
  border-radius: 4px;
}

.chat-cmd-popover.is-hidden { display: none; }

.chat-cmd-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 6px;
  font-size: 12px;
  text-align: left;
  transition: background 0.1s;
}

.chat-cmd-item:hover,
.chat-cmd-item.is-active {
  background: rgba(255, 255, 255, 0.05);
}

.chat-cmd-item-name {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-weight: 600;
  color: #60a5fa;
  font-size: 12px;
  flex-shrink: 0;
}

.chat-cmd-item-icon {
  font-size: 11px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}
.chat-cmd-item-desc {
  color: #475569;
  font-size: 11px;
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-cmd-item--node {
  gap: 8px;
}

.chat-cmd-item-badge {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  flex-shrink: 0;
  min-width: 22px;
  text-align: center;
  letter-spacing: 0.3px;
}

.chat-cmd-item-badge--action {
  background: rgba(45, 212, 191, 0.15);
  color: #2dd4bf;
}

.chat-cmd-item-badge--agent {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}

.chat-cmd-item-badge--trigger {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.chat-cmd-item-pkg {
  color: #475569;
  font-size: 10px;
  white-space: nowrap;
  font-style: italic;
}

.chat-cmd-item--node .chat-cmd-item-name {
  min-width: 0;
  flex: 1;
  flex-shrink: 1;
}

.chat-cmd-item--node .chat-cmd-item-pkg {
  margin-left: auto;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-cmd-item-kind {
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  flex-shrink: 0;
  border: 1px solid transparent;
}

.chat-cmd-item-kind--action {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
  border-color: rgba(96, 165, 250, 0.18);
}

.chat-cmd-item-kind--agent {
  color: #a855f7;
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.18);
}

.chat-cmd-item-kind--trigger {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.18);
}

.chat-cmd-item-kind--data {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.18);
}

/* ── /workspace list output ────────────────────── */

.chat-ws-list {
  margin: 4px 0 6px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chat-ws-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.chat-ws-list-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.chat-ws-list-icon {
  font-size: 12px;
  color: #60a5fa;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.chat-ws-list-name {
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.chat-ws-list-id {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 10px;
  color: #334155;
  margin-left: auto;
  white-space: nowrap;
}

.chat-cmd-item-hint {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 9px;
  color: #334155;
  margin-left: auto;
  white-space: nowrap;
}

.chat-cmd-item-node-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: contain;
}

.chat-cmd-item-node-letter {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  color: #64748b;
}
.chat-cmd-item-thumb {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.04);
}
.chat-cmd-item--resource {
  padding-top: 4px;
  padding-bottom: 4px;
}
.chat-cmd-item-kind--media {
  color: #5eead4;
  background: rgba(94, 234, 212, 0.12);
}

/* ── /node list structured output ─────────────── */

.chat-node-list {
  margin: 4px 0 6px;
  display: flex;
  flex-direction: column;
  gap: 0;
  font-size: 12px;
}

.chat-node-list-group {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0 2px;
  margin-top: 2px;
}

.chat-node-list-group:first-child {
  margin-top: 0;
}

.chat-node-list-pkg-icon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  object-fit: contain;
}

.chat-node-list-pkg-name {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
}

.chat-node-list-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0 1px 8px;
  line-height: 1.6;
}

.chat-node-list-icon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  object-fit: contain;
  flex-shrink: 0;
}

.chat-node-list-letter {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  color: #64748b;
}

.chat-node-list-name {
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  color: #cbd5e1;
  font-size: 11px;
  white-space: nowrap;
}

.chat-node-list-desc {
  color: #475569;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Typing indicator */
.chat-typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}
.chat-typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #475569;
  animation: chatTypeDot 1.4s infinite both;
}
.chat-typing-indicator span:nth-child(2) { animation-delay: 0.16s; }
.chat-typing-indicator span:nth-child(3) { animation-delay: 0.32s; }
@keyframes chatTypeDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Code in chat */
.chat-code-inline {
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 13px;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
}

.chat-code-block {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 10px 0;
  overflow-x: auto;
  font-size: 13px;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  color: #cbd5e1;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}

/* Tool cards in chat (vo-card reuse) */
.chat-tool-wrap {
  max-width: 780px;
  width: 100%;
  margin: 12px auto 14px;
  padding: 0 2px;
  animation: toolPopIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.chat-tool-wrap.no-animate {
  animation: none;
}

.chat-tool-wrap.no-animate .vo-card-body {
  transition: none;
}

.no-animate .chat-media-card {
  animation: none;
}

@keyframes toolPopIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.chat-tool-wrap .vo-card {
  opacity: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-tool-wrap .vo-card-body {
  padding: 0;
  gap: 0;
  overflow: hidden;
  transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.4s ease;
  max-height: 2000px;
  opacity: 1;
}

.chat-tool-wrap .vo-card.is-collapsed .vo-card-body {
  max-height: 0 !important;
  opacity: 0;
}

.chat-tool-wrap .vo-card-status {
  transition: opacity 0.2s ease;
}

.chat-tool-collapse-arrow {
  display: none;
}

.chat-tool-wrap .vo-card-header {
  position: relative;
}

.chat-tool-wrap .chat-tool-collapse-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0;
  color: rgba(148, 163, 184, 0.7);
  transition: opacity 0.2s ease, transform 0.25s ease;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 2;
}

.chat-tool-wrap .vo-card-header:hover .chat-tool-collapse-arrow {
  opacity: 1;
}

.chat-tool-wrap .vo-card-header:hover .vo-card-status .vo-card-status-icon {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.chat-tool-wrap .vo-card-header .vo-card-status .vo-card-status-icon {
  transition: opacity 0.2s ease;
}

.chat-tool-wrap .vo-card.is-collapsed .chat-tool-collapse-arrow {
  transform: translateY(-50%) rotate(-90deg);
}

.chat-tool-wrap .vo-card.is-collapsed .vo-card-header:hover .chat-tool-collapse-arrow {
  opacity: 1;
}

.chat-tool-wrap .vo-card.is-collapsed .vo-card-header:hover .vo-card-status .vo-card-status-icon {
  opacity: 0;
}

.chat-tool-wrap .vo-card.is-collapsed .vo-card-header {
  border-radius: 10px;
}

.chat-tool-section {
  padding: 8px 12px 8px 38px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.chat-tool-section-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #475569;
  margin-bottom: 5px;
}

.chat-tool-kv {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0;
  font-size: 11px;
  line-height: 1.5;
}

.chat-tool-kv-key {
  color: #64748b;
  font-weight: 500;
  flex-shrink: 0;
  min-width: 60px;
}

.chat-tool-kv-key::after {
  content: ":";
}

.chat-tool-kv-val {
  color: #94a3b8;
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
  word-break: break-word;
  min-width: 0;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

/* Data Node reference chip */
.chat-data-ref {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 6px;
  background: rgba(99, 102, 241, 0.10);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: #a5b4fc;
  cursor: default;
  transition: background 0.15s, border-color 0.15s;
}

.chat-data-ref:hover {
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(99, 102, 241, 0.35);
}

.chat-data-ref-icon {
  border-radius: 3px;
  flex-shrink: 0;
  opacity: 0.85;
}

.chat-data-ref-label {
  font-weight: 600;
  white-space: nowrap;
}

.chat-data-ref-badge {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  background: rgba(99, 102, 241, 0.18);
  border-radius: 3px;
  color: rgba(165, 180, 252, 0.7);
  margin-left: 2px;
}

/* Typed value chip (engine-aware inline values) */
.chat-typed-val {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: #94a3b8;
  max-width: 100%;
}

.chat-typed-val-badge {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  color: rgba(148, 163, 184, 0.7);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-typed-val > .chat-tool-kv-val {
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
  word-break: break-word;
  min-width: 0;
  color: #cbd5e1;
}

/* Inspectable (clickable) truncated values */
.chat-inspectable {
  cursor: pointer;
  transition: color 0.15s;
}
.chat-inspectable:hover {
  color: #e2e8f0;
}

/* Value Viewer overlay (like media lightbox) */
.value-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.value-viewer-box {
  background: #1e1e2e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  max-width: 80vw;
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}
.value-viewer-box::-webkit-scrollbar { width: 6px; height: 6px; }
.value-viewer-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
.value-viewer-content {
  margin: 0;
  padding: 20px 24px;
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
}
.value-viewer-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.value-viewer-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Fallback card (when vo module not loaded) */
.chat-tool-card-fallback {
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  padding: 10px 14px;
  font-size: 12px;
  color: #94a3b8;
}


/* ── Left Sidebar ─────────────────────────────────────── */

.app-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  background: #080d1a;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  transition: width 0.25s ease, min-width 0.25s ease;
  overflow: hidden;
  z-index: 110;
  flex-shrink: 0;
}

.app-sidebar.is-collapsed {
  width: 62px;
  min-width: 62px;
}

.app-sidebar.is-collapsed .sidebar-logo,
.app-sidebar.is-collapsed .sidebar-nav-btn span {
  display: none;
}

.app-sidebar.is-collapsed .sidebar-header {
  justify-content: center;
  padding: 16px 8px 12px;
}

.app-sidebar.is-collapsed .sidebar-nav-group {
  padding: 4px 8px 12px;
  align-items: center;
  flex: 0 0 auto;
}

.app-sidebar.is-collapsed .sidebar-nav-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  justify-content: center;
  border-radius: 10px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 16px 12px;
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #e2e8f0;
  white-space: nowrap;
}

.sidebar-collapse-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

.sidebar-collapse-btn svg {
  transition: transform 0.25s ease;
}

.app-sidebar.is-collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

/* ── Sidebar: Navigation ──────────────────────────────── */

.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  padding: 4px 10px 12px;
  flex-shrink: 0;
}

.sidebar-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s, border-radius 0.25s;
}

.sidebar-nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.sidebar-nav-btn.is-active {
  background: rgba(59, 130, 246, 0.1);
  color: #93c5fd;
  border-color: rgba(255, 255, 255, 0.06);
}

.sidebar-nav-btn svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.sidebar-nav-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  object-fit: contain;
  border-radius: 3px;
}

.sidebar-nav-letter {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: inherit;
}

.sidebar-nav-btn[data-space="chats"].is-active {
  border-radius: 10px 10px 0 0;
  border-bottom-color: transparent;
}

#sidebar-nav-workspaces {
  margin-top: 6px;
}

/* ── Sidebar: Chat Session List ──────────────────────── */

.sidebar-sessions {
  display: flex;
  flex-direction: column;
  border-radius: 0 0 10px 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-top: none;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.3);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.28s ease, opacity 0.22s ease;
}

.sidebar-sessions.is-expanded {
  max-height: 500px;
  opacity: 1;
}

.sidebar-sessions-header {
  padding: 6px 12px 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.22);
  flex-shrink: 0;
}

.sidebar-sessions-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 5px 6px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 250px;
  scrollbar-width: none;
}
.sidebar-sessions-list::-webkit-scrollbar { display: none; }

.sidebar-sessions-empty {
  padding: 14px 10px;
  color: rgba(255,255,255,0.28);
  font-size: 12px;
  text-align: center;
}

.sidebar-session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  position: relative;
}

.sidebar-session-item:hover {
  background: rgba(255,255,255,0.055);
}

.sidebar-session-item.is-active {
  background: rgba(255,255,255,0.045);
}

.sidebar-session-icon {
  flex-shrink: 0;
  color: rgba(255,255,255,0.30);
}

.sidebar-session-item.is-active .sidebar-session-icon {
  color: rgba(255,255,255,0.45);
}

.sidebar-session-title {
  flex: 1 1 0;
  min-width: 0;
  font-size: 13px;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s;
}

.sidebar-session-item:hover .sidebar-session-title {
  color: rgba(255,255,255,0.85);
}

.sidebar-session-item.is-active .sidebar-session-title {
  color: rgba(255,255,255,0.8);
  font-weight: 500;
}

/* 3-dot more button */
.sidebar-session-more {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: rgba(255,255,255,0.4);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.sidebar-session-item:hover .sidebar-session-more {
  opacity: 1;
}

.sidebar-session-more:hover {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.1);
}

/* Pinned session icon */
.sidebar-session-icon--pin {
  color: rgba(250, 204, 21, 0.55);
}

.sidebar-session-item.is-pinned {
  background: rgba(250, 204, 21, 0.03);
}

.sidebar-session-item.is-dragging {
  opacity: 0.4 !important;
  cursor: grabbing;
}

.sidebar-session-item.drag-over-above {
  box-shadow: 0 -2px 0 0 rgba(250, 204, 21, 0.5);
}

.sidebar-session-item.drag-over-below {
  box-shadow: 0 2px 0 0 rgba(250, 204, 21, 0.5);
}

/* Context menu */
.sidebar-session-menu {
  position: fixed;
  z-index: 10000;
  min-width: 140px;
  padding: 4px;
  background: rgba(24, 24, 30, 0.97);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateY(-4px) scale(0.96);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
}

.sidebar-session-menu.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.sidebar-session-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: none;
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.sidebar-session-menu-item:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.95);
}

.sidebar-session-menu-item--danger:hover {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
}

/* Inline rename */
.sidebar-session-item.is-renaming .sidebar-session-title {
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  padding: 1px 4px;
  outline: 1px solid rgba(255,255,255,0.15);
  cursor: text;
  color: rgba(255,255,255,0.95);
}

.sidebar-session-item.is-renaming .sidebar-session-more {
  opacity: 0;
  pointer-events: none;
}

/* Streaming session indicator */
.sidebar-session-spinner {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(59,130,246,0.20);
  border-top-color: rgba(93,165,255,0.85);
  border-radius: 50%;
  animation: sidebarSpin 0.7s linear infinite;
}
@keyframes sidebarSpin {
  to { transform: rotate(360deg); }
}
.sidebar-session-item.is-streaming .sidebar-session-title {
  color: rgba(255,255,255,0.85);
}

/* ── Explorer Panel (tab-panel--explorer) ──────────── */

.tab-panel--explorer .explorer-panel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.tab-panel--explorer .explorer-panel-body::-webkit-scrollbar { width: 4px; }
.tab-panel--explorer .explorer-panel-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.explorer-titlebar-icon {
  flex-shrink: 0;
  margin-right: 6px;
  opacity: 0.6;
}

/* Search bar */
.explorer-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.explorer-search-icon {
  flex-shrink: 0;
  opacity: 0.35;
}
.explorer-search-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12px;
  color: #e2e8f0;
  outline: none;
  transition: border-color 0.15s;
}
.explorer-search-input:focus {
  border-color: rgba(99, 149, 255, 0.4);
}
.explorer-search-input::placeholder {
  color: rgba(255,255,255,0.28);
}

/* Search results */
.explorer-search-results.is-hidden { display: none; }

.explorer-count-bar {
  padding: 6px 10px;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  background: #0d1117;
  z-index: 1;
}

.explorer-search-result {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: default;
}
.explorer-search-result:hover {
  background: rgba(255,255,255,0.03);
}
.explorer-result-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}
.explorer-result-ref {
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
  font-size: 11.5px;
  color: #a5b4fc;
  word-break: break-all;
}
.explorer-result-pkg {
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  margin-left: auto;
  flex-shrink: 0;
}
.explorer-result-desc {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  margin-bottom: 4px;
  line-height: 1.35;
  padding-left: 2px;
}
.explorer-result-ports {
  display: flex;
  gap: 20px;
  margin-top: 2px;
}
.explorer-port-col {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.explorer-port-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  margin-bottom: 1px;
}
.explorer-port-entry {
  display: flex;
  align-items: baseline;
  gap: 0;
  font-size: 10.5px;
  line-height: 1.5;
}
.explorer-port-req {
  width: 10px;
  flex-shrink: 0;
  color: rgba(255,180,100,0.7);
  font-weight: 700;
}
.explorer-port-name {
  color: rgba(255,255,255,0.55);
  margin-right: 4px;
}
.explorer-port-name::after {
  content: ":";
}
.explorer-port-type {
  font-size: 9.5px;
  color: rgba(148,163,184,0.6);
}

.explorer-result-skills {
  font-size: 10.5px;
  color: rgba(180,220,255,0.55);
  background: rgba(100,160,255,0.06);
  border-left: 2px solid rgba(100,160,255,0.2);
  padding: 4px 6px;
  margin-top: 4px;
  border-radius: 3px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.explorer-node { display: flex; flex-direction: column; }

.explorer-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
  color: rgba(255,255,255,0.72);
  border-radius: 4px;
  user-select: none;
  transition: background 0.12s;
}
.explorer-row:hover {
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
}
.explorer-row.is-selected {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.explorer-chevron {
  flex-shrink: 0;
  width: 12px;
  font-size: 8px;
  text-align: center;
  color: rgba(255,255,255,0.35);
}
.explorer-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  font-size: 12px;
}
.explorer-icon img {
  display: block;
  border-radius: 2px;
}
.explorer-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.explorer-badge {
  flex-shrink: 0;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.explorer-count {
  flex-shrink: 0;
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  margin-left: 2px;
}

.explorer-children.is-hidden { display: none; }

.explorer-empty {
  padding: 8px 16px;
  font-size: 11px;
  color: rgba(255,255,255,0.25);
  font-style: italic;
}

/* Collapsed sidebar: hide session list */
.app-sidebar.is-collapsed .sidebar-sessions {
  display: none;
}

.app-sidebar.is-collapsed .sidebar-spaces-wrap {
  display: none;
}

.app-sidebar.is-collapsed #sidebar-nav-chat.is-active {
  border-radius: 10px;
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

/* ── Sidebar: Space List ──────────────────────────────── */

.sidebar-spaces-wrap {
  overflow: hidden;
}

.sidebar-spaces-wrap:not(.is-expanded) {
  display: none;
}

.sidebar-spaces-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 5px 6px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 250px;
  scrollbar-width: none;
}
.sidebar-spaces-list::-webkit-scrollbar { display: none; }

.sidebar-spaces-empty {
  padding: 14px 10px;
  color: rgba(255,255,255,0.28);
  font-size: 12px;
  text-align: center;
}

.sidebar-space-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}

.sidebar-space-item:hover {
  background: rgba(255,255,255,0.06);
}

.sidebar-space-item.is-active {
  background: rgba(99, 102, 241, 0.13);
}

.sidebar-space-item.is-active .sidebar-space-icon {
  color: #818cf8;
}

.sidebar-space-icon {
  flex-shrink: 0;
  color: rgba(255,255,255,0.35);
}

.sidebar-space-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: rgba(255,255,255,0.6);
}

.sidebar-space-item:hover .sidebar-space-title {
  color: rgba(255,255,255,0.85);
}

.sidebar-space-item.is-active .sidebar-space-title {
  color: rgba(255,255,255,0.9);
}

.sidebar-space-more {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}

.sidebar-space-item:hover .sidebar-space-more {
  display: flex;
}

.sidebar-space-more:hover {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
}

.sidebar-space-live-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.5);
  margin: 0 3px;
}

/* ── Sidebar: User Panel ─────────────────────────────── */

.sidebar-user-panel {
  margin-top: auto;
  position: relative;
  flex-shrink: 0;
  padding: 8px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.sidebar-user-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar-user-btn:hover .sidebar-user-avatar {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
  color: #cbd5e1;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: #d1d5db;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.sidebar-user-chevron {
  flex-shrink: 0;
  color: #6b7280;
  transition: transform 0.2s ease;
}

.sidebar-user-panel.is-open .sidebar-user-chevron {
  transform: rotate(180deg);
}

.sidebar-user-menu {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% - 2px);
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5), 0 -2px 8px rgba(0, 0, 0, 0.3);
  z-index: 200;
  display: flex;
  flex-direction: column;
  animation: userMenuIn 0.15s ease;
}

.sidebar-user-menu.is-hidden {
  display: none;
}

@keyframes userMenuIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sidebar-user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: #d1d5db;
  font-size: 13px;
  font-weight: 450;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  text-align: left;
  width: 100%;
}

.sidebar-user-menu-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #f3f4f6;
}

.sidebar-user-menu-item svg {
  flex-shrink: 0;
  color: #6b7280;
}

.sidebar-user-menu-item:hover svg {
  color: #9ca3af;
}

.sidebar-user-menu-item--danger {
  color: #f87171;
}

.sidebar-user-menu-item--danger:hover {
  background: rgba(248, 113, 113, 0.1);
  color: #fca5a5;
}

.sidebar-user-menu-item--danger svg {
  color: #f87171;
}

.sidebar-user-menu-item--danger:hover svg {
  color: #fca5a5;
}

.sidebar-user-menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 4px 8px;
}

/* Collapsed sidebar: user panel */
.app-sidebar.is-collapsed .sidebar-user-name,
.app-sidebar.is-collapsed .sidebar-user-chevron {
  display: none;
}

.app-sidebar.is-collapsed .sidebar-user-btn {
  justify-content: center;
  padding: 8px 0;
}

.app-sidebar.is-collapsed .sidebar-user-panel {
  padding: 8px 9px 12px;
}


/* Dead workspace explorer CSS removed -- see git history */

/* ── Name prompt dialog ───────────────────────────────── */

.ws-name-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  transition: background 0.2s, backdrop-filter 0.2s;
}

.ws-name-overlay.is-visible {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.ws-name-dialog {
  background: #0f1526;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 28px 32px 24px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: scale(0.95) translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

.ws-name-overlay.is-visible .ws-name-dialog {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.ws-name-dialog-title {
  margin: 0 0 18px;
  font-size: 17px;
  font-weight: 700;
  color: #e2e8f0;
}

.ws-name-dialog-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.ws-name-dialog-input:focus {
  border-color: rgba(255, 255, 255, 0.2);
}

.ws-name-dialog-error {
  min-height: 20px;
  margin: 8px 0 4px;
  font-size: 12px;
  color: #f87171;
  font-weight: 500;
}

.ws-name-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.ws-name-dialog-btn {
  padding: 8px 18px;
  border: 0;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  font-family: inherit;
}

.ws-name-dialog-btn--cancel {
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
}

.ws-name-dialog-btn--cancel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

.ws-name-dialog-btn--confirm {
  background: rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
}

.ws-name-dialog-btn--confirm:hover {
  background: rgba(99, 102, 241, 0.45);
  color: #c7d2fe;
}

/* ── Topbar: Save indicator ───────────────────────────── */

.topbar-save-indicator {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  padding: 4px 8px;
  border-radius: 6px;
  transition: opacity 0.3s;
  white-space: nowrap;
}

.topbar-save-indicator.is-saving {
  color: #64748b;
}

.topbar-save-indicator.is-saved {
  color: #10b981;
}

/* ── Topbar workspace name (used inside unified-bar-ws) ── */

.topbar-workspace-name {
  font-size: 11.5px;
  font-weight: 500;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  padding: 2px 6px;
  border-radius: 3px;
  transition: background 0.15s;
}

.topbar-workspace-name:hover {
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.topbar-workspace-name[contenteditable="true"] {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  cursor: text;
}


.topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.topbar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

.topbar-btn--danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* ── App body (below topbar) ──────────────────────────── */

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

/* ── Node browser toggle (+ button) ──────────────────── */

.node-browser-toggle {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 20;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 16px;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.45);
  transition: background 0.15s, box-shadow 0.15s, transform 0.12s;
}

.node-browser-toggle svg {
  width: 22px;
  height: 22px;
}

.node-browser-toggle:hover {
  background: #1d4ed8;
  box-shadow: 0 5px 22px rgba(37, 99, 235, 0.6);
  transform: scale(1.05);
}

.node-browser-toggle:active {
  transform: scale(0.94);
}

.node-browser-toggle.is-active {
  background: #3b82f6;
  box-shadow: 0 4px 18px rgba(59, 130, 246, 0.5);
}

/* ── Node browser panel ──────────────────────────────── */

.node-browser {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 25;
  width: 340px;
  background: #0a0f1e;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.4);
  transform: translateX(0);
  opacity: 1;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

.node-browser.is-hidden {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.node-browser-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 0 14px;
  flex-shrink: 0;
}

.node-browser-search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 7px 10px;
  transition: border-color 0.15s;
}

.node-browser-search-wrap:focus-within {
  border-color: rgba(96, 165, 250, 0.5);
}

.node-browser-search-icon {
  flex-shrink: 0;
  color: #64748b;
}

.node-browser-search {
  flex: 1;
  background: none;
  border: 0;
  outline: none;
  color: #e2e8f0;
  font-size: 13px;
  font-family: inherit;
}

.node-browser-search::placeholder {
  color: #64748b;
}

.node-browser-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.node-browser-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

.node-browser-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 14px;
}

.node-browser-body::-webkit-scrollbar { width: 5px; }
.node-browser-body::-webkit-scrollbar-track { background: transparent; }
.node-browser-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.node-browser-body::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Package groups (collapsible) ── */

.package-group {
  margin-bottom: 8px;
}

.package-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.package-group-header:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.package-group.is-open .package-group-header {
  background: rgba(96, 165, 250, 0.06);
  border-color: rgba(96, 165, 250, 0.15);
}

.package-group-chevron {
  flex-shrink: 0;
  color: #64748b;
  transition: transform 0.2s ease, color 0.2s;
}

.package-group.is-open .package-group-chevron {
  transform: rotate(90deg);
  color: #93c5fd;
}

.package-group-body {
  display: none;
  padding: 8px 0 4px 4px;
}

.package-group.is-open .package-group-body {
  display: block;
}

.palette-node {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: grab;
  user-select: none;
  transition: background 0.12s, border-color 0.12s;
}

.palette-node:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
}

.palette-node:active {
  cursor: grabbing;
}

.palette-node .kind {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: #94a3b8;
  border: 1px solid transparent;
  margin-left: auto;
  margin-top: 2px;
  flex-shrink: 0;
  white-space: nowrap;
}

.palette-node .kind--action {
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(59, 130, 246, 0.26);
  color: #7db7ff;
}

.palette-node .kind--data,
.palette-node .kind--datatype {
  background: rgba(234, 88, 12, 0.15);
  border-color: rgba(249, 115, 22, 0.26);
  color: #f7a55c;
}

.palette-node .kind--agent,
.palette-node .kind--agent-tool {
  background: rgba(88, 28, 135, 0.22);
  border-color: rgba(124, 58, 237, 0.28);
  color: #b794f6;
}

.palette-node .kind--trigger {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(52, 211, 153, 0.24);
  color: #34d399;
}

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

.palette-node-info strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.palette-desc {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 3px;
  line-height: 1.4;
}

.canvas-wrap {
  flex: 1;
  position: relative;
}

/* (old toolbar removed — buttons now in .topbar) */

.workspace-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 4px;
  padding: 3px 10px 3px 8px;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.02em;
  color: #e6edf3;
  background: #1f6feb;
  box-shadow: none;
  transition: background 0.15s, transform 0.1s;
}

.workspace-toggle-btn:hover {
  background: #388bfd;
}

.workspace-toggle-btn:active {
  transform: scale(0.96);
}

.workspace-toggle-btn.is-live {
  background: #da3633;
}

.workspace-toggle-btn.is-live:hover {
  background: #f85149;
}

.workspace-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.workspace-toggle-btn .workspace-play-icon,
.workspace-toggle-btn .workspace-stop-icon {
  flex-shrink: 0;
}

/* ── Workspace status indicator ── */

.workspace-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 3px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 10px;
  font-weight: 500;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  color: rgba(255,255,255,0.35);
  transition: all 0.2s;
}

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

.workspace-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
  flex-shrink: 0;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.workspace-status.is-live {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.workspace-status.is-live .workspace-status-dot {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
  animation: status-dot-pulse 1.5s ease-in-out infinite;
}

@keyframes status-dot-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px rgba(16, 185, 129, 0.6); }
  50% { opacity: 0.7; box-shadow: 0 0 10px rgba(16, 185, 129, 0.9); }
}

/* Run buttons remain interactive during live mode — handled by JS */

/* ── Run split-button dropdown ── */

.run-btn-wrap {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  gap: 0;
}

.run-btn-icon {
  flex-shrink: 0;
  pointer-events: none;
}
.run-btn-icon--stop {
  display: none;
}
.node-hover-btn--run.is-running .run-btn-icon--play {
  display: none;
}
.node-hover-btn--run.is-running .run-btn-icon--stop {
  display: inline;
}

.run-split-mode-label {
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

/* Connected caret button for exec-mode dropdown (canvas nodes) */
.run-btn-caret-btn {
  width: 26px !important;
  padding: 0 !important;
  border-radius: 0 10px 10px 0 !important;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  background: linear-gradient(135deg, #2f6df6, #1f53d8);
  box-shadow:
    0 2px 8px rgba(37, 99, 235, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.run-btn-caret-btn:hover {
  background: linear-gradient(135deg, #2563eb, #1a44c0);
}
.run-btn-caret-btn svg {
  pointer-events: none;
  opacity: 0.65;
}
.run-btn-caret-btn:hover svg {
  opacity: 1;
}

/* Config dialog: connected run+caret pair */
#config-run-wrap {
  gap: 0;
}
#config-run-wrap .config-execute-btn {
  border-radius: 10px 0 0 10px;
}
.config-caret-btn {
  width: 28px;
  height: auto;
  align-self: stretch;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, #2f5fcf, #1d4ed8);
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 10px 10px 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.config-caret-btn:hover {
  background: linear-gradient(135deg, #2563eb, #1a44c0);
  color: #fff;
}
.config-caret-btn svg {
  pointer-events: none;
}

/* Global exec-mode dropdown menu */
.exec-mode-menu {
  display: none;
  position: fixed;
  min-width: 148px;
  background: rgba(17, 24, 39, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 4px;
  z-index: 100000;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3);

  opacity: 0;
  transform: translateY(-6px) scale(0.96);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.exec-mode-menu.is-visible {
  display: block;
}
.exec-mode-menu.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.exec-mode-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: none;
  color: #d1d5db;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  border-radius: 7px;
  transition: background 0.1s ease, color 0.1s ease;
}
.exec-mode-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.exec-mode-item.is-active {
  color: #60a5fa;
}
.exec-mode-item .exec-mode-check {
  width: 16px;
  text-align: center;
  font-size: 11px;
  opacity: 0.7;
}
.exec-mode-item.is-active .exec-mode-check {
  opacity: 1;
}

#canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 22% 18%, rgba(58, 32, 98, 0.05), transparent 48%),
    radial-gradient(ellipse at 78% 76%, rgba(24, 62, 88, 0.04), transparent 44%),
    linear-gradient(145deg, #060810 0%, #07091a 40%, #0a0c18 100%);
}

#star-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 1;
  filter: none;
}

#canvas-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: visible;
  transform-origin: 0 0;
  z-index: 1;
}

/* ── Edge layer ── */

.edge-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  pointer-events: none;
}

.edge-group {
  cursor: pointer;
}

.edge-glow {
  fill: none;
  stroke: #fb923c;
  stroke-width: 5;
  stroke-linecap: round;
  pointer-events: none;
  opacity: 0.35;
  transition: stroke 0.15s ease, opacity 0.15s ease;
}

.edge-path {
  fill: none;
  stroke: #fb923c;
  stroke-width: 5;
  stroke-linecap: round;
  pointer-events: none;
  transition: stroke 0.15s ease;
}

.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 22;
  stroke-linecap: round;
  pointer-events: stroke;
  cursor: pointer;
}

.edge-group:hover .edge-glow {
  stroke: #ef4444;
  opacity: 0.45;
}

.edge-group:hover .edge-path {
  stroke: #ef4444;
}

/* ── Flow edges (white) ── */

.edge-group--flow .edge-glow {
  stroke: #ffffff;
  opacity: 0.25;
}

.edge-group--flow .edge-path {
  stroke: #ffffff;
}

.edge-group--flow:hover .edge-glow {
  stroke: #ef4444;
  opacity: 0.45;
}

.edge-group--flow:hover .edge-path {
  stroke: #ef4444;
}

.edge-path--temp {
  fill: none;
  stroke: #fb923c;
  stroke-width: 5;
  stroke-dasharray: 6 4;
  pointer-events: none;
}

.edge-path--temp-flow {
  stroke: #ffffff;
}

/* ── Agent-tool green links ── */

.agent-link-glow {
  fill: none;
  stroke: #a78bfa;
  stroke-width: 6;
  stroke-linecap: round;
  pointer-events: none;
  opacity: 0.2;
}

.agent-link-path {
  fill: none;
  stroke: #a78bfa;
  stroke-width: 2.5;
  stroke-linecap: round;
  pointer-events: none;
  opacity: 0.7;
  stroke-dasharray: 8 5;
}

/* ── Highlight flash for node navigation ── */

@keyframes nodeHighlightFlash {
  0%   { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0); }
  25%  { box-shadow: 0 0 20px 8px rgba(167, 139, 250, 0.4); }
  100% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0); }
}

.node.is-highlight-flash .node-shell {
  animation: nodeHighlightFlash 0.8s ease-out;
}

/* Port highlighting during connection drag */

.node-port--compatible .node-port-dot {
  box-shadow: 0 0 8px 2px rgba(96, 165, 250, 0.6);
  transform: scale(1.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.node-port--incompatible {
  opacity: 0.3;
  pointer-events: none;
}

.is-connecting-ports .node-port-dot {
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.package-group-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 7px;
}

.package-group-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #e2e8f0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.package-group-count {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.palette-node-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 7px;
}

.nb-empty {
  text-align: center;
  padding: 24px 12px;
  color: #64748b;
  font-size: 13px;
}

.node {
  position: absolute;
  width: 320px;
  min-width: 180px;
  max-width: 2000px;
  min-height: 120px;
  max-height: 2000px;
  overflow: visible;
  -webkit-user-select: none;
  user-select: none;
  z-index: 1;
}

.node-resize-handle {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.node-resize-handle::before {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 6px;
  height: 6px;
  border-right: 2px solid rgba(255, 255, 255, 0.45);
  border-bottom: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 0 0 2px 0;
}

.node:hover .node-resize-handle {
  opacity: 1;
}

.node .node-inline-preview-mount,
.node .node-inline-preview-single {
  -webkit-user-select: auto;
  user-select: auto;
}

.node::after {
  content: "";
  position: absolute;
  inset: -32px -14px -14px;
  pointer-events: auto;
  z-index: -1;
}

.node.is-dragging {
  opacity: 1;
}

.node.is-selected {
  outline: 2px solid rgba(96, 165, 250, 0.6);
  outline-offset: -1px;
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.15),
    0 0 16px rgba(96, 165, 250, 0.08);
}

.node.is-resolving {
  transition: left 0.2s ease, top 0.2s ease;
}

.node--compact .node-header {
  justify-content: flex-end;
}

.node-compact-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 16px 24px;
  text-align: center;
  flex: 1;
}

.node-compact-body-icon {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 16px;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.08));
}

.node-compact-body-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
}

.node-compact-body-name {
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
  line-height: 1.3;
  word-break: break-word;
  max-width: 260px;
  letter-spacing: -0.01em;
}

.node-title-wrap[hidden],
.node-compact-body[hidden],
.node-footer[hidden] {
  display: none;
}

.node-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #141a2e;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  transition:
    border-color 0.28s ease,
    box-shadow 0.28s ease;
}

.node:not(.is-dragging):hover .node-shell {
  border-color: rgba(96, 165, 250, 0.35);
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.2),
    0 0 20px 4px rgba(96, 165, 250, 0.12),
    0 0 40px 8px rgba(96, 165, 250, 0.06),
    0 10px 22px rgba(0, 0, 0, 0.5);
}

.node.is-executing .node-shell,
.node.is-executing:hover .node-shell {
  border-color: rgba(250, 204, 21, 0.65);
  box-shadow:
    0 0 0 2px rgba(250, 204, 21, 0.4),
    0 0 28px 8px rgba(250, 204, 21, 0.35),
    0 0 60px 16px rgba(250, 204, 21, 0.18),
    0 0 90px 24px rgba(250, 204, 21, 0.08),
    0 10px 22px rgba(0, 0, 0, 0.3);
  animation: exec-pulse 1.5s ease-in-out infinite;
}

@keyframes exec-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 2px rgba(250, 204, 21, 0.4),
      0 0 28px 8px rgba(250, 204, 21, 0.35),
      0 0 60px 16px rgba(250, 204, 21, 0.18),
      0 0 90px 24px rgba(250, 204, 21, 0.08),
      0 10px 22px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow:
      0 0 0 3px rgba(250, 204, 21, 0.55),
      0 0 36px 12px rgba(250, 204, 21, 0.45),
      0 0 70px 20px rgba(250, 204, 21, 0.22),
      0 0 100px 30px rgba(250, 204, 21, 0.1),
      0 10px 22px rgba(0, 0, 0, 0.3);
  }
}

/* Trigger nodes: green glow with slower, more dramatic animation */
.node--trigger.is-executing .node-shell,
.node--trigger.is-executing:hover .node-shell {
  border-color: rgba(16, 185, 129, 0.7);
  box-shadow:
    0 0 0 2px rgba(16, 185, 129, 0.45),
    0 0 30px 10px rgba(16, 185, 129, 0.4),
    0 0 65px 18px rgba(16, 185, 129, 0.2),
    0 0 100px 28px rgba(16, 185, 129, 0.1),
    0 10px 22px rgba(0, 0, 0, 0.3);
  animation: trigger-exec-pulse 2.5s ease-in-out infinite;
}

@keyframes trigger-exec-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 2px rgba(16, 185, 129, 0.45),
      0 0 30px 10px rgba(16, 185, 129, 0.4),
      0 0 65px 18px rgba(16, 185, 129, 0.2),
      0 0 100px 28px rgba(16, 185, 129, 0.1),
      0 10px 22px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(16, 185, 129, 0.65),
      0 0 40px 14px rgba(16, 185, 129, 0.55),
      0 0 80px 24px rgba(16, 185, 129, 0.28),
      0 0 120px 36px rgba(16, 185, 129, 0.12),
      0 10px 22px rgba(0, 0, 0, 0.3);
  }
}

.node--agent-tool.is-executing .node-shell,
.node--agent-tool.is-executing:hover .node-shell {
  border-color: rgba(167, 139, 250, 0.7);
  box-shadow:
    0 0 0 2px rgba(167, 139, 250, 0.45),
    0 0 30px 10px rgba(167, 139, 250, 0.4),
    0 0 65px 18px rgba(167, 139, 250, 0.2),
    0 0 100px 28px rgba(167, 139, 250, 0.1),
    0 10px 22px rgba(0, 0, 0, 0.3);
  animation: agent-tool-exec-pulse 1.5s ease-in-out infinite;
}

@keyframes agent-tool-exec-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 2px rgba(167, 139, 250, 0.45),
      0 0 30px 10px rgba(167, 139, 250, 0.4),
      0 0 65px 18px rgba(167, 139, 250, 0.2),
      0 0 100px 28px rgba(167, 139, 250, 0.1),
      0 10px 22px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(167, 139, 250, 0.65),
      0 0 40px 14px rgba(167, 139, 250, 0.55),
      0 0 80px 24px rgba(167, 139, 250, 0.28),
      0 0 120px 36px rgba(167, 139, 250, 0.12),
      0 10px 22px rgba(0, 0, 0, 0.3);
  }
}

.node.is-executing .node-hover-actions {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.node.is-executing .node-hover-btn--run {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow:
    0 2px 8px rgba(239, 68, 68, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.node.is-executing .run-btn-caret-btn {
  background: linear-gradient(135deg, #dc3434, #c42020);
  border-left-color: rgba(255, 255, 255, 0.12);
}

.node.is-executing .node-hover-btn--run:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow:
    0 4px 14px rgba(239, 68, 68, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.node.is-executing .node-hover-btn--run .run-btn-icon {
  animation: btn-spin 0.7s linear infinite;
}

.node-hover-overlay {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  padding-bottom: 10px;
  z-index: 10;
}

.node-hover-actions {
  display: flex;
  gap: 8px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.12),
    0 1px 3px rgba(0, 0, 0, 0.06);
  opacity: 0;
  transform: translateY(6px) scale(0.9);
  transition:
    opacity 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    transform 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

.node:not(.is-dragging):hover .node-hover-actions,
.node.has-menu-open .node-hover-actions {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.node-hover-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  transition:
    background 0.15s ease,
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.node-hover-btn--run {
  width: auto;
  gap: 5px;
  padding: 0 10px;
  border-radius: 10px 0 0 10px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow:
    0 2px 8px rgba(37, 99, 235, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.node-hover-btn--run:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow:
    0 4px 14px rgba(37, 99, 235, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.node-hover-btn--edit {
  background: linear-gradient(135deg, #4b5563, #374151);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.node-hover-btn--edit:hover {
  background: linear-gradient(135deg, #374151, #1f2937);
  transform: scale(1.1);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.node-hover-btn--delete {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow:
    0 2px 8px rgba(239, 68, 68, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.node-hover-btn--delete:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: scale(1.1);
  box-shadow:
    0 4px 14px rgba(239, 68, 68, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.node-hover-btn:active {
  transform: scale(0.93);
  transition-duration: 0.06s;
}

.node--action .node-header {
  background: rgba(59, 130, 246, 0.1);
  border-bottom-color: rgba(59, 130, 246, 0.1);
}

.node--data .node-header,
.node--datatype .node-header {
  background: rgba(249, 115, 22, 0.1);
  border-bottom-color: rgba(249, 115, 22, 0.1);
}

.node--trigger .node-header {
  background: rgba(16, 185, 129, 0.1);
  border-bottom-color: rgba(16, 185, 129, 0.1);
}

.node--trigger .node-shell {
  border-color: rgba(16, 185, 129, 0.15);
  border-radius: 14px 34px 34px 14px;
}

.node--trigger .node-hover-overlay {
  border-radius: 14px 34px 34px 14px;
}

.node--agent .node-header {
  background: rgba(124, 58, 237, 0.12);
  border-bottom-color: rgba(124, 58, 237, 0.12);
}

.node--agent .node-shell {
  border-color: rgba(124, 58, 237, 0.18);
}

.node--agent-tool .node-header {
  background: rgba(167, 139, 250, 0.1);
  border-bottom-color: rgba(167, 139, 250, 0.1);
}

.node--agent-tool .node-shell {
  border-color: rgba(167, 139, 250, 0.16);
}

.node--agent-tool:not(.is-dragging):hover .node-shell {
  border-color: rgba(167, 139, 250, 0.35);
  box-shadow:
    0 0 0 1px rgba(167, 139, 250, 0.15),
    0 0 18px 3px rgba(167, 139, 250, 0.1),
    0 10px 22px rgba(0, 0, 0, 0.5);
}

.node--trigger:not(.is-dragging):hover .node-shell {
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow:
    0 0 0 1px rgba(16, 185, 129, 0.2),
    0 0 20px 4px rgba(16, 185, 129, 0.15),
    0 0 40px 8px rgba(16, 185, 129, 0.06),
    0 10px 22px rgba(0, 0, 0, 0.5);
}

.node-header {
  padding: 12px 14px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: move;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.node-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.node-title-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 7px;
}

.node-title {
  font-size: 15px;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1.2;
  padding-right: 8px;
  word-break: break-word;
}

.node-kind-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.node-kind-badge--action {
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(59, 130, 246, 0.26);
  color: #7db7ff;
}

.node-kind-badge--data,
.node-kind-badge--datatype {
  background: rgba(234, 88, 12, 0.15);
  border-color: rgba(249, 115, 22, 0.26);
  color: #f7a55c;
}

.node-kind-badge--trigger {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.node-kind-badge--agent {
  background: rgba(88, 28, 135, 0.22);
  border-color: rgba(124, 58, 237, 0.28);
  color: #b794f6;
}

.node-kind-badge--agent-tool {
  background: rgba(88, 28, 135, 0.18);
  border-color: rgba(124, 58, 237, 0.24);
  color: #b794f6;
}

.node-body {
  padding: 14px;
  font-size: 13px;
  color: #cbd5e1;
  min-height: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
}

.node-body > * {
  min-height: 0;
}

.node--data .node-body,
.node--datatype .node-body {
  min-height: 0;
}

.node--has-preview .node-body {
  padding: 0;
}

.node--has-preview .node-inline-previews {
  gap: 0;
}

.node--has-preview .node-inline-preview {
  border-radius: 0;
}

.node-footer {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  min-height: 20px;
  margin-top: auto;
}

.node-technical-id {
  font-size: 11px;
  font-weight: 500;
  color: #9ca3af;
  line-height: 1.2;
  word-break: break-word;
}

.node-port {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  pointer-events: auto;
  z-index: 6;
  user-select: none;
  transition:
    left 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    top 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.node-port.is-port-dragging {
  z-index: 20;
  transition: none;
}

.node-port-dot {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  cursor: grab;
  pointer-events: auto;
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.node-port.is-port-dragging .node-port-dot {
  cursor: grabbing;
  transform: scale(1.06);
}

.node-port--input .node-port-dot {
  background: #f97316;
  border-radius: 6px;
}

.node-port--output .node-port-dot {
  background: #f97316;
  border-radius: 999px;
}

.node-port-text {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 260px;
  pointer-events: none;
}

.node-port-label {
  font-size: 13px;
  font-weight: 700;
  color: #f9fafb;
  line-height: 1.1;
}

.node-port-type {
  font-size: 12px;
  font-weight: 500;
  color: #9ca3af;
  line-height: 1.1;
}

/* ── Flow ports (white) ── */

.node-port--flow .node-port-dot {
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.node-port--flow .node-port-label {
  color: rgba(255, 255, 255, 0.7);
}

.node-port--flow .node-port-type {
  color: rgba(255, 255, 255, 0.4);
}

.node-port--flow.node-port--compatible .node-port-dot {
  box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.5);
  transform: scale(1.3);
}

.node-port--flow[data-optional="true"] .node-port-dot {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

/* Kanten */
.node-port--at-left {
  transform: translate(calc(-100% - 10px), -50%);
  flex-direction: row;
}

.node-port--at-left .node-port-text {
  text-align: right;
}

.node-port--at-right {
  transform: translate(10px, -50%);
  flex-direction: row-reverse;
}

.node-port--at-right .node-port-text {
  text-align: left;
}

.node-port--at-top {
  transform: translate(-50%, calc(-100% - 10px));
  flex-direction: column;
  align-items: center;
}

.node-port--at-top .node-port-text {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.node-port--at-bottom {
  transform: translate(-50%, 10px);
  flex-direction: column-reverse;
  align-items: center;
}

.node-port--at-bottom .node-port-text {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

/* Ecken */
.node-port--at-top-left {
  transform: translate(calc(-100% - 8px), calc(-100% - 8px));
  flex-direction: row;
  align-items: flex-end;
}

.node-port--at-top-left .node-port-text {
  text-align: right;
}

.node-port--at-top-right {
  transform: translate(8px, calc(-100% - 8px));
  flex-direction: row-reverse;
  align-items: flex-end;
}

.node-port--at-top-right .node-port-text {
  text-align: left;
}

.node-port--at-bottom-left {
  transform: translate(calc(-100% - 8px), 8px);
  flex-direction: row;
  align-items: flex-start;
}

.node-port--at-bottom-left .node-port-text {
  text-align: right;
}

.node-port--at-bottom-right {
  transform: translate(8px, 8px);
  flex-direction: row-reverse;
  align-items: flex-start;
}

.node-port--at-bottom-right .node-port-text {
  text-align: left;
}

/* ── App dock (full-height fixed column, like sidebar) ── */

.integration-bar {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 110;
  width: 56px;
  background: #080d1a;
  border-left: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 4px;
}

.integration-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.integration-bar-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition:
    transform 0.18s ease,
    color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.integration-bar-btn:hover {
  transform: translateY(-1px);
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.integration-bar-item.is-running .integration-bar-btn {
  background: rgba(99, 102, 241, 0.14);
  color: #a5b4fc;
}

.integration-bar-item.is-running .integration-bar-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
}

.integration-bar-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

.integration-bar-letter {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.integration-bar-label {
  font-size: 10px;
  font-weight: 500;
  color: #cbd5e1;
  text-align: center;
  line-height: 1.2;
  max-width: 58px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
  transition: color 0.18s ease;
}

.integration-bar-item.is-running .integration-bar-label {
  color: #a5b4fc;
}

.integration-bar-item:hover .integration-bar-label {
  color: #ffffff;
}

/* ── App tab containers inside split ──────────────────── */

.app-tab-container {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  color: #e2e8f0;
  background: transparent;
}

.app-tab-container.is-active {
  display: flex;
}

.tab-panel--app *::-webkit-scrollbar {
  width: 6px;
}

.tab-panel--app *::-webkit-scrollbar-track {
  background: transparent;
}

.tab-panel--app *::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

.tab-panel--app *::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Toasts */
.toast-container {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  color: #fff;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(12px);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast--error {
  background: rgba(185, 28, 28, 0.45);
  box-shadow: 0 8px 24px rgba(185, 28, 28, 0.15);
}

.toast--info {
  background: rgba(37, 99, 235, 0.45);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.15);
}

.toast-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.toast-text b {
  font-weight: 700;
}

.toast-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Config modal */
.config-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.config-modal.is-hidden {
  display: none;
}

.config-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 12, 0.75);
  backdrop-filter: blur(8px);
}

.config-dialog {
  position: relative;
  z-index: 1;
  width: min(1600px, calc(100vw - 48px));
  height: min(90vh, calc(100vh - 48px));
  border-radius: 24px;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 8px 24px rgba(15, 23, 42, 0.14);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-user-select: none;
  user-select: none;
}

.config-dialog input,
.config-dialog textarea,
.config-dialog [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

.config-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 28px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.config-dialog-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.config-node-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 7px;
}

.config-dialog-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.config-dialog-title {
  font-size: 17px;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1.2;
}

.config-dialog-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.3;
  word-break: break-word;
}

.config-kind-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.config-kind-badge--action {
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(59, 130, 246, 0.26);
  color: #7db7ff;
}

.config-kind-badge--data,
.config-kind-badge--datatype {
  background: rgba(234, 88, 12, 0.15);
  border-color: rgba(249, 115, 22, 0.26);
  color: #f7a55c;
}

.config-kind-badge--agent {
  background: rgba(88, 28, 135, 0.22);
  border-color: rgba(124, 58, 237, 0.28);
  color: #b794f6;
}

.config-kind-badge--agent-tool {
  background: rgba(88, 28, 135, 0.18);
  border-color: rgba(124, 58, 237, 0.24);
  color: #b794f6;
}

.config-agent-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-radius: 8px;
  background: rgba(167, 139, 250, 0.06);
  color: #a78bfa;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  margin-left: auto;
  flex-shrink: 0;
}

.config-agent-nav-btn:hover {
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.35);
}

.config-agent-nav-btn svg {
  flex-shrink: 0;
}

.config-agent-tool-mount {
  width: 100%;
}

.config-execute-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 7px 12px 7px 11px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: #ffffff;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  transition:
    background 0.15s ease,
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.config-execute-btn:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
}

.config-execute-btn:active {
  transform: scale(0.96);
}

.config-execute-btn[hidden] {
  display: none;
}

.config-execute-btn.is-executing {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

.config-execute-btn.is-executing:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.5);
}

.config-execute-btn .run-btn-icon--stop {
  display: none;
}
.config-execute-btn.is-executing .run-btn-icon--play {
  display: none;
}
.config-execute-btn.is-executing .run-btn-icon--stop {
  display: inline;
  animation: btn-spin 0.7s linear infinite;
}

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

.config-execute-btn svg {
  flex-shrink: 0;
}

.config-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
  transition:
    background 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.15s ease;
}

.config-delete-btn:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.5);
}

.config-delete-btn:active {
  transform: scale(0.93);
}

.config-close-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  transition:
    background 0.18s ease,
    transform 0.18s ease;
}

.config-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  transform: translateY(-1px);
}

.config-dialog-body {
  flex: 1;
  min-height: 0;
  padding: 24px 28px 28px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
  background:
    radial-gradient(circle at top, rgba(59, 130, 246, 0.05), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.01), rgba(255, 255, 255, 0));
}

.config-dialog-body:has(.config-split) {
  padding: 0 18px;
  align-items: stretch;
  overflow-y: hidden;
}

.config-dialog-body::-webkit-scrollbar { width: 6px; }
.config-dialog-body::-webkit-scrollbar-track { background: transparent; }
.config-dialog-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.config-dialog-body::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

.config-controller-mount {
  width: 100%;
  max-width: min(1120px, 100%);
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 0 auto;
  gap: 0;
}

.config-controller-mount:has(.config-split) {
  max-width: none;
  flex: 1;
  align-self: stretch;
  min-height: 0;
  height: 100%;
}

.controller-drag-over {
  outline: 2px solid rgba(94, 234, 212, 0.45);
  outline-offset: -2px;
  border-radius: 8px;
}

.config-single-controller-mount {
  width: 100%;
  max-width: min(1120px, 100%);
  display: flex;
  align-items: stretch;
  margin: 0 auto;
}

.config-single-controller-mount > * {
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
}

.config-empty-state {
  width: 100%;
  min-height: 120px;
  border: 1px dashed rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}

.config-empty-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  color: #475569;
  font-size: 18px;
  font-weight: 700;
}

.config-empty-title {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
}

.config-empty-text {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.5;
  color: #475569;
}

.config-no-model-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 4px;
  color: #475569;
}

.config-no-model-hint svg {
  flex-shrink: 0;
  opacity: 0.5;
}

.config-no-model-hint span {
  font-size: 11px;
  font-weight: 500;
}

.config-error-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(248, 113, 113, 0.2);
  background: rgba(248, 113, 113, 0.06);
  color: #fca5a5;
  font-size: 12px;
  line-height: 1.5;
}

.config-error-banner svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: #f87171;
}

.config-error-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.config-error-dismiss {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #64748b;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, background 0.12s;
}

.config-error-dismiss:hover {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
}

.config-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 28px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}

.config-footer-btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.config-footer-btn.primary {
  background: #2563eb;
  color: #fff;
}

.config-footer-btn.primary:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.config-footer-btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

.config-input-group {
  width: 100%;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 10px 2px;
  margin-bottom: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.config-input-group:last-child {
  border-bottom: none;
}

.config-input-group--negative-prompt {
  padding: 0 2px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.config-input-group--negative-prompt .config-input-header {
  display: none;
}

.config-input-group--negative-prompt .config-input-controller {
  display: block;
}

.config-input-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.config-input-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.config-input-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

.config-input-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.config-optional-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #475569;
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.config-input-group--connected {
  border-left: 2px solid rgba(249, 115, 22, 0.45);
  border-bottom-style: dashed;
  border-bottom-color: rgba(249, 115, 22, 0.15);
  background: transparent;
  padding-left: 10px;
}

.config-input-group--connected .config-input-header {
  margin-bottom: 6px;
}

.config-agent-sep {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(167, 139, 250, 0.2), transparent);
  margin: 18px 0 14px;
}

.config-agent-tools {
  padding: 0;
  width: 100%;
}

/* ── Config split layout (input left, output right) ── */

.config-split {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 100%;
  flex: 1;
}

.config-split-inputs {
  flex: 1 1 56%;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  padding: 12px 20px 24px 0;
  overflow-y: auto;
}

.config-split-inputs > * {
  width: 100%;
  max-width: none;
}

.config-split-divider {
  flex-shrink: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.06);
  position: relative;
  cursor: col-resize;
  user-select: none;
  -webkit-user-select: none;
}

.config-split-divider::before {
  content: "";
  position: absolute;
  inset: 0 -5px;
  z-index: 1;
}

.config-split-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(167, 139, 250, 0.18));
  transition: background 0.15s, height 0.15s, width 0.15s;
}

.config-split-divider:hover::after,
.config-split-divider.is-dragging::after {
  background: linear-gradient(180deg, rgba(96, 165, 250, 0.45), rgba(167, 139, 250, 0.4));
  height: 52px;
  width: 5px;
}

.config-split-outputs {
  flex: 1 1 44%;
  min-width: 260px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding: 18px 0 24px 20px;
  overflow: hidden;
}

.config-split-outputs > .config-split-col-label {
  flex-shrink: 0;
}

.config-split-outputs > .config-output-controller {
  flex: 1 1 0;
  min-height: 0;
  height: 100%;
}

.config-split-outputs .config-output-controller > * {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

@media (max-width: 1080px) {
  .config-split {
    flex-direction: column;
  }

  .config-split-inputs,
  .config-split-outputs {
    flex: none;
    min-width: 0;
    padding: 12px 0;
  }

  .config-split-divider {
    width: 100%;
    height: 1px;
    cursor: row-resize;
  }

  .config-split-divider::before {
    inset: -5px 0;
  }

  .config-split-divider::after {
    width: 42px;
    height: 4px;
  }
}

.config-split-col-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #64748b;
  padding-bottom: 6px;
  text-align: center;
  flex-shrink: 0;
}

.config-output-controller {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.config-output-preview-shell {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.config-output-preview-body {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.config-output-preview-body > * {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

.config-output-preview-content {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.config-output-preview-body > .config-output-clear-btn {
  width: 22px;
  flex: 0 0 22px;
  min-height: 22px;
}

.config-output-clear-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 8;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.46);
  color: rgba(226, 232, 240, 0.5);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.16s ease, color 0.16s ease;
}

.config-output-clear-btn:hover {
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
}

.config-output-actions-dock {
  width: 100%;
  flex-shrink: 0;
  margin-top: auto;
}

.config-output-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
}

.config-output-actions-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.config-output-actions-list {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  overflow-y: visible;
  gap: 8px;
  padding: 2px 0 6px;
  scroll-snap-type: x proximity;
}

.config-output-action-card {
  appearance: none;
  width: 260px;
  min-width: 260px;
  flex: 0 0 260px;
  margin: 0;
  padding: 8px 10px;
  text-align: left;
  font: inherit;
  line-height: 1.25;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  user-select: none;
  transition: border-color 0.16s ease, background 0.16s ease;
  scroll-snap-align: start;
}

.config-output-action-card:hover {
  border-color: rgba(96, 165, 250, 0.34);
  background: rgba(255, 255, 255, 0.06);
}

.config-output-action-card .palette-node-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.config-output-action-card .palette-node-info strong,
.config-output-action-card-main {
  font-size: 12px;
  line-height: 1.25;
  letter-spacing: 0;
  color: #e5edf8;
}

.config-output-action-connection {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 16px;
  margin-top: 3px;
  margin-bottom: 4px;
  color: #8ea0b8;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.config-output-action-port {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.config-output-action-arrow {
  color: #7db7ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.config-output-action-arrow svg {
  display: block;
}

.config-output-action-card .palette-desc {
  margin-top: 3px;
  font-size: 10px;
  line-height: 1.35;
  color: #8ea0b8;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.config-output-action-card .kind {
  margin-top: 0;
  align-self: flex-start;
}

.is-preview-zoomable {
  cursor: pointer;
}

.config-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  color: #475569;
  height: 100%;
  min-height: 200px;
  padding: 24px;
}

.config-connected-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fb923c;
  background: rgba(249, 115, 22, 0.1);
  white-space: nowrap;
}

.config-connected-badge svg {
  flex-shrink: 0;
}

.config-connected-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(249, 115, 22, 0.7);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.config-connected-open:hover {
  background: #f97316;
}

.config-connected-open:active {
  opacity: 0.85;
}

.config-connected-open svg {
  flex-shrink: 0;
}

/* Connected port: real controller is mounted, no static preview needed */

.config-connected-text {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  padding: 6px 10px;
  word-break: break-word;
  line-height: 1.4;
}

.config-connected-empty {
  display: block;
  font-size: 11px;
  font-weight: 500;
  font-style: italic;
  color: #475569;
  padding: 4px 2px;
}

.config-port-toggle {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  min-width: 42px;
  min-height: 22px;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  color: #64748b;
  background: transparent;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.config-port-toggle:hover {
  border-color: rgba(255, 255, 255, 0.15);
  color: #94a3b8;
}

.config-port-toggle.is-on {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

.config-input-controller {
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  min-width: 0;
}

.config-input-controller > * {
  width: 100%;
  min-height: 0;
}

.config-collapsible-section {
  width: 100%;
  flex-shrink: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
  position: relative;
  z-index: 1;
  margin-top: 10px;
  padding-top: 8px;
}

.config-collapsible-section--subtle {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.config-collapsible-section--subtle .config-collapsible-toggle {
  padding-inline: 0;
}

.config-collapsible-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #94a3b8;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.12s ease;
  text-align: left;
}

.config-collapsible-toggle:hover {
  background: transparent;
  color: #cbd5e1;
}

.config-collapsible-section:not(.is-collapsed) .config-collapsible-toggle {
  color: #cbd5e1;
}

.config-collapsible-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.config-collapsible-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  transition: transform 0.16s ease, color 0.12s ease;
  flex-shrink: 0;
}

.config-collapsible-icon svg {
  display: block;
}

.config-collapsible-section.is-collapsed .config-collapsible-icon {
  transform: rotate(-90deg);
}

.config-collapsible-body {
  padding: 8px 0 2px;
}

.config-collapsible-body > .config-input-group:last-child {
  border-bottom: none;
}

.node-inline-previews {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 0;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

.node-inline-preview {
  position: relative;
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.node-port-flow-actions {
  position: absolute;
  top: 50%;
  left: calc(100% + 10px);
  transform: translateY(-50%);
  z-index: 14;
  pointer-events: auto;
}

.node-port-flow-actions::before {
  content: "";
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: -14px;
  width: 18px;
}

.node-port--has-flow-actions .node-port-dot {
  cursor: pointer;
}

/* + button */
.node-port-flow-actions-btn {
  position: relative;
  z-index: 2;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1.5px solid rgba(96, 165, 250, 0.3);
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.92);
  color: #94a3b8;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-4px) scale(0.92);
  transition:
    opacity 0.18s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.node-port-flow-actions-btn svg {
  pointer-events: none;
}

.node-port.is-flow-actions-hovered .node-port-flow-actions-btn,
.node-port--has-flow-actions:hover .node-port-flow-actions-btn,
.node-port-flow-actions.is-open .node-port-flow-actions-btn {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.node-port-flow-actions-btn:hover {
  border-color: rgba(96, 165, 250, 0.55);
  background: rgba(30, 58, 138, 0.8);
  color: #e2e8f0;
}

.node-port.is-flow-actions-hovered .node-port-dot,
.node-port--has-flow-actions:hover .node-port-dot,
.node-port--has-flow-actions .node-port-dot:hover {
  box-shadow:
    0 0 0 2px rgba(17, 24, 39, 0.14),
    0 0 0 6px rgba(96, 165, 250, 0.14);
}

.node-port--has-flow-actions:hover .node-port-label {
  color: #ffffff;
}

.node-port--has-flow-actions:hover .node-port-type {
  color: #cbd5e1;
}

/* Menu panel */
.node-port-flow-actions-menu {
  position: absolute;
  top: -4px;
  left: -4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 280px;
  max-width: 320px;
  max-height: 360px;
  overflow: auto;
  padding: 40px 8px 8px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(10, 15, 30, 0.95);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(16px);
  opacity: 0;
  transform: scale(0.95) translateY(-4px);
  transform-origin: top left;
  pointer-events: none;
  transition:
    opacity 0.18s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.node-port-flow-actions.is-open .node-port-flow-actions-menu {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.node-port-flow-actions-menu::-webkit-scrollbar,
.config-output-actions-list::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.node-port-flow-actions-menu::-webkit-scrollbar-track,
.config-output-actions-list::-webkit-scrollbar-track {
  background: transparent;
}

.node-port-flow-actions-menu::-webkit-scrollbar-thumb,
.config-output-actions-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.node-port-flow-actions-menu::-webkit-scrollbar-thumb:hover,
.config-output-actions-list::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.34);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.node-port-flow-actions-item {
  width: 100%;
  min-width: 0;
  flex: 0 0 auto;
  margin: 0;
  cursor: pointer;
}

.node-port-flow-actions-item:hover {
  border-color: rgba(96, 165, 250, 0.34);
  background: rgba(255, 255, 255, 0.06);
}

.node-port-flow-actions-empty {
  padding: 10px;
  color: #94a3b8;
  font-size: 11px;
}

.node-inline-preview--output {
  background: transparent;
}

.node-inline-preview {
  position: relative;
}

.node-preview-clear-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.46);
  color: rgba(226, 232, 240, 0.5);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.16s ease, color 0.16s ease;
  pointer-events: auto;
  padding: 0;
}

.node-preview-clear-btn:hover {
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
}

.node-inline-preview-mount .config-empty-state {
  min-height: 90px;
  padding: 12px;
  border-radius: 6px;
}

.node-inline-preview-mount .config-empty-title {
  font-size: 12px;
}

.node-inline-preview-mount .config-empty-text {
  font-size: 11px;
}

.node-inline-preview-mount {
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  overflow: hidden;
}

.node-inline-preview-mount > * {
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
}

.node--has-preview:not(.node--has-media) .node-inline-preview-mount {
  min-height: 140px;
}

.node--has-preview:not(.node--has-media) .node-inline-preview-single {
  min-height: 140px;
}

.node-inline-preview-single {
  width: 100%;
  margin-bottom: 0;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  flex: 1 1 auto;
  overflow: hidden;
}

.node-inline-preview-single > * {
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
}

/* ── Agent sub-tool cards (rendered by app.js) ── */

.vo-agent-text {
  font-size: 13px;
  line-height: 1.6;
  color: #e2e8f0;
  padding: 8px 0;
  word-break: break-word;
  white-space: pre-wrap;
}

.vo-card--sub {
  margin: 8px 0;
  border: 1px solid rgba(167, 139, 250, 0.22) !important;
  border-left: 3px solid rgba(167, 139, 250, 0.5) !important;
  border-radius: 4px 8px 8px 4px;
  opacity: 1 !important;
  background: rgba(167, 139, 250, 0.04) !important;
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.06);
  transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
}

.vo-card--sub .vo-card-header {
  padding: 7px 10px;
  min-height: 30px;
  background: rgba(167, 139, 250, 0.07);
  border-radius: 0 8px 8px 0;
  gap: 6px;
}

.vo-card--sub .vo-card-header .vo-card-status {
  width: 14px;
  height: 14px;
}

.vo-card--sub .vo-card-header .vo-card-status-icon {
  width: 13px;
  height: 13px;
}

.vo-card--sub .vo-card-header .vo-card-icon-wrap {
  width: 16px;
  height: 16px;
}

.vo-card--sub .vo-card-header .vo-card-node-icon {
  width: 14px;
  height: 14px;
}

.vo-card--sub .vo-card-header .vo-card-node-name {
  font-size: 11px;
}

.vo-card--sub .vo-card-header .vo-card-pkg {
  font-size: 10px;
}

.vo-card--sub .vo-card-header .vo-card-sep {
  font-size: 10px;
}

.vo-card--sub:has(.vo-card-body:not([hidden])) .vo-card-header {
  border-radius: 0 8px 0 0;
}

.vo-card--sub .vo-card-body {
  padding: 6px 10px 8px 28px;
  background: rgba(167, 139, 250, 0.02);
}

.vo-card--sub .vo-card-spinner {
  color: #a78bfa;
}

.vo-card--sub.vo-card--done {
  border-color: rgba(74, 222, 128, 0.2) !important;
  border-left-color: rgba(74, 222, 128, 0.5) !important;
  background: rgba(74, 222, 128, 0.03) !important;
  box-shadow: none;
}

.vo-card--sub.vo-card--done .vo-card-header {
  background: rgba(74, 222, 128, 0.05);
}

.vo-card--sub.vo-card--error {
  border-color: rgba(248, 113, 113, 0.2) !important;
  border-left-color: rgba(248, 113, 113, 0.5) !important;
  background: rgba(248, 113, 113, 0.03) !important;
  box-shadow: none;
}

.vo-card--sub.vo-card--error .vo-card-header {
  background: rgba(248, 113, 113, 0.06);
}

.vo-card-inputs {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px 0;
}

.vo-card-input-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  line-height: 1.4;
}

.vo-card-input-label {
  font-weight: 600;
  color: #64748b;
  flex-shrink: 0;
}

.vo-card-input-label::after {
  content: ":";
}

.vo-card-input-value {
  color: #94a3b8;
  word-break: break-word;
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

/* ── Admin Panel ─────────────────────────────────────────── */

.admin-container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 28px 32px 48px;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.admin-container::-webkit-scrollbar { width: 5px; }
.admin-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
/* Full-width for mode editor */
.admin-container:has(.ap--editor) {
  max-width: 100%;
  padding: 0;
  overflow: hidden;
}

.ap {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.ap--editor {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Tabs */
.ap-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #1e2533;
  margin-bottom: 24px;
}

.ap-tab {
  padding: 11px 22px;
  background: none;
  border: none;
  color: #6b7280;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.ap-tab:hover { color: #d1d5db; }
.ap-tab.is-active { color: #818cf8; border-bottom-color: #818cf8; }

/* Table */
.ap-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ap-table-wrap {
  overflow-x: auto;
  border: 1px solid #1e2533;
  border-radius: 10px;
  background: #0a0f1a;
}

.ap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ap-table th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  background: #0d1117;
  border-bottom: 1px solid #1e2533;
}

.ap-th-id { width: 48px; }
.ap-th-center { text-align: center !important; }
.ap-th-right { text-align: right !important; }

.ap-table td {
  padding: 10px 16px;
  border-bottom: 1px solid #111827;
  color: #d1d5db;
}

.ap-table tr:last-child td { border-bottom: none; }
.ap-table tr:hover td { background: rgba(255, 255, 255, 0.015); }

.ap-cell-id { color: #4b5563; font-variant-numeric: tabular-nums; }
.ap-cell-nick { font-weight: 500; color: #e5e7eb; }
.ap-cell-email { color: #9ca3af; }
.ap-cell-center { text-align: center; }
.ap-cell-actions { display: flex; gap: 6px; justify-content: flex-end; }
.ap-empty { text-align: center; color: #4b5563; padding: 32px 16px !important; }

/* Badges */
.ap-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  text-transform: capitalize;
}

.ap-badge--ok { background: rgba(52, 211, 153, 0.1); color: #6ee7b7; border-color: rgba(52, 211, 153, 0.2); }
.ap-badge--warn { background: rgba(251, 191, 36, 0.1); color: #fcd34d; border-color: rgba(251, 191, 36, 0.2); }
.ap-badge--accent { background: rgba(99, 102, 241, 0.12); color: #a5b4fc; border-color: rgba(99, 102, 241, 0.2); }
.ap-badge--muted { background: rgba(255, 255, 255, 0.04); color: #6b7280; border-color: rgba(255, 255, 255, 0.06); }
.ap-clickable { cursor: pointer; transition: opacity 0.15s; }
.ap-clickable:hover { opacity: 0.8; }

/* Buttons */
.ap-btn {
  padding: 7px 16px;
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: #111827;
  color: #d1d5db;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.ap-btn:hover { background: #1e242c; border-color: #374151; color: #f3f4f6; }
.ap-btn--sm { padding: 4px 12px; font-size: 12px; border-radius: 6px; }
.ap-btn--xs { padding: 2px 8px; font-size: 11px; border-radius: 5px; }
.ap-btn--ghost { background: transparent; border-color: transparent; color: #9ca3af; }
.ap-btn--ghost:hover { background: rgba(255, 255, 255, 0.06); color: #e5e7eb; }
.ap-btn--primary { background: linear-gradient(135deg, #6366f1, #818cf8); border-color: #6366f1; color: #fff; font-weight: 600; }
.ap-btn--primary:hover { opacity: 0.9; }
.ap-btn--danger { color: #fca5a5; border-color: rgba(248, 113, 113, 0.15); }
.ap-btn--danger:hover { background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.35); }
.ap-btn--back svg { flex-shrink: 0; }

/* Permission Editor Header */
.ap-perm-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.ap-perm-title {
  font-size: 17px;
  font-weight: 700;
  color: #e2e8f0;
  margin: 0;
  flex: 1;
}

/* Toolbar */
.ap-perm-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.ap-perm-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.ap-perm-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #4b5563;
  pointer-events: none;
}

.ap-perm-search {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: #0d1117;
  border: 1px solid #1e2533;
  border-radius: 8px;
  color: #e5e7eb;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.ap-perm-search:focus { border-color: #6366f1; }
.ap-perm-search::placeholder { color: #4b5563; }

.ap-perm-bulk {
  display: flex;
  gap: 4px;
}

/* Permission grid */
.ap-perm-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ap-perm-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ap-pkg {
  background: #0a0f1a;
  border: 1px solid #161d2d;
  border-radius: 10px;
  overflow: hidden;
}

.ap-pkg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  gap: 10px;
}

.ap-pkg-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #d1d5db;
  flex: 1;
  min-width: 0;
}

.ap-pkg-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: contain;
  flex-shrink: 0;
}

.ap-pkg-icon-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #6b7280;
  flex-shrink: 0;
}

.ap-pkg-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ap-pkg-count {
  font-size: 11px;
  color: #4b5563;
  font-weight: 400;
  flex-shrink: 0;
}

.ap-pkg-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ap-pkg-expand {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, transform 0.2s;
}

.ap-pkg-expand:hover { background: rgba(255, 255, 255, 0.06); }
.ap-pkg-expand.is-expanded svg { transform: rotate(180deg); }

/* Nodes list */
.ap-pkg-nodes {
  padding: 0 14px 10px 46px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ap-pkg-nodes.is-collapsed { display: none; }

.ap-node {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  color: #b0b8c4;
  transition: background 0.1s;
}

.ap-node:hover { background: rgba(255, 255, 255, 0.03); }

.ap-node-name { flex: 1; min-width: 0; }

.ap-node-kind {
  font-size: 10px;
  color: #4b5563;
  padding: 1px 6px;
  background: #111827;
  border-radius: 4px;
  flex-shrink: 0;
}

/* Integrations section */
.ap-perm-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  margin-bottom: 10px;
  padding: 0 2px;
}

.ap-perm-section-label {
  font-size: 13px;
  font-weight: 600;
  color: #9ca3af;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ap-perm-section-actions { display: flex; gap: 4px; }

.ap-int-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 4px;
}

.ap-int-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: #b0b8c4;
  transition: background 0.1s;
}

.ap-int-item:hover { background: rgba(255, 255, 255, 0.03); }
.ap-int-name { flex: 1; min-width: 0; }
.ap-int-pkg { font-size: 10px; color: #4b5563; flex-shrink: 0; }

/* Checkboxes */
.ap-pkg-cb,
.ap-node-cb,
.ap-int-cb {
  accent-color: #6366f1;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Toast */
.ap-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.ap-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Agent Modes */
.ap-modes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.ap-modes-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  margin: 0;
}
.ap-modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}
.ap-mode-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 14px 16px;
  transition: border-color 0.15s;
}
.ap-mode-card.is-active {
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.04);
}
.ap-mode-card:hover {
  border-color: rgba(255,255,255,0.12);
}
.ap-mode-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.ap-mode-name {
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
}
.ap-mode-desc {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  margin: 0 0 10px;
  line-height: 1.4;
}
.ap-mode-detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.ap-mode-section {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
}
.ap-mode-section-label {
  color: rgba(255,255,255,0.35);
  min-width: 70px;
}
.ap-mode-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(99, 149, 255, 0.1);
  color: rgba(99, 149, 255, 0.8);
  font-size: 10px;
}
.ap-mode-badge--inj {
  background: rgba(52, 211, 153, 0.1);
  color: rgba(52, 211, 153, 0.8);
}
.ap-mode-none {
  color: rgba(255,255,255,0.2);
  font-style: italic;
}

.ap-mode-actions {
  display: flex;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.04);
}

/* Editor top bar */
.ap-editor-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.ap-editor-bar-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
}

/* Mode editor */
.ap-mode-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ap-mode-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ap-mode-label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
}
.ap-mode-input {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  color: #e2e8f0;
  outline: none;
  transition: border-color 0.15s;
}
.ap-mode-input:focus {
  border-color: rgba(99, 149, 255, 0.4);
}
.ap-mode-input[readonly] {
  opacity: 0.5;
  cursor: not-allowed;
}
.ap-mode-input--sm {
  max-width: 100px;
}
.ap-mode-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.ap-mode-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: #e2e8f0;
  cursor: pointer;
}
.ap-mode-check input[type="checkbox"] {
  accent-color: #6366f1;
}
.ap-mode-textarea {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #e2e8f0;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  min-height: 200px;
  transition: border-color 0.15s;
}
.ap-mode-textarea:focus {
  border-color: rgba(99, 149, 255, 0.4);
}

/* Mode editor layout (side-by-side with preview) */
.ap-mode-layout {
  display: flex;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.ap-mode-layout .ap-mode-editor {
  flex: 1;
  min-width: 0;
  padding: 20px 28px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.ap-mode-layout .ap-mode-editor::-webkit-scrollbar { width: 5px; }
.ap-mode-layout .ap-mode-editor::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* Preview panel */
.ap-mode-preview {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(0,0,0,0.15);
  border-left: 1px solid rgba(255,255,255,0.06);
}

.ap-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.ap-preview-title {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.ap-preview-sample {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.ap-preview-sample .ap-mode-input {
  flex: 1;
  font-size: 11px;
  padding: 4px 8px;
  min-width: 0;
}
.ap-preview-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 8px;
  flex-shrink: 0;
}
.ap-preview-tab {
  background: none;
  border: none;
  padding: 7px 10px;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.ap-preview-tab:hover { color: rgba(255,255,255,0.7); }
.ap-preview-tab.is-active {
  color: #a5b4fc;
  border-bottom-color: #6366f1;
}
.ap-preview-tokens {
  display: flex;
  gap: 12px;
  padding: 6px 12px;
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  border-bottom: 1px solid rgba(255,255,255,0.04);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.ap-preview-total {
  color: rgba(255,255,255,0.55);
  font-weight: 600;
}
.ap-preview-body {
  flex: 1;
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.ap-preview-body::-webkit-scrollbar { width: 5px; }
.ap-preview-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.ap-preview-code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 11px;
  line-height: 1.5;
  color: rgba(255,255,255,0.7);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 8px;
  background: rgba(0,0,0,0.15);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.04);
}
.ap-preview-code--json {
  color: rgba(99, 149, 255, 0.8);
}
.ap-preview-empty, .ap-preview-loading {
  text-align: center;
  padding: 24px 12px;
  font-size: 12px;
  color: rgba(255,255,255,0.25);
}
.ap-preview-inj-block {
  margin-bottom: 10px;
}
.ap-preview-inj-name {
  font-size: 11px;
  font-weight: 600;
  color: rgba(52, 211, 153, 0.7);
  margin-bottom: 4px;
  padding-left: 4px;
}

/* ─── Usage tab ─── */
.ap-usage-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.ap-period-group {
  display: flex;
  gap: 4px;
}
.ap-stat-cards {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.ap-stat-card {
  flex: 1 1 0;
  min-width: 120px;
  padding: 16px 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ap-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  letter-spacing: -0.02em;
}
.ap-stat-label {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ap-stat--warn .ap-stat-value {
  color: rgba(251, 146, 60, 0.9);
}
.ap-table--usage th,
.ap-table--usage td {
  padding: 8px 10px;
  font-size: 12px;
}
.ap-cell-ts {
  white-space: nowrap;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}
.ap-cell-model {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ap-cell-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ap-badge--type {
  background: rgba(99, 149, 255, 0.12);
  color: rgba(99, 149, 255, 0.85);
}
.ap-badge--danger {
  background: rgba(239, 68, 68, 0.15);
  color: rgba(239, 68, 68, 0.85);
}

/* ─── API Keys tab ─── */
.ap-keys-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  margin: 0 0 20px;
  line-height: 1.5;
}
.ap-key-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.ap-key-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s;
}
.ap-key-card--set {
  border-color: rgba(52, 211, 153, 0.2);
}
.ap-key-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ap-key-card-name {
  font-weight: 600;
  font-size: 14px;
  color: rgba(255,255,255,0.85);
}
.ap-key-card-masked {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.2);
  padding: 6px 10px;
  border-radius: 6px;
}
.ap-key-card-actions {
  display: flex;
  gap: 6px;
}
.ap-key-card-input {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}
.ap-key-card-input .ap-mode-input {
  flex: 1;
  min-width: 0;
}
.ap-keys-other-title,
.ap-keys-add-title {
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  margin: 0 0 12px;
}
.ap-keys-add {
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.ap-keys-add-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.ap-keys-add-form .ap-mode-input {
  flex: 1 1 160px;
  min-width: 120px;
}

/* ─── Pricing tab ─── */
.ap-pricing-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.ap-pricing-currency {
  display: flex;
  gap: 4px;
}
.ap-pricing-eur-rate {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ap-pricing-rate-label {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
}
.ap-pricing-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.ap-pricing-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  overflow: hidden;
}
.ap-pricing-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(255,255,255,0.025);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.ap-pricing-card-name {
  font-weight: 700;
  font-size: 15px;
  color: rgba(255,255,255,0.85);
}
.ap-pricing-card-body {
  padding: 0;
  overflow-x: auto;
}
.ap-table--pricing th,
.ap-table--pricing td {
  padding: 7px 10px;
  font-size: 12px;
}
.ap-pricing-model {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 11px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ap-pricing-row--override {
  background: rgba(99, 149, 255, 0.04);
}
.ap-cell-mono {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.ap-badge--xs {
  font-size: 9px;
  padding: 1px 5px;
  vertical-align: middle;
}

/* ─── Pricing dialog ─── */
.ap-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.ap-dialog-overlay.is-visible {
  opacity: 1;
}
.ap-dialog {
  background: #1a1c22;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.ap-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ap-dialog-title {
  font-weight: 600;
  font-size: 14px;
  color: rgba(255,255,255,0.85);
}
.ap-dialog-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ap-dialog-hint {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  margin: 0 0 4px;
}
.ap-dialog-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ap-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ─── Usage cost enhancements ─── */
.ap-stat--cost .ap-stat-value {
  color: rgba(52, 211, 153, 0.9);
}
.ap-stat-sub {
  font-size: 12px;
  font-weight: 500;
  color: rgba(52, 211, 153, 0.65);
  font-variant-numeric: tabular-nums;
}
.ap-cell-cost--high {
  color: rgba(251, 146, 60, 0.85);
}
.ap-usage-providers {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.ap-usage-provider-chip {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 6px 12px;
  font-variant-numeric: tabular-nums;
}
.ap-usage-provider-chip strong {
  color: rgba(255,255,255,0.8);
}
