* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-sidebar: #0A0A0A;
  --bg-dark-surface: #1A1A1A;
  --bg-page: #FFFFFF;
  --bg-surface-tint: #F5F5F5;
  --border-gray: #E0E0E0;
  --text-primary: #0A0A0A;
  --text-secondary: #777777;
  --text-muted: #999999;
  --text-on-dark: #FFFFFF;
  --accent-red: #FF3B30;
  --accent-green: #22C55E;
  --accent-orange: #D29922;
  --gray-700: #666666;
  --radius: 6px;
  --font-heading: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
}

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* ---- Sidebar ---- */

#sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  padding: 32px;
  color: var(--text-on-dark);
}

#logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

#logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent-red);
  border-radius: 4px;
}

#logo-text {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
}

/* Nav */

#nav-section {
  display: flex;
  flex-direction: column;
  margin-top: 40px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  font-family: var(--font-heading);
  font-size: 15px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
  cursor: pointer;
}

.nav-item::before {
  content: attr(data-num);
  font-size: 12px;
  color: var(--text-muted);
  min-width: 18px;
}

.nav-item:hover {
  color: var(--text-on-dark);
}

.nav-item.active {
  color: var(--text-on-dark);
  font-weight: 600;
}

.nav-item.active::before {
  color: var(--accent-red);
  font-weight: 600;
}

#sidebar-spacer {
  flex: 1;
}

/* Connect box */

#connect-box {
  background: var(--bg-dark-surface);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#connect-box-label {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#connect-row, #session-row {
  display: flex;
  gap: 8px;
}

#connect-box input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #333;
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  font-family: var(--font-body);
  font-size: 12px;
  outline: none;
}

#connect-box input[type="text"]:focus {
  border-color: var(--accent-red);
}

#connect-box button {
  padding: 6px 12px;
  border-radius: 4px;
  border: none;
  background: var(--accent-red);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

#connect-box button:hover {
  opacity: 0.9;
}

#session-row.hidden {
  display: none;
}

/* User area */

#user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
}

#user-avatar {
  width: 36px;
  height: 36px;
  background: var(--accent-red);
  border-radius: 50%;
}

#user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#user-name {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
}

.status {
  font-size: 11px;
  font-weight: 500;
}

.status.disconnected { color: var(--accent-red); }
.status.connected    { color: var(--accent-green); }
.status.connecting   { color: var(--accent-orange); }

/* ---- Main Area ---- */

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Top Bar */

#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  min-height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-gray);
  background: var(--bg-page);
}

#top-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-heading);
  font-size: 15px;
}

#breadcrumb-prefix { color: var(--text-secondary); }
#breadcrumb-sep    { color: var(--text-muted); }
#breadcrumb-name   { color: var(--text-primary); font-weight: 700; }

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

#session-badge {
  background: var(--bg-surface-tint);
  border: 1px solid var(--border-gray);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

#session-badge.hidden { display: none; }

#top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-outline {
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-gray);
  background: transparent;
  color: var(--gray-700);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.btn-outline:hover { background: var(--bg-surface-tint); }

.btn-primary {
  padding: 10px 18px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent-red);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.btn-primary:hover { opacity: 0.9; }

.btn-small {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}

.btn-ghost:hover { color: var(--text-primary); }

/* ---- Views ---- */

#views {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.view.active {
  display: flex;
}

/* ---- Workflows View (project list) ---- */

#workflows-view {
  overflow-y: auto;
  padding: 24px;
}

#projects-header {
  margin-bottom: 24px;
}

#projects-header h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

#projects-empty {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

#projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Project card */

.project-card {
  border: 1px solid var(--border-gray);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s;
}

.project-card:hover {
  border-color: var(--text-muted);
}

.project-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.project-card-name {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
}

.project-card-type {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.project-card-type.crew {
  background: #FFF0EF;
  color: var(--accent-red);
}

.project-card-type.flow {
  background: #F0FFF4;
  color: var(--accent-green);
}

.project-card-type.unknown {
  background: var(--bg-surface-tint);
  color: var(--text-muted);
}

.project-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.project-card-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.project-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Project inputs */

.project-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border-gray);
}

.project-input-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-input-label {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: lowercase;
}

.project-input-field {
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-gray);
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 12px;
  outline: none;
}

.project-input-field:focus {
  border-color: var(--accent-red);
}

.project-input-field::placeholder {
  color: var(--text-muted);
}

.project-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.project-card-actions button {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.project-run-btn {
  background: var(--accent-red);
  border: none;
  color: #fff;
}

.project-run-btn:hover { opacity: 0.9; }

.project-view-btn {
  background: transparent;
  border: 1px solid var(--border-gray);
  color: var(--gray-700);
}

.project-view-btn:hover { background: var(--bg-surface-tint); }

/* ---- Chat View ---- */

#chat-view {
  overflow: hidden;
}

#chat-split {
  flex: 1;
  display: flex;
  overflow: hidden;
}

#chat {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  background: var(--bg-surface-tint);
  padding: 10px 16px;
  border-radius: var(--radius);
  align-self: flex-start;
  max-width: 80%;
  color: var(--text-primary);
  font-family: var(--font-body);
}

.msg.assistant {
  display: flex;
  gap: 8px;
  align-self: flex-start;
  max-width: 90%;
  padding: 7px 0 0 0;
  color: var(--text-secondary);
  font-family: var(--font-body);
}

.msg.assistant::before {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  min-width: 6px;
  border-radius: 50%;
  background: var(--accent-red);
  margin-top: 7px;
}

.msg.system {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  align-self: center;
}

.msg.error {
  color: var(--accent-red);
  font-size: 11px;
  text-align: center;
  align-self: center;
}

.msg.tool {
  font-size: 12px;
  color: var(--text-muted);
  font-family: "SF Mono", "Fira Code", monospace;
  background: var(--bg-surface-tint);
  border: 1px solid var(--border-gray);
  border-radius: var(--radius);
  padding: 8px 12px;
  align-self: flex-start;
  max-width: 90%;
}

/* ---- Tool Group (collapsible) ---- */

.tool-group {
  align-self: flex-start;
  width: 100%;
  max-width: 90%;
}

.tool-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-tint);
  border: 1px solid var(--border-gray);
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text-secondary);
  width: auto;
  display: inline-flex;
}

.tool-group-header:hover {
  border-color: var(--text-muted);
}

.tool-group-header.expanded .tool-group-chevron {
  transform: rotate(180deg);
}

.tool-group-spinner {
  width: 10px;
  height: 10px;
  border: 2px solid var(--border-gray);
  border-top-color: var(--accent-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.tool-group-label {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.tool-group-count {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.tool-group-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.15s;
}

.tool-group-items {
  padding: 6px 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tool-group-items.collapsed {
  display: none;
}

.tool-group-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}

.tool-icon {
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}

.msg .label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  color: var(--text-muted);
}

/* Thinking indicator */

#thinking {
  display: none;
  align-self: flex-start;
  padding: 10px 0 0 0;
  gap: 4px;
  align-items: center;
}

#thinking.visible { display: flex; }

#thinking .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-red);
  animation: bounce 1.2s infinite ease-in-out;
}

#thinking .dot:nth-child(2) { animation-delay: 0.2s; }
#thinking .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input Area */

#input-area {
  border-top: 2px solid var(--border-gray);
  padding: 12px 20px 14px 20px;
  background: var(--bg-page);
  position: relative;
}

#input-resize-handle {
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
  z-index: 2;
}

#input-resize-handle:hover,
#input-resize-handle.dragging {
  background: linear-gradient(to bottom, transparent, rgba(255, 59, 48, 0.15));
}

#prompt-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  min-height: 40px;
}

#prompt-form.hidden { display: none; }

#prompt-input {
  flex: 1;
  min-height: 40px;
  max-height: 200px;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-gray);
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  resize: none;
  line-height: 1.5;
  overflow-y: auto;
  field-sizing: content;
}

#prompt-input:focus { border-color: var(--accent-red); }
#prompt-input::placeholder { color: var(--text-muted); }

#send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent-red);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#send-btn:hover { opacity: 0.9; }

/* ---- Execution Drawer ---- */

#exec-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 560px;
  min-width: 360px;
  max-width: 80vw;
  height: 100%;
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 10;
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}

#exec-resize-handle {
  position: absolute;
  top: 0;
  left: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 11;
}

#exec-resize-handle:hover,
#exec-resize-handle.dragging {
  background: var(--accent-red);
  opacity: 0.5;
}

#exec-drawer.drawer-open {
  transform: translateX(0);
}

#exec-drawer.drawer-closed {
  transform: translateX(100%);
}

#exec-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #333;
  min-height: 56px;
}

#exec-drawer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
}

#exec-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 1.5s infinite;
}

#exec-status-dot.stopped { background: var(--accent-red); animation: none; }
#exec-status-dot.done    { background: var(--accent-green); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#exec-drawer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#exec-drawer-actions .btn-outline {
  border-color: #444;
  color: var(--text-muted);
}

#exec-drawer-actions .btn-outline:hover {
  background: #222;
  color: var(--text-on-dark);
}

#exec-drawer-actions .btn-ghost {
  color: var(--text-muted);
}

#exec-drawer-actions .btn-ghost:hover {
  color: var(--text-on-dark);
}

/* Env vars section */

#exec-env-section {
  border-bottom: 1px solid #333;
  padding: 0 20px;
}

#exec-env-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  cursor: pointer;
}

#exec-env-label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

#exec-env-body {
  overflow: hidden;
  transition: max-height 0.2s ease, padding 0.2s ease;
  max-height: 300px;
  padding-bottom: 12px;
}

#exec-env-body.collapsed {
  max-height: 0;
  padding-bottom: 0;
}

#exec-env-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.env-var-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 11px;
}

.env-var-key {
  color: var(--accent-green);
  min-width: 100px;
}

.env-var-value {
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.env-var-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
  line-height: 1;
}

.env-var-remove:hover {
  color: var(--accent-red);
}

#exec-env-add-row {
  display: flex;
  gap: 6px;
}

#exec-env-add-row input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid #333;
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 11px;
  outline: none;
}

#exec-env-key {
  max-width: 120px;
  text-transform: uppercase;
}

#exec-env-add-row input:focus {
  border-color: var(--accent-red);
}

#exec-env-add-row .btn-outline {
  border-color: #444;
  color: var(--text-muted);
  padding: 5px 10px;
  font-size: 11px;
}

#exec-env-add-row .btn-outline:hover {
  background: #222;
  color: var(--text-on-dark);
}

#exec-output {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: #CCC;
}

#exec-output::-webkit-scrollbar { width: 6px; }
#exec-output::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

/* ---- Scrollbar ---- */

#chat::-webkit-scrollbar { width: 6px; }
#chat::-webkit-scrollbar-thumb { background: var(--border-gray); border-radius: 3px; }

#workflows-view::-webkit-scrollbar { width: 6px; }
#workflows-view::-webkit-scrollbar-thumb { background: var(--border-gray); border-radius: 3px; }

/* ---- Settings View ---- */

#settings-view {
  overflow-y: auto;
  padding: 24px;
}

#settings-container {
  max-width: 480px;
}

#settings-container h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.settings-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

#settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-field label {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-field input {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-gray);
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
}

.settings-field input:focus {
  border-color: var(--accent-red);
}

.settings-field input::placeholder {
  color: var(--text-muted);
}

.settings-token-status {
  font-size: 11px;
  color: var(--text-muted);
}

.settings-token-status.saved {
  color: var(--accent-green);
}

#settings-save-btn {
  align-self: flex-start;
  margin-top: 8px;
}

/* ---- Card Environment Variables ---- */

.project-env-section {
  padding-top: 4px;
}

.project-env-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 2px 0;
}

.project-env-toggle:hover {
  color: var(--gray-900);
}

.project-env-icon {
  transition: transform 0.15s;
}

.project-env-icon.expanded {
  transform: rotate(90deg);
}

.project-env-count {
  color: var(--text-muted);
  font-size: 10px;
}

.project-env-body {
  padding-top: 6px;
}

.project-env-body.collapsed {
  display: none;
}

.project-env-add-row {
  display: flex;
  gap: 4px;
  align-items: center;
}

.project-env-add-row input {
  padding: 3px 6px;
  border: 1px solid var(--border-gray);
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--font-mono, monospace);
  background: var(--bg-main);
  color: var(--gray-900);
  outline: none;
  min-width: 0;
}

.project-env-add-row input:first-child {
  flex: 0.8;
}

.project-env-add-row input:nth-child(2) {
  flex: 1.2;
}

.project-env-add-row input:focus {
  border-color: var(--accent-red);
}

.project-env-add-row input::placeholder {
  color: var(--text-muted);
}

.project-env-add-row .btn-small {
  padding: 3px 8px;
  font-size: 10px;
}

.project-env-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  font-size: 10px;
}

.project-env-key {
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  color: var(--gray-900);
}

.project-env-val {
  font-family: var(--font-mono, monospace);
  color: var(--text-muted);
}

.project-env-remove {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0 2px;
}

.project-env-remove:hover {
  color: var(--accent-red);
}

/* ---- Deploy Button & Status ---- */

.project-deploy-btn {
  background: transparent;
  border: 1px solid var(--border-gray);
  color: var(--gray-700);
}

.project-deploy-btn:hover {
  background: var(--bg-surface-tint);
  border-color: var(--text-muted);
}

.project-card-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-delete-btn {
  background: transparent;
  border: none;
  color: var(--gray-500);
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.project-card:hover .project-delete-btn {
  opacity: 1;
}

.project-delete-btn:hover {
  background: #fee2e2;
  color: var(--accent-red);
}

.project-deploy-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  padding-top: 4px;
}

.deploy-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.deploy-dot.in-progress {
  background: var(--accent-orange);
  animation: pulse 1.5s infinite;
}

.deploy-dot.deployed {
  background: var(--accent-green);
}

.deploy-dot.failed {
  background: var(--accent-red);
}

.deploy-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deploy-logs-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.deploy-logs-btn:hover {
  color: var(--text-primary);
}

/* ---- Blueprint Toggle Button ---- */

#blueprint-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#blueprint-toggle-btn svg {
  opacity: 0.6;
}

#blueprint-toggle-btn.active {
  background: var(--bg-surface-tint);
  border-color: var(--accent-red);
  color: var(--accent-red);
}

#blueprint-toggle-btn.active svg {
  opacity: 1;
  stroke: var(--accent-red);
}

/* ---- Blueprint Panel ---- */

#blueprint-panel {
  width: 420px;
  min-width: 280px;
  max-width: 70vw;
  border-left: 1px solid var(--border-gray);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-page);
  position: relative;
}

#blueprint-panel.bp-hidden {
  display: none;
}

#bp-resize-handle {
  position: absolute;
  top: 0;
  left: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}

#bp-resize-handle:hover,
#bp-resize-handle.dragging {
  background: var(--accent-red);
  opacity: 0.4;
}

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

#bp-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

#bp-header-left svg {
  color: var(--text-muted);
}

#bp-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

#bp-content::-webkit-scrollbar { width: 6px; }
#bp-content::-webkit-scrollbar-thumb { background: var(--border-gray); border-radius: 3px; }

#bp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px 20px;
}

#bp-empty p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0;
}

.bp-empty-hint {
  font-size: 11px !important;
  color: var(--text-muted);
}

/* ---- Blueprint: Type badges ---- */

.bp-type-badge {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 3px;
  text-transform: uppercase;
}

.bp-badge-crew {
  background: #FFF0EF;
  color: var(--accent-red);
}

.bp-badge-flow {
  background: #F0FFF4;
  color: var(--accent-green);
}

.bp-process-badge {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---- Blueprint: Crew ---- */

.bp-crew {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bp-crew-nested {
  padding: 12px;
  border: 1px solid var(--border-gray);
  border-radius: var(--radius);
  background: var(--bg-surface-tint);
}

.bp-crew-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bp-crew-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bp-crew-name {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ---- Blueprint: Pipeline (task flow) ---- */

.bp-pipeline {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.bp-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 0;
}

.bp-connector-line {
  width: 2px;
  height: 16px;
  background: var(--border-gray);
}

.bp-connector-arrow {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--border-gray);
}

/* ---- Blueprint: Task node ---- */

.bp-task-node {
  border: 1px solid var(--border-gray);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--bg-page);
  transition: border-color 0.15s;
}

.bp-task-node:hover {
  border-color: var(--text-muted);
}

.bp-task-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.bp-task-name {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.bp-task-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 6px;
}

.bp-task-agent {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.bp-agent-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-red);
  flex-shrink: 0;
}

.bp-task-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.bp-tool-tag-sm {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 9px;
  background: var(--bg-surface-tint);
  border: 1px solid var(--border-gray);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text-muted);
}

.bp-task-context {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
}

/* ---- Blueprint: Agents section ---- */

.bp-agents-section {
  border-top: 1px solid var(--border-gray);
  padding-top: 12px;
}

.bp-agents-header {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.bp-agents-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bp-agent-card {
  flex: 1;
  min-width: 120px;
  border: 1px solid var(--border-gray);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--bg-page);
}

.bp-agent-name {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.bp-agent-role {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 4px;
}

.bp-agent-repo {
  font-size: 10px;
  color: var(--accent-orange);
  font-style: italic;
  margin-bottom: 4px;
}

.bp-agent-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.bp-tool-tag {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 9px;
  background: var(--bg-surface-tint);
  border: 1px solid var(--border-gray);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text-muted);
}

/* ---- Blueprint: Flow ---- */

.bp-flow {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bp-flow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bp-flow-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bp-flow-name {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ---- Blueprint: State fields ---- */

.bp-state-section {
  border: 1px solid var(--border-gray);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--bg-surface-tint);
}

.bp-state-label {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.bp-state-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.bp-state-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  background: var(--bg-page);
  border: 1px solid var(--border-gray);
  border-radius: 3px;
  padding: 2px 6px;
}

.bp-state-field-name {
  font-family: "SF Mono", "Fira Code", monospace;
  font-weight: 500;
  color: var(--text-primary);
}

.bp-state-field-type {
  font-family: "SF Mono", "Fira Code", monospace;
  color: var(--text-muted);
  font-size: 10px;
}

/* ---- Blueprint: Steps ---- */

.bp-steps {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.bp-step-node {
  border: 1px solid var(--border-gray);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--bg-page);
  transition: border-color 0.15s;
}

.bp-step-node:hover {
  border-color: var(--text-muted);
}

.bp-step-start {
  border-left: 3px solid var(--accent-green);
}

.bp-step-router {
  border-left: 3px solid var(--accent-orange);
}

.bp-step-listen {
  border-left: 3px solid #6366F1;
}

.bp-step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.bp-step-decorator-badge {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
}

.bp-dec-start {
  background: #F0FFF4;
  color: var(--accent-green);
}

.bp-dec-listen {
  background: #EEF2FF;
  color: #6366F1;
}

.bp-dec-router {
  background: #FFF7ED;
  color: var(--accent-orange);
}

.bp-step-name {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.bp-step-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.bp-step-listens {
  font-family: "SF Mono", "Fira Code", monospace;
  color: var(--text-secondary);
}

.bp-step-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---- Blueprint: Nested crews in steps ---- */

.bp-step-crews {
  margin-top: 8px;
}

.bp-nested-crew-summary {
  border: 1px solid var(--border-gray);
  border-radius: var(--radius);
  overflow: hidden;
}

.bp-nested-crew-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #FFF0EF;
  cursor: default;
}

.bp-nested-crew-icon {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent-red);
  flex-shrink: 0;
}

.bp-nested-crew-name {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
}

.bp-nested-crew-meta {
  font-size: 10px;
  color: var(--text-secondary);
  flex: 1;
}

.bp-expand-btn {
  padding: 2px !important;
  color: var(--text-muted) !important;
}

.bp-nested-crew-body {
  transition: max-height 0.25s ease, padding 0.25s ease;
  max-height: 1000px;
  padding: 8px;
}

.bp-nested-crew-body.bp-collapsed {
  max-height: 0;
  padding: 0 8px;
  overflow: hidden;
}

/* ---- Blueprint: Branches (router) ---- */

.bp-branches {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 8px 0;
}

.bp-branch {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}

.bp-branch-label {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 10px;
  font-weight: 500;
  color: var(--accent-orange);
  background: #FFF7ED;
  padding: 1px 6px;
  border-radius: 3px;
}

.bp-branch-connector {
  width: 2px;
  height: 12px;
  background: var(--accent-orange);
  opacity: 0.4;
}

.bp-branch-target {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border-gray);
  border-radius: var(--radius);
  padding: 4px 10px;
  background: var(--bg-page);
}

/* ---- Blueprint: View button on project cards ---- */

.project-view-btn {
  background: transparent;
  border: 1px solid var(--border-gray);
  color: var(--gray-700);
}

.project-view-btn:hover {
  background: var(--bg-surface-tint);
  border-color: var(--text-muted);
}

/* ================================================================
   STUDIO: Visual Workflow Builder
   ================================================================ */

#studio-view.active {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---- Template Picker ---- */

#studio-picker {
  flex: 1;
  overflow-y: auto;
  padding: 40px 48px;
}

#studio-picker.hidden { display: none; }

#studio-picker-header {
  margin-bottom: 32px;
}

#studio-title {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

#studio-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Category filter */

#studio-categories {
  display: flex;
  gap: 6px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.studio-cat {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-gray);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.studio-cat:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.studio-cat.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--text-on-dark);
}

/* Template cards grid */

#studio-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.studio-template-card {
  border: 1px solid var(--border-gray);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-page);
}

.studio-template-card:hover {
  border-color: var(--text-muted);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

.studio-template-card.scratch {
  border-style: dashed;
  border-width: 2px;
}

.studio-template-card.scratch:hover {
  border-color: var(--accent-red);
}

.studio-tpl-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: currentColor;
  position: relative;
}

.studio-tpl-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: currentColor;
  opacity: 0.1;
}

.studio-tpl-icon svg {
  position: relative;
  z-index: 1;
}

.studio-tpl-info {
  flex: 1;
  min-width: 0;
}

.studio-tpl-info h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.studio-tpl-info p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.studio-tpl-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-surface-tint);
  padding: 2px 8px;
  border-radius: 10px;
}

/* ---- Flow Builder ---- */

#studio-builder {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#studio-builder.hidden { display: none; }

/* Toolbar */

#studio-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-gray);
  background: var(--bg-page);
  min-height: 56px;
}

#studio-toolbar .btn-ghost {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

#studio-toolbar .btn-ghost:hover {
  color: var(--text-primary);
}

#studio-toolbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

#studio-name-input {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  border: none;
  background: transparent;
  text-align: center;
  outline: none;
  width: 300px;
  padding: 6px 12px;
  border-radius: var(--radius);
}

#studio-name-input:hover {
  background: var(--bg-surface-tint);
}

#studio-name-input:focus {
  background: var(--bg-surface-tint);
  box-shadow: 0 0 0 2px var(--accent-red);
}

#studio-name-input::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

#studio-generate-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 13px;
}

#studio-generate-btn svg {
  flex-shrink: 0;
}

/* Workspace (3-column layout) */

#studio-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Left: Block palette */

#studio-palette {
  width: 240px;
  min-width: 200px;
  border-right: 1px solid var(--border-gray);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface-tint);
  overflow-y: auto;
}

#studio-palette-header {
  padding: 16px 16px 12px;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

#studio-palette-blocks {
  padding: 0 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.studio-palette-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.studio-palette-block:hover {
  background: var(--bg-page);
  border-color: var(--border-gray);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.studio-palette-block[draggable="true"] {
  cursor: grab;
}

.studio-palette-block[draggable="true"]:active {
  cursor: grabbing;
}

.studio-pb-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: currentColor;
  position: relative;
}

.studio-pb-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: currentColor;
  opacity: 0.1;
}

.studio-pb-icon svg {
  position: relative;
  z-index: 1;
}

.studio-pb-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.studio-pb-name {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.studio-pb-desc {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Center: Flow canvas */

#studio-canvas {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

#studio-canvas::-webkit-scrollbar { width: 6px; }
#studio-canvas::-webkit-scrollbar-thumb { background: var(--border-gray); border-radius: 3px; }

/* Goal description */

#studio-flow-description {
  width: 100%;
  max-width: 520px;
  margin-bottom: 24px;
}

#studio-flow-description label {
  display: block;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

#studio-goal-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-gray);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  line-height: 1.5;
}

#studio-goal-input:focus {
  border-color: var(--accent-red);
}

#studio-goal-input::placeholder {
  color: var(--text-muted);
}

/* Flow blocks area */

#studio-flow-blocks {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.studio-flow-empty {
  padding: 60px 20px;
  text-align: center;
}

.studio-flow-empty p {
  font-size: 14px;
  color: var(--text-muted);
  margin: 4px 0;
}

.studio-flow-empty-hint {
  font-size: 12px !important;
}

/* Block node */

.studio-block-node {
  width: 100%;
  border: 1px solid var(--border-gray);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  background: var(--bg-page);
  position: relative;
}

.studio-block-node:hover {
  border-color: var(--text-muted);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.studio-block-node.selected {
  border-color: var(--block-color, var(--accent-red));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--block-color, var(--accent-red)) 15%, transparent);
}

.studio-block-node.dragging {
  opacity: 0.5;
}

.studio-block-node.studio-drop-target {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.studio-block-accent {
  width: 4px;
  min-width: 4px;
  background: var(--block-color, var(--accent-red));
}

.studio-block-content {
  flex: 1;
  padding: 14px 16px;
  min-width: 0;
}

.studio-block-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.studio-block-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  position: relative;
}

.studio-block-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: currentColor;
  opacity: 0.1;
}

.studio-block-icon svg {
  position: relative;
  z-index: 1;
}

.studio-block-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.studio-block-name {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.studio-block-type-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.studio-block-number {
  width: 22px;
  height: 22px;
  min-width: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-surface-tint);
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.studio-block-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.studio-block-desc.placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* Connectors between blocks */

.studio-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 0;
  position: relative;
}

.studio-connector-line {
  width: 2px;
  height: 20px;
  background: var(--border-gray);
}

.studio-connector-arrow {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--border-gray);
}

.studio-connector-add {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border-gray);
  background: var(--bg-page);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.15s;
}

.studio-connector:hover .studio-connector-add {
  opacity: 1;
}

.studio-connector-add:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
  background: #FFF0EF;
}

.studio-connector.studio-drop-hover .studio-connector-line {
  background: var(--accent-green);
}

.studio-connector.studio-drop-hover .studio-connector-arrow {
  border-top-color: var(--accent-green);
}

/* Add block button */

.studio-add-btn {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 20px;
  border: 2px dashed var(--border-gray);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.studio-add-btn:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
  background: #FFF0EF;
}

/* Block type menu (popup) */

.studio-block-menu {
  position: fixed;
  z-index: 100;
  background: var(--bg-page);
  border: 1px solid var(--border-gray);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 180px;
}

.studio-block-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 4px;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}

.studio-block-menu-item:hover {
  background: var(--bg-surface-tint);
}

.studio-block-menu-item span {
  display: flex;
  align-items: center;
}

/* Right: Config panel */

#studio-config {
  width: 300px;
  min-width: 260px;
  border-left: 1px solid var(--border-gray);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg-page);
}

#studio-config-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 20px;
}

#studio-config-empty.hidden { display: none; }

#studio-config-empty p {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

#studio-config-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#studio-config-form.hidden { display: none; }

#studio-config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#studio-config-type-badge {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.studio-config-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.studio-config-field label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.studio-config-field input,
.studio-config-field textarea,
.studio-config-field select {
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-gray);
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  background: var(--bg-page);
}

.studio-config-field input:focus,
.studio-config-field textarea:focus,
.studio-config-field select:focus {
  border-color: var(--accent-red);
}

.studio-config-field textarea {
  resize: vertical;
  line-height: 1.5;
}

.studio-config-field input::placeholder,
.studio-config-field textarea::placeholder {
  color: var(--text-muted);
}

.studio-config-field select {
  cursor: pointer;
}
