:root {
  color-scheme: dark;
  --bg: #07060e;
  --surface: rgba(13, 10, 26, 0.65);
  --surface-solid: #0d0a1c;
  --surface-2: rgba(20, 15, 40, 0.5);
  --surface-2-solid: #140f28;
  --surface-3: rgba(28, 21, 56, 0.6);
  --surface-4: rgba(38, 29, 74, 0.7);
  --border: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.03);
  --border-light: rgba(168, 85, 247, 0.2);
  --border-focus: rgba(192, 132, 252, 0.55);
  --text: #ffffff;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --text-muted: #64748b;
  --accent: #a855f7;
  --accent-light: #c084fc;
  --accent-dark: #7c3aed;
  --accent-glow: rgba(168, 85, 247, 0.25);
  --accent-soft: rgba(168, 85, 247, 0.1);
  --ambient-violet: rgba(139, 92, 246, 0.25);
  --ambient-indigo: rgba(99, 102, 241, 0.1);
  --gradient-primary: linear-gradient(135deg, #c084fc 0%, #a855f7 40%, #6366f1 100%);
  --gradient-user-msg: linear-gradient(135deg, rgba(168, 85, 247, 0.22) 0%, rgba(99, 102, 241, 0.16) 100%);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-full: 9999px;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-glass: 0 16px 40px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 32px rgba(168, 85, 247, 0.2);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

/* Atmospheric Ambient Lighting */
.ambient-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 55% at 10% 0%, var(--ambient-violet) 0%, var(--ambient-indigo) 40%, transparent 72%),
    radial-gradient(ellipse 50% 45% at 92% 90%, rgba(124, 58, 237, 0.1) 0%, transparent 65%);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(168, 85, 247, 0.4);
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 290px 1fr;
  height: 100vh;
  overflow: hidden;
  background: transparent;
  transition: grid-template-columns 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 769px) {
  .app.rail-retracted {
    grid-template-columns: 68px 1fr;
  }
}

/* ==========================================================================
   SIDEBAR (RAIL) - CLEAN & MINIMALIST (NO BOXES INSIDE BOXES)
   ========================================================================== */
.rail {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(8, 6, 17, 0.65);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  position: relative;
  z-index: 10;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Brand Header */
.rail-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px 24px;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.2);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.25);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.brand-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-light);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse-glow 2.5s infinite ease-in-out;
}

.rail-toggle-btn {
  margin-left: auto;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.rail-toggle-btn:hover {
  color: #c084fc;
  background: rgba(168, 85, 247, 0.12);
}

.workspace {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100vh;
}

.account-wrap {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 50;
}

.account-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 50%;
  background: rgba(13, 10, 26, 0.78);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.account-btn:hover,
.account-btn[aria-expanded="true"] {
  border-color: rgba(192, 132, 252, 0.7);
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.16), 0 8px 24px rgba(0, 0, 0, 0.45);
}

.account-btn .user-avatar,
.account-btn .user-badge-op {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.account-btn .user-badge-op {
  font-size: 12px;
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  padding: 8px;
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: var(--radius-lg);
  background: #130f24;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.account-menu[hidden] {
  display: none;
}

.account-menu-identity {
  padding: 8px 10px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.account-menu-name {
  font-size: 13px;
  font-weight: 650;
  color: #ffffff;
}

.account-menu-email,
.account-menu-org {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.account-menu-item svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.account-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.account-menu-item.is-danger {
  color: #fca5a5;
}

.account-menu-item.is-danger svg {
  color: #f87171;
}

.account-menu-item.is-danger:hover {
  background: rgba(248, 113, 113, 0.1);
}

.settings-org-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-keys-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Rail User Switcher */
.rail-user {
  padding: 0 16px 14px;
  position: relative;
}

.rail-user .user-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  width: 100%;
}

.rail-user .user-switcher.is-locked .user-switcher-btn {
  pointer-events: none;
}

.rail-user .user-switcher.is-locked .user-switcher-caret {
  display: none;
}

.rail-user .user-switcher-label {
  flex: 1;
  min-width: 0;
  position: relative;
}

.rail-user .user-switcher-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 10px 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: #f1f5f9;
  outline: none;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.rail-user .user-switcher-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(168, 85, 247, 0.35);
}

.rail-user .user-switcher-btn:focus {
  border-color: var(--border-focus);
}

.user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 20%;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
}

.user-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
}

.user-switcher-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-user .user-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  min-width: 100%;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: var(--radius);
  background: #130f24;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  max-height: 240px;
  overflow-y: auto;
}

.rail-user .user-create-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 16px;
  right: 16px;
  width: auto;
  padding: 0;
  z-index: 31;
}

.rail-user .org-switcher {
  margin-top: 8px;
}

.rail-user .org-switcher.is-implicit {
  display: none;
}

.user-menu[hidden] {
  display: none;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.user-menu-item:hover,
.user-menu-item.is-active {
  background: rgba(255, 255, 255, 0.06);
}

/* Category Track (EduCore Style Accent: — GUILDS) */
.category-track {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #818cf8;
}

.rail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px 8px;
}

.rail-section-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-count {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-tertiary);
}

.btn-icon-subtle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon-subtle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* Create Guild Inline Dropdown */
.create-panel {
  padding: 8px 20px 14px;
}

.create-panel form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-with-button {
  display: flex;
  gap: 6px;
}

.input-with-button input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #ffffff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-with-button input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.2);
}

.btn-primary-sm {
  background: var(--gradient-primary);
  border: 0;
  color: #ffffff;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.btn-primary-sm:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-primary-sm:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Scroll Area for Guilds */
.rail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 14px 16px;
}

.rail-scroll.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.guild-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ==========================================================================
   GUILD NAVIGATION (NO OUTER BOXES / BORDERS)
   ========================================================================== */
.guild-card {
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  overflow: visible;
}

.guild-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.guild-card-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.guild-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.guild-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.guild-caret {
  color: var(--text-muted);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.guild-caret.collapsed {
  transform: rotate(-90deg);
}

.guild-folder-icon {
  color: #a78bfa;
  flex-shrink: 0;
  opacity: 0.9;
}

.guild-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
}

.guild-agents-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Indented Clean Sub-hierarchy */
.guild-card-body {
  padding: 2px 0 6px 14px;
  margin-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Group Chat Channel Button - Borderless List Item */
.channel-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}

.channel-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
}

.channel-btn.selected {
  background: rgba(168, 85, 247, 0.15);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(168, 85, 247, 0.3);
}

.channel-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.channel-icon {
  font-size: 13px;
  opacity: 0.85;
}

.channel-shortcut {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.channel-pulse-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-light);
  font-size: 10px;
  font-weight: 600;
}

/* Agents Subsection */
.rail-sub-section {
  margin-top: 4px;
  padding-top: 4px;
}

.rail-sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 2px;
}

.sub-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.btn-sub-add {
  display: flex;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: 0;
  color: var(--accent-light);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  transition: all 0.15s;
}

.btn-sub-add:hover {
  background: rgba(168, 85, 247, 0.15);
}

.agent-items-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 2px;
}

/* Agent List Item - Clean & Borderless */
.agent-item-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 3.5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  text-align: left;
}

.agent-item-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
}

.agent-item-btn.selected {
  background: rgba(168, 85, 247, 0.15);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(168, 85, 247, 0.3);
}

.agent-avatar-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.agent-avatar-circle.pulse {
  box-shadow: 0 0 10px var(--accent);
  animation: pulse-ring 1.5s infinite;
}

.agent-item-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.agent-embed-broken {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: 999px;
  padding: 1px 6px;
}

.agent-embed-broken-banner {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 6px;
  padding: 6px 8px;
  max-width: 42rem;
}

.agent-setup-banner {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px 12px;
  border-bottom: 1px solid rgba(251, 191, 36, 0.2);
  background: rgba(251, 191, 36, 0.08);
}

.agent-setup-notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.agent-setup-copy {
  min-width: 0;
}

.agent-setup-copy strong {
  display: block;
  font-size: 13px;
  color: #fde68a;
}

.agent-setup-copy p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.agent-setup-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.fb-note-embed.is-broken {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.18);
  border-bottom-color: rgba(248, 113, 113, 0.7);
}

.fb-note-embed.is-broken:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ffffff;
}

.agent-browser-badge,
.guild-database-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--text-tertiary);
  opacity: 0.85;
}

.agent-responding-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-glow 1.2s infinite ease-in-out;
}

/* Inline Agent Creation Form */
.create-agent-form-inline {
  margin: 6px 4px 4px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.create-agent-form-inline input {
  width: 100%;
  background: rgba(10, 8, 20, 0.8);
  border: 1px solid var(--border);
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: #ffffff;
  outline: none;
}

.create-agent-form-inline input:focus {
  border-color: var(--accent);
}

.inline-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.btn-cancel-sm {
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-cancel-sm:hover {
  color: #ffffff;
}

/* Rail Footer */
.rail-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: transparent;
}

.rail-footer-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.rail-footer-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  border-color: rgba(168, 85, 247, 0.25);
}

.rail-footer-btn.active {
  background: rgba(168, 85, 247, 0.12);
  border-color: var(--accent);
  color: #ffffff;
}

.rail-footer-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: rgba(168, 85, 247, 0.12);
  color: var(--accent-light);
  flex-shrink: 0;
}

.rail-footer-label {
  display: flex;
  flex-direction: column;
}

.rail-footer-label .title {
  font-size: 12px;
  font-weight: 600;
}

.rail-footer-label .subtitle {
  font-size: 10px;
  color: var(--text-muted);
}

/* ==========================================================================
   RETRACTABLE NAVIGATION RAIL (ICON-ONLY MODE)
   ========================================================================== */

/* Guild preview & avatar fallback in header */
.guild-avatars-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
}

.guild-avatar-monogram {
  width: 32px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: #c084fc;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

/* Expanded rail behavior for collapsed/expanded guilds */
.rail:not(.is-retracted) .guild-card:not(.is-collapsed) .guild-avatars-preview {
  display: none;
}
.rail:not(.is-retracted) .guild-card.is-collapsed .guild-card-body {
  display: none;
}

/* Retracted Rail Behavior (Desktop >= 769px) */
@media (min-width: 769px) {
  .rail.is-retracted {
    width: 68px;
  }

  /* Brand */
  .rail.is-retracted .rail-brand {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 0 12px;
    gap: 10px;
  }

  .rail.is-retracted .brand-text {
    display: none !important;
  }

  .rail.is-retracted .brand-logo {
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
  }

  .rail.is-retracted .brand-logo:hover {
    transform: scale(1.08);
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.45);
  }

  .rail.is-retracted .rail-toggle-btn {
    margin: 0;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
  }

  .rail.is-retracted .rail-toggle-btn:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.3);
    color: #c084fc;
    transform: scale(1.05);
  }

  /* Section Header */
  .rail.is-retracted .rail-section-header {
    padding: 6px 0;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin: 4px 10px;
  }

  .rail.is-retracted .rail-section-title-wrap {
    display: none !important;
  }

  .rail.is-retracted #toggle-create-guild {
    width: 26px;
    height: 26px;
    margin: 0 auto;
  }

  /* Scroll container */
  .rail.is-retracted .rail-scroll {
    padding: 8px 8px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .rail.is-retracted .rail-scroll::-webkit-scrollbar {
    display: none;
  }

  .rail.is-retracted .guild-stack {
    width: 100%;
    align-items: center;
    gap: 8px;
  }

  .rail.is-retracted .rail-empty-hint {
    font-size: 10px;
    padding: 10px 4px;
    text-align: center;
    color: var(--text-muted);
  }

  /* Guild card in retracted mode */
  .rail.is-retracted .guild-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .rail.is-retracted .guild-card-header {
    padding: 5px;
    width: 48px;
    height: 44px;
    border-radius: 12px;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: all 0.18s ease;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
  }

  .rail.is-retracted .guild-card-header:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(168, 85, 247, 0.25);
    transform: scale(1.06);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  }

  .rail.is-retracted .guild-header-left {
    justify-content: center;
    align-items: center;
    width: 100%;
    gap: 0;
  }

  .rail.is-retracted .guild-caret-btn,
  .rail.is-retracted .guild-name,
  .rail.is-retracted .guild-header-right {
    display: none !important;
  }

  .rail.is-retracted .guild-avatars-preview {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* UNSELECTED GUILD: Hides agent list, shows only grouped icons */
  .rail.is-retracted .guild-card:not(.active-guild) .guild-card-body {
    display: none !important;
  }

  /* SELECTED GUILD: Highlights guild icon and expands all agent icons */
  .rail.is-retracted .guild-card.active-guild > .guild-card-header {
    background: rgba(168, 85, 247, 0.18);
    border-color: rgba(168, 85, 247, 0.5);
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.3), inset 0 0 0 1px rgba(168, 85, 247, 0.4);
  }

  .rail.is-retracted .guild-card.active-guild > .guild-card-header::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 10px;
    bottom: 10px;
    width: 3.5px;
    border-radius: 0 4px 4px 0;
    background: #c084fc;
    box-shadow: 0 0 8px #a855f7;
  }

  .rail.is-retracted .guild-card.active-guild .guild-card-body {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    margin: 6px 0 6px 0;
    padding: 6px 0;
    border-left: none;
    gap: 6px;
    width: 100%;
    position: relative;
    background: rgba(168, 85, 247, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(168, 85, 247, 0.15);
    animation: retractedAgentFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .rail.is-retracted .agent-items-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-left: 0;
    gap: 6px;
    width: 100%;
  }

  .rail.is-retracted .agent-item-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.04);
    transition: all 0.16s ease;
    position: relative;
  }

  .rail.is-retracted .agent-item-left {
    justify-content: center;
    width: 100%;
    min-width: 0;
  }

  .rail.is-retracted .agent-item-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .rail.is-retracted .agent-item-name,
  .rail.is-retracted .agent-item-right {
    display: none !important;
  }

  .rail.is-retracted .agent-item-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.18);
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  }

  .rail.is-retracted .agent-item-btn.selected {
    background: rgba(168, 85, 247, 0.25);
    border-color: #c084fc;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.5), inset 0 0 0 1px #c084fc;
    transform: scale(1.06);
  }

  .rail.is-retracted .rail-add-agent-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.14);
    color: #64748b;
    margin-top: 2px;
    transition: all 0.16s ease;
  }

  .rail.is-retracted .rail-add-agent-btn:hover {
    color: #c084fc;
    border-color: #a855f7;
    background: rgba(168, 85, 247, 0.12);
    transform: scale(1.08);
  }

  .rail.is-retracted .rail-add-text {
    display: none !important;
  }

  /* Retracted Rail Footer */
  .rail.is-retracted .rail-footer {
    padding: 12px 8px;
    align-items: center;
    gap: 8px;
  }

  .rail.is-retracted .rail-footer-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    border-radius: 11px;
    position: relative;
  }

  .rail.is-retracted .rail-footer-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .rail.is-retracted .rail-footer-label {
    display: none !important;
  }

  .rail.is-retracted .rail-footer-btn:hover {
    transform: scale(1.06);
  }
}

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

/* ==========================================================================
   MAIN PANE - AIRY, TRANSLUCENT, SOPHISTICATED
   ========================================================================== */
.pane {
  display: flex;
  flex-direction: column;
  background: transparent;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.pane-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
}

.empty-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 480px;
}

.empty-orb {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: 0 0 60px rgba(168, 85, 247, 0.5), 0 0 100px rgba(99, 102, 241, 0.25);
  margin-bottom: 24px;
  animation: float 4.5s ease-in-out infinite;
}

.empty-title {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.empty-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

/* Pane Header */
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 240px 18px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 6, 17, 0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  flex-shrink: 0;
}

.pane-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pane-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pane-icon-badge {
  font-size: 20px;
}

.pane-avatar-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--gradient-primary);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.3);
}

.pane-title-details {
  display: flex;
  flex-direction: column;
}

.pane-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pane-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.pane-type-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent-light);
}

.pane-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.model-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: var(--radius-sm);
  background: rgba(168, 85, 247, 0.12);
  color: var(--accent-light);
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.pane-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon-labeled {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon-labeled:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
  border-color: rgba(168, 85, 247, 0.25);
}

.btn-icon-labeled.active {
  background: rgba(168, 85, 247, 0.15);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-danger-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--danger);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger-sm:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.16);
}

.btn-danger-sm:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-quiet-sm {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-quiet-sm:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.btn-quiet-sm:disabled {
  opacity: 0.5;
  cursor: default;
}

.limit-form-pill label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-tertiary);
}

.limit-form-pill input {
  width: 46px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  color: #ffffff;
  outline: none;
}

/* Tab Bar - Clean Floating Indicators */
.tabs {
  display: flex;
  gap: 8px;
  padding: 10px 32px 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  flex-shrink: 0;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  padding: 8px 14px 10px;
  border-radius: 6px 6px 0 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.tab-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.72;
}

.tab.active .tab-icon {
  opacity: 1;
}

.tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.03);
}

.tab.active {
  color: #ffffff;
  border-bottom-color: var(--accent);
  background: rgba(168, 85, 247, 0.08);
}

/* Pane Body */
.pane-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
}

.pane-body:has(> .group-chat:not([hidden])) {
  overflow: hidden;
  padding: 0;
}

.pane-body:has(> .file-browser:not([hidden])),
.pane-body:has(> .browser-container:not([hidden])),
.pane-body:has(> .db-browser:not([hidden])),
.pane-body:has(> .db-scoped:not([hidden])) {
  overflow: hidden;
  padding: 24px 32px;
}

/* ==========================================================================
   CHAT WORKSPACE & FLOATING COMPOSER DOCK
   ========================================================================== */
.chat-workspace {
  display: flex;
  flex-direction: column;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  height: 100%;
  min-height: 0;
  gap: 16px;
  position: relative;
}

.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 8px 8px 0;
}

/* New Session Hero */
.new-session-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px 32px;
  text-align: center;
  margin: auto 0;
}

.hero-orb-wrap {
  margin-bottom: 22px;
}

.hero-avatar {
  margin-bottom: 22px;
  line-height: 0;
}

.hero-orb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--gradient-primary);
  box-shadow: 0 0 50px rgba(168, 85, 247, 0.4);
}

.hero-title {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.hero-subtitle {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text-tertiary);
  max-width: 440px;
  line-height: 1.6;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

/* Messages - Clean, Spacious, Minimal Borders */
.msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 18px;
  border-radius: var(--radius);
  max-width: min(85%, 760px);
  position: relative;
  transition: all 0.15s ease;
}

.msg.is-user {
  align-self: flex-end;
  background: var(--gradient-user-msg);
  border: 1px solid rgba(168, 85, 247, 0.28);
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.msg.is-assistant {
  align-self: flex-start;
  background: rgba(18, 14, 36, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom-left-radius: 4px;
  backdrop-filter: blur(12px);
}

.msg.is-tool {
  align-self: flex-start;
  background: rgba(14, 10, 26, 0.5);
  border: 1px solid var(--border);
}

.msg.is-system {
  align-self: center;
  background: rgba(251, 191, 36, 0.05);
  border: 1px solid rgba(251, 191, 36, 0.2);
  font-size: 13px;
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 11px;
  flex-shrink: 0;
  overflow: visible;
}

.avatar-user {
  background: var(--gradient-primary);
  color: #ffffff;
}

.avatar-agent {
  background: transparent;
  border: none;
  overflow: visible;
}

.avatar-tool {
  background: rgba(255, 255, 255, 0.06);
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.tool-badge {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(168, 85, 247, 0.12);
  color: var(--accent-light);
}

.msg-body {
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: #f1f5f9;
}

/* ==========================================================================
   CHAT MARKDOWN STYLING (DIRECT CHAT & GROUP CHAT)
   ========================================================================== */
.msg-body.markdown-content,
.group-msg-body.markdown-content {
  white-space: normal;
}

.markdown-content > *:first-child {
  margin-top: 0 !important;
}

.markdown-content > *:last-child {
  margin-bottom: 0 !important;
}

.markdown-content p {
  margin: 0 0 0.75em 0;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.markdown-content li {
  white-space: pre-wrap;
}

.markdown-content p:last-child {
  margin-bottom: 0;
}

/* Headings */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  font-family: inherit;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.35;
  margin: 1.1em 0 0.45em 0;
}

.markdown-content h1 {
  font-size: 1.28rem;
  letter-spacing: -0.015em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.3em;
}

.markdown-content h2 {
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.markdown-content h3 {
  font-size: 1.05rem;
}

.markdown-content h4 {
  font-size: 0.95rem;
}

.markdown-content h5,
.markdown-content h6 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

/* Lists */
.markdown-content ul,
.markdown-content ol {
  margin: 0.4em 0 0.65em 0;
  padding-left: 1.4em;
}

.markdown-content li {
  margin: 0.25em 0;
  line-height: 1.55;
}

.markdown-content li > ul,
.markdown-content li > ol {
  margin: 0.2em 0 0.2em 0;
}

.markdown-content input[type="checkbox"] {
  margin-right: 6px;
  vertical-align: middle;
  accent-color: var(--accent);
}

/* Blockquotes */
.markdown-content blockquote {
  margin: 0.65em 0;
  padding: 6px 14px;
  border-left: 3px solid var(--accent, #a855f7);
  background: rgba(168, 85, 247, 0.08);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  color: #cbd5e1;
}

.markdown-content blockquote p {
  margin: 0.25em 0;
}

/* Inline Code */
.markdown-content :not(pre) > code {
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 0.88em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  white-space: break-spaces;
}

/* Code Block Containers */
.code-block-wrap {
  margin: 0.75em 0;
  border-radius: 8px;
  border: 1px solid rgba(168, 85, 247, 0.22);
  background: #0d0a18;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  user-select: none;
}

.code-lang {
  font-family: var(--mono, monospace);
  font-weight: 600;
  font-size: 11px;
  color: var(--accent-light, #c084fc);
  text-transform: lowercase;
  letter-spacing: 0.03em;
}

.btn-copy-code {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 2px 8px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copy-code:hover {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.4);
  color: #ffffff;
}

.btn-copy-code.copied {
  background: rgba(52, 211, 153, 0.18);
  border-color: rgba(52, 211, 153, 0.4);
  color: #34d399;
}

.code-block-wrap pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 13px;
  line-height: 1.55;
  color: #f1f5f9;
  background: transparent;
  tab-size: 2;
}

.code-block-wrap pre code {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  padding: 0;
  border: none;
  white-space: pre;
}

/* Tables */
.table-wrap {
  margin: 0.75em 0;
  overflow-x: auto;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(10, 8, 20, 0.4);
}

.markdown-content table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  text-align: left;
}

.markdown-content th,
.markdown-content td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.markdown-content tr:last-child td {
  border-bottom: none;
}

.markdown-content th:last-child,
.markdown-content td:last-child {
  border-right: none;
}

.markdown-content th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: #f8fafc;
}

.markdown-content tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

/* Links */
.markdown-content a {
  color: var(--accent-light, #c084fc);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}

.markdown-content a:hover {
  color: #e9d5ff;
}

/* Dividers */
.markdown-content hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin: 1em 0;
}

/* User Message Bubble Overrides */
.msg.is-user .markdown-content :not(pre) > code,
.group-msg.is-user .markdown-content :not(pre) > code {
  background: rgba(0, 0, 0, 0.28);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.msg.is-user .code-block-wrap,
.group-msg.is-user .code-block-wrap {
  background: rgba(15, 10, 28, 0.85);
  border-color: rgba(255, 255, 255, 0.18);
}

.msg.is-user .markdown-content blockquote,
.group-msg.is-user .markdown-content blockquote {
  border-left-color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.2);
  color: #f8fafc;
}

.msg.is-user .markdown-content a,
.group-msg.is-user .markdown-content a {
  color: #ffffff;
  text-decoration-color: rgba(255, 255, 255, 0.7);
}

.msg.is-user .markdown-content a:hover,
.group-msg.is-user .markdown-content a:hover {
  color: #fdf4ff;
  text-decoration-color: #ffffff;
}

.msg.is-user .table-wrap,
.group-msg.is-user .table-wrap {
  background: rgba(0, 0, 0, 0.25);
  border-color: rgba(255, 255, 255, 0.15);
}

.msg.is-user .markdown-content th,
.group-msg.is-user .markdown-content th {
  background: rgba(0, 0, 0, 0.3);
}

.msg.is-user .markdown-content h1,
.msg.is-user .markdown-content h2,
.msg.is-user .markdown-content h3,
.msg.is-user .markdown-content h4,
.group-msg.is-user .markdown-content h1,
.group-msg.is-user .markdown-content h2,
.group-msg.is-user .markdown-content h3,
.group-msg.is-user .markdown-content h4 {
  color: #ffffff;
}

.streaming-pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: #ffffff;
  animation: pulse-ring 1.5s infinite;
  white-space: nowrap;
}

.msg-tool-calls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  width: 100%;
}

/* Tool Execution Group (Collapsible Group for Consecutive Tool Calls) */
.tool-calls-group {
  display: block;
  flex-shrink: 0;
  min-height: 40px;
  margin: 8px 0;
  border-radius: var(--radius-sm, 10px);
  background: rgba(18, 14, 30, 0.75);
  border: 1px solid rgba(168, 85, 247, 0.22);
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  width: 100%;
  box-sizing: border-box;
}

.tool-calls-group:hover {
  border-color: rgba(168, 85, 247, 0.38);
}

.tool-calls-group.is-open,
.tool-calls-group[open] {
  border-color: rgba(168, 85, 247, 0.45);
  background: rgba(18, 14, 30, 0.88);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.tool-group-header,
.tool-group-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  flex-shrink: 0;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.025);
  border: none;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  user-select: none;
  text-align: left;
  list-style: none;
  transition: background 0.15s ease;
  box-sizing: border-box;
}

.tool-group-header::-webkit-details-marker,
.tool-group-summary::-webkit-details-marker {
  display: none;
}

.tool-group-header:hover,
.tool-group-summary:hover {
  background: rgba(168, 85, 247, 0.06);
}

.tool-group-header:focus-visible,
.tool-group-summary:focus-visible {
  outline: 2px solid rgba(168, 85, 247, 0.5);
  outline-offset: -1px;
}

.tool-calls-group.is-open > .tool-group-header,
.tool-calls-group.is-open > .tool-group-summary,
.tool-calls-group[open] > .tool-group-header,
.tool-calls-group[open] > .tool-group-summary {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tool-group-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.tool-group-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #f1f5f9;
}

.tool-group-breakdown {
  font-size: 11.5px;
  color: #a78bfa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-group-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tool-calls-group.is-open > .tool-group-header .tool-chevron svg,
.tool-calls-group.is-open > .tool-group-summary .tool-chevron svg,
.tool-calls-group[open] > .tool-group-header .tool-chevron svg,
.tool-calls-group[open] > .tool-group-summary .tool-chevron svg {
  transform: rotate(180deg);
}

.tool-group-body[hidden] {
  display: none !important;
}

.tool-group-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  max-height: min(48vh, 560px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.tool-call-card {
  display: block;
  flex-shrink: 0;
  border-radius: var(--radius-sm, 8px);
  background: rgba(12, 10, 24, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  backdrop-filter: blur(8px);
  width: 100%;
  box-sizing: border-box;
}

.tool-call-card:hover {
  border-color: rgba(168, 85, 247, 0.25);
}

.tool-call-card.is-open,
.tool-call-card[open] {
  border-color: rgba(168, 85, 247, 0.35);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.tool-call-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  flex-shrink: 0;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.025);
  border: none;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  user-select: none;
  text-align: left;
  list-style: none;
  transition: background 0.15s ease;
  box-sizing: border-box;
}

.tool-call-summary::-webkit-details-marker {
  display: none;
}

.tool-call-summary:hover {
  background: rgba(255, 255, 255, 0.05);
}

.tool-call-summary:focus-visible {
  outline: 2px solid rgba(168, 85, 247, 0.5);
  outline-offset: -1px;
}

.tool-call-card.is-open > .tool-call-summary,
.tool-call-card[open] > .tool-call-summary {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.035);
}

.tool-call-summary-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.tool-call-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--accent-light, #c084fc);
  flex-shrink: 0;
}

.tool-call-name-badge {
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 11px;
  font-weight: 600;
  color: #f1f5f9;
  background: rgba(168, 85, 247, 0.14);
  border: 1px solid rgba(168, 85, 247, 0.24);
  padding: 1px 7px;
  border-radius: 4px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.tool-call-hint {
  font-size: 12px;
  color: var(--text-tertiary, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.tool-call-summary-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tool-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 9999px;
  text-transform: lowercase;
  line-height: 1.4;
}

.tool-status-pill.is-completed {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.tool-status-pill.is-running {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.tool-status-pill.is-error {
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.28);
}

.tool-duration-pill {
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 10px;
  color: var(--text-tertiary, #94a3b8);
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 5px;
  border-radius: 4px;
}

.tool-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-tertiary, #94a3b8);
}

.tool-chevron svg {
  transition: transform 0.2s ease;
}

.tool-call-card.is-open > .tool-call-summary .tool-chevron svg,
.tool-call-card[open] > .tool-call-summary .tool-chevron svg {
  transform: rotate(180deg);
}

.tool-call-summary:hover .tool-chevron {
  color: var(--text-primary, #ffffff);
}

.tool-call-body[hidden] {
  display: none !important;
}

.tool-call-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(0, 0, 0, 0.25);
  min-height: 0;
}


.tool-section {
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.tool-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px 5px 10px;
  background: rgba(255, 255, 255, 0.025);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.tool-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #cbd5e1);
}

.tool-section-title svg {
  color: var(--accent-light, #c084fc);
}

.tool-type-badge {
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  margin-left: 6px;
}

.tool-type-badge.badge-json {
  background: rgba(168, 85, 247, 0.18);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.25);
}

.tool-type-badge.badge-text {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.btn-copy-tool-block {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text-tertiary, #94a3b8);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copy-tool-block:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #ffffff);
}

.tool-code-block {
  margin: 0;
  padding: 8px 10px;
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 11.5px;
  line-height: 1.55;
  color: #e2e8f0;
  max-height: 380px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: transparent;
}

.tool-code-block.is-pending {
  color: var(--text-tertiary, #94a3b8);
  font-style: italic;
}

.tool-code-block.is-json code {
  color: #a5f3fc;
}

.tool-code-block.is-raw code {
  color: #e2e8f0;
}

.tool-meta-subdetails {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
}

.tool-meta-subdetails summary {
  cursor: pointer;
  user-select: none;
  padding: 3px 6px;
  font-size: 10.5px;
  color: var(--text-tertiary, #94a3b8);
  border-radius: 4px;
  display: inline-block;
}

.tool-meta-subdetails summary:hover {
  color: var(--text-secondary, #cbd5e1);
}

.tool-meta-subdetails pre {
  margin-top: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
}

.msg-metadata {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.msg-metadata summary {
  cursor: pointer;
  user-select: none;
}

.msg-metadata pre {
  margin: 6px 0 0;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  font-family: var(--mono);
}

.run-offered-tools pre {
  max-height: 320px;
  overflow: auto;
}

/* ==========================================================================
   OFFERED TOOLS (Debug View)
   ========================================================================== */
.offered-tools-wrapper {
  width: 100%;
  max-width: 100%;
  margin: 4px 0;
  flex-shrink: 0;
}

.offered-tools-panel {
  display: block;
  border: 1px solid rgba(168, 85, 247, 0.2);
  background: rgba(18, 14, 36, 0.45);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  min-height: auto;
}

.offered-tools-panel[open] {
  border-color: rgba(168, 85, 247, 0.35);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.offered-tools-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.15s;
  gap: 12px;
  list-style: none;
}

.offered-tools-summary::-webkit-details-marker {
  display: none;
}

.offered-tools-summary:hover {
  background: rgba(255, 255, 255, 0.04);
}

.offered-tools-summary-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}

.offered-tools-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #c084fc;
}

.offered-tools-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.offered-tools-count-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 9999px;
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.offered-tools-preview-list {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  flex-wrap: nowrap;
}

.preview-tool-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.preview-tool-more {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.offered-tools-chevron {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.offered-tools-panel[open] .offered-tools-chevron {
  transform: rotate(180deg);
}

.offered-tools-body {
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.offered-tools-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.offered-tools-search {
  position: relative;
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
}

.offered-tools-search .search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.tools-filter-input {
  width: 100%;
  padding: 6px 10px 6px 30px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  transition: border-color 0.15s;
}

.tools-filter-input:focus {
  outline: none;
  border-color: #a855f7;
}

.offered-tools-mode-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 2px;
}

.btn-mode-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-mode-toggle.is-active {
  background: rgba(168, 85, 247, 0.25);
  color: #ffffff;
}

.offered-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  max-height: 440px;
  overflow-y: auto;
  padding-right: 4px;
}

.offered-tool-card {
  background: rgba(10, 8, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s;
}

.offered-tool-card:hover {
  border-color: rgba(168, 85, 247, 0.25);
  background: rgba(14, 11, 26, 0.7);
}

.tool-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tool-card-name-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tool-card-name {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: #c084fc;
  background: rgba(168, 85, 247, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-copy-tool {
  padding: 3px;
  color: var(--text-muted);
}
.btn-copy-tool:hover {
  color: var(--text-primary);
}

.tool-badge-params {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 6px;
  border-radius: 4px;
}

.tool-card-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.tool-card-params {
  margin-top: 4px;
  border-top: 1px dashed rgba(255, 255, 255, 0.06);
  padding-top: 6px;
}

.tool-card-params summary {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tool-card-params summary:hover {
  color: var(--text-secondary);
}

.tool-param-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding-left: 6px;
}

.tool-param-item {
  font-size: 11px;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px 8px;
  border-radius: 4px;
  border-left: 2px solid rgba(168, 85, 247, 0.4);
}

.param-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.param-item-name {
  font-family: var(--mono);
  font-weight: 600;
  color: #e2e8f0;
}

.param-item-type {
  font-family: var(--mono);
  font-size: 10px;
  color: #94a3b8;
}

.param-item-req {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
  padding: 0 4px;
  border-radius: 3px;
}

.param-item-opt {
  font-size: 9px;
  color: var(--text-muted);
}

.param-item-desc {
  color: var(--text-secondary);
  font-size: 10.5px;
  margin-top: 2px;
  line-height: 1.35;
}

.offered-tools-raw {
  margin: 0;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11px;
  max-height: 380px;
  overflow: auto;
  color: #cbd5e1;
}

/* ==========================================================================
   SYSTEM PROMPT (Collapsible Section, XML-aware, Non-Bubble)
   ========================================================================== */
.system-prompt-wrapper {
  width: 100%;
  max-width: 100%;
  margin: 4px 0;
}

.system-prompt-panel {
  display: block;
  border: 1px solid rgba(168, 85, 247, 0.18);
  background: rgba(18, 13, 33, 0.45);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
  transition: all 0.2s ease;
  width: 100%;
  min-height: auto;
}

.system-prompt-panel[open] {
  border-color: rgba(168, 85, 247, 0.32);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.system-prompt-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.15s;
  gap: 12px;
  list-style: none;
}

.system-prompt-summary::-webkit-details-marker {
  display: none;
}

.system-prompt-summary:hover {
  background: rgba(255, 255, 255, 0.04);
}

.system-prompt-summary-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}

.system-prompt-icon {
  display: inline-flex;
  align-items: center;
  color: #c084fc;
}

.system-prompt-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.system-prompt-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.xml-tag-pill {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--tag-color, #c084fc);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1px 7px;
  border-radius: 4px;
}

.system-prompt-summary-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-copy-prompt {
  color: var(--text-muted);
}
.btn-copy-prompt:hover {
  color: var(--text-primary);
}

.system-prompt-chevron {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.system-prompt-panel[open] .system-prompt-chevron {
  transform: rotate(180deg);
}

.system-prompt-body {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* XML Section Cards inside System Prompt */
.prompt-xml-card {
  --section-color: #c084fc;
  background: rgba(10, 8, 20, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 3px solid var(--section-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s;
}

.prompt-xml-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  border-left-color: var(--section-color);
}

.prompt-xml-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.025);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.prompt-xml-tag-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11.5px;
}

.prompt-xml-bracket {
  color: var(--text-muted);
}

.prompt-xml-tag-name {
  font-weight: 700;
  color: var(--section-color);
}

.prompt-xml-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  padding-left: 8px;
}

.prompt-xml-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-copy-xml-section {
  color: var(--text-muted);
  padding: 3px;
}
.btn-copy-xml-section:hover {
  color: var(--text-primary);
}

.prompt-xml-body {
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.prompt-xml-body h1,
.prompt-xml-body h2,
.prompt-xml-body h3,
.prompt-xml-body h4 {
  color: var(--text-primary);
  margin-top: 10px;
  margin-bottom: 6px;
}

.prompt-xml-body h1:first-child,
.prompt-xml-body h2:first-child,
.prompt-xml-body h3:first-child {
  margin-top: 0;
}

.prompt-xml-body p {
  margin-bottom: 8px;
}

.prompt-xml-body p:last-child {
  margin-bottom: 0;
}

.prompt-xml-body .fb-note-embed,
.prompt-plain-section .fb-note-embed {
  font-size: 13px;
}

.prompt-xml-footer {
  padding: 4px 12px 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.prompt-plain-section {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(255, 255, 255, 0.07);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.prompt-meta-details {
  margin-top: 4px;
  font-size: 11px;
}

/* Floating Glass Composer Dock */
.composer-card {
  flex-shrink: 0;
  background: rgba(15, 11, 30, 0.8);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 24px rgba(168, 85, 247, 0.1);
  padding: 10px 14px 8px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 8px;
}

.composer-card:focus-within {
  border-color: rgba(192, 132, 252, 0.45);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 32px rgba(168, 85, 247, 0.2);
}

.composer-inner textarea {
  width: 100%;
  min-height: 64px;
  max-height: 220px;
  border: 0;
  background: transparent;
  color: #ffffff;
  padding: 4px 2px 8px;
  font-size: 14px;
  resize: none;
  outline: none;
  line-height: 1.55;
}

.composer-inner textarea::placeholder {
  color: var(--text-muted);
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.composer-hints {
  font-size: 11px;
  color: var(--text-muted);
}

.hint-key {
  display: inline-block;
  padding: 1px 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-tertiary);
}

.composer-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-send {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: var(--gradient-primary);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.35);
}

.btn-send:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-send:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-cancel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-cancel:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.btn-cancel:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Alerts / Notices */
.notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.06);
  border: 1px solid rgba(251, 191, 36, 0.2);
  color: var(--warning);
  font-size: 12px;
}

.msg-limit {
  margin-top: 2px;
}

.latest-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--danger);
  font-size: 12px;
}

/* ==========================================================================
   SESSION HISTORY TAB
   ========================================================================== */
.history-view {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.history-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.history-view-title {
  margin: 0 0 3px;
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

.history-view-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.btn-primary-gradient {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: var(--gradient-primary);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 12px rgba(168, 85, 247, 0.3);
}

.btn-primary-gradient:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.history-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.run-history-card {
  padding: 14px 18px;
  border-radius: var(--radius);
  background: rgba(14, 10, 28, 0.45);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.run-history-card:hover {
  background: rgba(20, 15, 38, 0.6);
  border-color: rgba(168, 85, 247, 0.3);
  transform: translateY(-1px);
}

.run-history-card.active {
  background: rgba(168, 85, 247, 0.12);
  border-color: var(--accent);
}

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

.run-card-type {
  display: flex;
  align-items: center;
  gap: 8px;
}

.run-card-icon {
  font-size: 14px;
}

.run-card-title {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}

.run-card-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}

.status-completed {
  background: var(--success-soft);
  color: var(--success);
}

.status-running {
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-light);
  animation: pulse-ring 1.5s infinite;
}

.status-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.run-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.run-card-id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.run-card-notice {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--warning);
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(251, 191, 36, 0.08);
}

.run-card-tools {
  font-size: 11px;
  color: var(--text-tertiary);
}

.run-card-tools summary {
  cursor: pointer;
  user-select: none;
}

.run-card-tools pre {
  margin: 6px 0 0;
  padding: 8px;
  max-height: 240px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  font-family: var(--mono);
}

.run-card-tools-list {
  margin-top: 6px;
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.run-card-tool-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
}

.run-card-tool-name {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  color: #c084fc;
}

.run-card-tool-desc {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  text-align: center;
  color: var(--text-tertiary);
}

.history-empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

/* ==========================================================================
   2-PANE FILE BROWSER - SEAMLESS SPLIT
   ========================================================================== */
.file-browser {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
  min-height: 480px;
  border-radius: var(--radius);
  background: rgba(12, 9, 24, 0.5);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.file-browser > .fb-sidebar,
.file-browser > .fb-viewer {
  min-height: 0;
  min-width: 0;
}

.file-browser.fb-solo {
  grid-template-columns: 1fr;
}

.file-browser.fb-solo > .fb-sidebar {
  display: none;
}

.fb-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(8, 6, 17, 0.4);
}

.fb-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.fb-sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.fb-location {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.fb-roots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 4px;
  margin-top: 10px;
}

.fb-root-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  color: #94a3b8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.fb-root-label {
  min-width: 0;
}

.fb-root-count {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.3;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  min-width: 1.35em;
  text-align: center;
}

.fb-root-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.fb-root-btn.active,
.fb-root-btn[aria-pressed="true"] {
  background: rgba(168, 85, 247, 0.22);
  border-color: rgba(168, 85, 247, 0.4);
  color: #ffffff;
}

.fb-root-btn:hover .fb-root-count {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.fb-root-btn.active .fb-root-count,
.fb-root-btn[aria-pressed="true"] .fb-root-count {
  background: rgba(168, 85, 247, 0.38);
  color: #ffffff;
}

.fb-kinds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 8px;
}

.fb-kind-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  color: #94a3b8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 4px;
  border-radius: 7px;
  cursor: pointer;
}

.fb-kind-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.fb-kind-btn.active,
.fb-kind-btn[aria-pressed="true"] {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.4);
  color: #ffffff;
}

.file-browser.fb-kind-collections {
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
}

.file-browser.fb-kind-collections > .fb-sidebar {
  border-right: none;
  border-bottom: 1px solid var(--border);
}

.file-browser.fb-kind-collections > .fb-tree,
.file-browser.fb-kind-collections > .fb-sidebar .fb-tree,
.file-browser.fb-kind-collections > .fb-viewer {
  display: none;
}

.file-browser.fb-kind-collections > .db-browser {
  border: none;
  border-radius: 0;
  box-shadow: none;
  min-height: 0;
  height: 100%;
}

.fb-location-path {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  font-family: var(--mono);
}

.fb-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.fb-back:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.fb-nav-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
  padding: 7px 10px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent-light);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.fb-nav-row:hover {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.35);
  color: #ffffff;
}

.fb-nav-row span {
  flex: 1;
  min-width: 0;
}

.fb-file-list-root {
  margin: 0;
  padding: 0;
  border-left: none;
}

.fb-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fb-folder-block {
  display: flex;
  flex-direction: column;
}

.fb-folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.fb-folder-header:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
}

.fb-folder-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.fb-folder-caret {
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.fb-folder-header.collapsed .fb-folder-caret {
  transform: rotate(-90deg);
}

.fb-folder-icon {
  color: var(--accent-light);
  flex-shrink: 0;
}

.fb-folder-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-tertiary);
}

.fb-file-list {
  list-style: none;
  margin: 2px 0 6px 14px;
  padding: 0 0 0 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.fb-file-list.collapsed {
  display: none;
}

.fb-file-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  flex-shrink: 0;
}

.fb-file-row:hover .fb-file-delete,
.fb-file-row.selected .fb-file-delete {
  opacity: 1;
}

.fb-file-delete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.fb-empty-hint {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 8px;
}

.fb-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.fb-file-row:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
}

.fb-file-row.selected {
  background: rgba(168, 85, 247, 0.15);
  color: #ffffff;
  font-weight: 600;
}

.fb-file-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.file-icon {
  flex-shrink: 0;
}

.icon-md { color: #38bdf8; }
.icon-py { color: #fbbf24; }
.icon-json { color: #a855f7; }
.icon-generic { color: var(--text-muted); }

.fb-file-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fb-obsidian-badge {
  color: var(--accent-light);
  font-size: 12px;
  opacity: 0.6;
  text-decoration: none;
  transition: opacity 0.15s;
}

.fb-obsidian-badge:hover {
  opacity: 1;
}

.fb-viewer {
  display: flex;
  flex-direction: column;
  background: transparent;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.fb-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 6, 17, 0.3);
}

.fb-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-family: var(--mono);
}

.crumb-hint {
  flex: 1 1 100%;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-tertiary);
}

.crumb-folder {
  color: var(--text-tertiary);
}

.crumb-sep {
  color: var(--text-muted);
}

.crumb-file {
  color: #ffffff;
  font-weight: 600;
}

.fb-viewer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-subtle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-subtle-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.btn-obsidian-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.2);
  color: var(--accent-light);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-obsidian-link:hover {
  background: rgba(168, 85, 247, 0.22);
}

.fb-content-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
}

.fb-content-wrap.editing {
  padding: 0;
}

.fb-code-pre {
  margin: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}

.fb-code-pre.placeholder {
  color: var(--text-muted);
  font-family: var(--font);
  padding: 30px;
  text-align: center;
}

.fb-editor {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 16px 20px;
  border: 0;
  background: transparent;
  resize: none;
  outline: none;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow: auto;
}

.fb-editor:focus {
  color: #ffffff;
}

.crumb-file.unsaved::after {
  content: "•";
  margin-left: 6px;
  color: var(--warning);
}

.fb-save-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.fb-save-status.dirty {
  color: var(--warning);
}

.fb-save-status.saved {
  color: var(--success);
}

.fb-save-status.error {
  color: var(--danger);
}

.fb-editor-surface {
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
}

.fb-editor-surface:focus {
  color: #ffffff;
}

.fb-sidebar-search,
.fb-find-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.fb-sidebar-search {
  flex-shrink: 0;
  padding: 0 10px 10px;
}

.fb-search-icon {
  position: absolute;
  left: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.fb-sidebar-search .fb-search-icon {
  left: 20px;
}

.fb-search-input,
.fb-find-input {
  width: 100%;
  padding: 6px 28px 6px 30px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.fb-search-input:focus,
.fb-find-input:focus {
  border-color: var(--accent);
  background: rgba(20, 15, 40, 0.6);
}

.fb-search-clear {
  position: absolute;
  right: 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 12px;
}

.fb-search-clear:hover {
  color: #ffffff;
}

.fb-mode-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 2px;
  flex-shrink: 0;
}

.fb-mode-toggle[hidden] {
  display: none;
}

.fb-find-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 6, 17, 0.22);
  flex-shrink: 0;
}

.fb-find-bar[hidden] {
  display: none;
}

.fb-find-input-wrap {
  flex: 1;
  min-width: 0;
}

.fb-find-input-wrap .fb-search-icon {
  left: 10px;
}

.fb-find-count {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.fb-content-wrap.reading {
  padding: 0;
}

.fb-preview {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px 28px 36px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
  outline: none;
}

.fb-preview.is-empty,
.fb-preview.is-loading,
.fb-preview.error-state,
.fb-preview-empty {
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
}

.fb-preview .fb-note-embed {
  font-size: 13px;
}

mark.fb-search-hit,
::highlight(fb-note-search) {
  background-color: rgba(250, 204, 21, 0.38);
  color: inherit;
}

mark.fb-search-hit.is-current,
::highlight(fb-note-search-current) {
  background-color: rgba(250, 204, 21, 0.78);
  color: #111827;
}

.fb-note-embed {
  display: inline;
  color: #e9d5ff;
  background: rgba(168, 85, 247, 0.18);
  border-bottom: 1px solid rgba(192, 132, 252, 0.55);
  border-radius: 4px;
  padding: 0 5px;
  margin: 0 1px;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font);
}

.fb-note-embed:hover {
  background: rgba(168, 85, 247, 0.32);
  color: #ffffff;
}

.file-insert-card {
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.file-insert-browser {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(12, 9, 24, 0.5);
}

.file-insert-browser .fb-roots {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.file-insert-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 360px;
  height: min(520px, 60vh);
}

.file-insert-body .fb-sidebar,
.file-insert-body .fb-viewer {
  min-height: 0;
  min-width: 0;
}

.file-insert-actions {
  margin-top: 16px;
  justify-content: flex-end;
}

.fb-note-preview {
  position: fixed;
  z-index: 1200;
  max-height: min(380px, 70vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-glass);
}

.fb-note-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fb-note-preview-title {
  margin: 4px 0 0;
  font-size: 15px;
  font-weight: 700;
}

.fb-note-preview-body {
  margin: 0;
  flex: 1;
  min-height: 0;
  padding: 12px 16px 16px;
  overflow: auto;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  word-break: break-word;
}

.fb-note-preview-body.is-loading,
.fb-note-preview-body.error-state {
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
}

/* ==========================================================================
   BROWSER SANDBOX TAB - CONSISTENT WINDOW WITH 16:9 RATIO FIT
   ========================================================================== */
.browser-container {
  height: 100%;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  container-type: size;
}

.browser-window {
  display: flex;
  flex-direction: column;
  --header-h: 45px;
  width: min(100%, calc((100cqh - var(--header-h)) * 16 / 9));
  max-height: 100%;
  border-radius: var(--radius);
  background: rgba(12, 9, 24, 0.5);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin: auto;
}

.browser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 6, 17, 0.3);
  flex-shrink: 0;
  height: var(--header-h);
  box-sizing: border-box;
}

.browser-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.browser-header-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.browser-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.browser-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
}

.browser-status-badge.is-live {
  background: var(--success-soft);
  border-color: rgba(52, 211, 153, 0.25);
  color: var(--success);
}

.browser-status-badge.is-live .pulse-dot {
  background: var(--success);
}

.browser-status-badge.is-failed {
  background: var(--danger-bg);
  border-color: rgba(248, 113, 113, 0.25);
  color: var(--danger);
}

.browser-status-badge.is-starting {
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-light);
}

.browser-viewport {
  width: 100%;
  aspect-ratio: 16 / 9;
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, rgba(168, 85, 247, 0.04) 0%, rgba(7, 6, 14, 0.95) 75%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.browser-viewport.is-live {
  padding: 0;
  background: #111018;
}

.browser-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #111018;
  overflow: hidden;
}

.browser-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #111018;
}

.browser-starting {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.browser-starting-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid rgba(168, 85, 247, 0.2);
  border-top-color: var(--accent-light);
  animation: agentOrbitSpin 0.8s linear infinite;
}

.browser-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 480px;
}

.browser-empty-graphic {
  position: relative;
  margin-bottom: 18px;
}

.browser-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(168, 85, 247, 0.25);
  box-shadow: 0 0 24px rgba(168, 85, 247, 0.15);
}

.browser-empty-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

.browser-empty-desc {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

.browser-empty-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.spec-tag {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.spec-tag .label {
  color: var(--text-muted);
  margin-right: 4px;
}

/* ==========================================================================
   GROUP CHAT VIEW
   ========================================================================== */
.group-chat {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.group-status-bar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 32px;
  background: rgba(8, 6, 17, 0.4);
  border-bottom: 1px solid var(--border);
}

.group-status-bar:empty {
  display: none;
}

.group-responding-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.25);
  color: var(--accent-light);
  font-size: 12px;
  width: fit-content;
}

.group-log {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.group-msg {
  display: flex;
  gap: 12px;
  max-width: min(80%, 720px);
}

.group-msg.is-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.group-msg.is-agent {
  align-self: flex-start;
}

.group-msg-avatar {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;
}

.group-msg-avatar.avatar-user {
  background: var(--gradient-primary);
  border-radius: 50%;
}

.group-msg-avatar.avatar-agent {
  background: transparent;
  border: none;
  overflow: visible;
}

.group-msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.group-msg.is-user .group-msg-content {
  align-items: flex-end;
}

.group-msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.group-msg-author {
  font-weight: 700;
  color: var(--text-secondary);
}

.group-msg.is-user .group-msg-author {
  color: var(--accent-light);
}

.group-msg time {
  font-size: 10px;
  color: var(--text-muted);
}

.group-inspect-link {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-light);
  cursor: pointer;
}

.group-inspect-link:hover {
  text-decoration: underline;
}

.group-msg-body {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.group-msg.is-user .group-msg-body {
  background: var(--gradient-user-msg);
  border: 1px solid rgba(168, 85, 247, 0.28);
  border-top-right-radius: 4px;
}

.group-msg.is-agent .group-msg-body {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 2px 0 0 0;
}

.group-tag {
  display: inline;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  font-weight: 600;
  font-size: 12px;
}

.group-tag.is-agent {
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-light);
}

.group-tag.is-user {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.group-composer {
  margin: 0 32px 16px;
}

.group-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 20px;
  margin: auto;
  color: var(--text-tertiary);
  max-width: 440px;
}

.group-empty-state .empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.group-empty-state h3 {
  margin: 0 0 6px;
  color: #ffffff;
  font-size: 18px;
}

.group-empty-state p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

.typing-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

/* ==========================================================================
   CONFIG & ACCESS FORMS - CLEAN, FLAT HIERARCHY (NO NESTED BOXES)
   ========================================================================== */
.access-pane,
.agent-config-panel {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 0;
}

/* Clean Open Sections */
.access-section-card,
.config-form-card,
.credential-form-card {
  padding: 24px 28px;
  border-radius: var(--radius-lg);
  background: rgba(14, 10, 28, 0.4);
  border: 1px solid var(--border);
  transition: padding 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.15s ease, background 0.15s ease;
}

.access-section-card.is-collapsed {
  padding: 16px 24px;
}

.access-section-card.is-collapsed .access-section-head {
  margin-bottom: 0;
}

.config-form-card .avatar-picker {
  margin-bottom: 22px;
}

.config-form-card .agent-focus-grid {
  margin-top: 0;
  margin-bottom: 22px;
}

.access-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.access-section-head.is-collapsible {
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  margin: -4px -6px 14px -6px;
  transition: background 0.15s ease;
}

.access-section-card.is-collapsed .access-section-head.is-collapsible {
  margin-bottom: -4px;
}

.access-section-head.is-collapsible:hover {
  background: rgba(255, 255, 255, 0.03);
}

.access-section-head.is-collapsible:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.access-section-head-info {
  flex: 1;
  min-width: 0;
}

.access-section-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.access-section-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono, monospace);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  letter-spacing: 0.02em;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.access-section-badge.has-active {
  color: #c084fc;
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.28);
}

.access-section-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.access-section-head.is-collapsible:hover .access-section-caret {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.access-section-caret.collapsed svg {
  transform: rotate(-90deg);
}

.access-section-caret svg {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.access-section-body {
  transition: opacity 0.15s ease;
}

.access-section-body[hidden] {
  display: none;
}

.head-icon {
  font-size: 18px;
  margin-top: 1px;
}

.head-title, .form-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.head-desc {
  margin: 0;
  font-size: 12px;
  color: var(--text-tertiary);
}

.access-list {
  display: flex;
  flex-direction: column;
}

/* Borderless List Rows */
.access-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 6px;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease;
}

.access-row:last-child {
  border-bottom: 0;
}

.access-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Service Cards List */
.mcp-service-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mcp-service-card {
  border-radius: var(--radius-lg);
  background: rgba(18, 13, 34, 0.45);
  border: 1px solid var(--border);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  overflow: hidden;
}

.mcp-service-card:hover {
  border-color: rgba(168, 85, 247, 0.24);
  background: rgba(22, 16, 42, 0.55);
}

.mcp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: transparent;
}

.mcp-card-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.mcp-card-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mcp-card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mcp-card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.mcp-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Service Icons */
.mcp-service-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.mcp-service-icon svg {
  display: block;
  max-width: 20px;
  max-height: 20px;
  flex-shrink: 0;
}

.mcp-service-card:hover .mcp-service-icon {
  transform: scale(1.04);
}

.mcp-icon-notion {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.mcp-icon-gmail {
  background: rgba(234, 67, 53, 0.10);
  border-color: rgba(234, 67, 53, 0.25);
  color: #ea4335;
}

.mcp-icon-coingecko {
  background: rgba(141, 198, 71, 0.12);
  border-color: rgba(141, 198, 71, 0.28);
  color: #4ade80;
}

.mcp-icon-x {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.mcp-icon-twitterapiio {
  background: rgba(29, 161, 242, 0.12);
  border-color: rgba(29, 161, 242, 0.28);
  color: #1da1f2;
}

.mcp-icon-wallet {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.28);
  color: #fbbf24;
}

.mcp-icon-alchemy {
  background: rgba(0, 82, 255, 0.12);
  border-color: rgba(0, 82, 255, 0.28);
  color: #60a5fa;
}

.mcp-icon-opensea {
  background: rgba(32, 129, 226, 0.12);
  border-color: rgba(32, 129, 226, 0.28);
  color: #38bdf8;
}

.mcp-icon-etherscan {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.28);
  color: #60a5fa;
}

.mcp-icon-cigale {
  background: rgba(249, 115, 22, 0.15);
  border-color: rgba(249, 115, 22, 0.32);
  color: #fb923c;
}

.mcp-icon-tavily {
  background: rgba(20, 184, 166, 0.12);
  border-color: rgba(20, 184, 166, 0.28);
  color: #2dd4bf;
}

.mcp-icon-slack {
  background: rgba(224, 30, 90, 0.10);
  border-color: rgba(224, 30, 90, 0.25);
  color: #f43f5e;
}

.mcp-icon-github {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.mcp-icon-default {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

/* Status Pill */
.mcp-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.mcp-status-pill.is-connected {
  color: #34d399;
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.24);
}

.mcp-status-pill.is-disconnected {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid rgba(248, 113, 113, 0.24);
}

.mcp-status-pill.is-unconfigured {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.mcp-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.mcp-status-dot.pulse {
  box-shadow: 0 0 6px currentColor;
  animation: status-pulse 2.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

/* Card Actions */
.mcp-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-connect-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: #ffffff;
  background: linear-gradient(135deg, #a855f7, #6366f1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.25);
}

.btn-connect-sm:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.35);
  filter: brightness(1.08);
}

.btn-danger-subtle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger-subtle:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.35);
  color: #ffffff;
}

.mcp-tool-drawer-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.15s ease;
}

.mcp-tool-drawer-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.mcp-tool-drawer-btn.is-open {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.3);
  color: #c084fc;
}

.mcp-tools-icon {
  opacity: 0.8;
}

.mcp-drawer-caret {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mcp-drawer-caret.collapsed {
  transform: rotate(-90deg);
}

/* Tools Drawer */
.mcp-tools-drawer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(8, 5, 18, 0.55);
  display: flex;
  flex-direction: column;
}

.mcp-tools-drawer[hidden] {
  display: none;
}

.mcp-tools-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(255, 255, 255, 0.015);
  flex-wrap: wrap;
}

.mcp-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 160px;
  max-width: 260px;
}

.mcp-search-icon {
  position: absolute;
  left: 9px;
  color: var(--text-muted);
  pointer-events: none;
}

.mcp-search-input {
  width: 100%;
  padding: 5px 26px 5px 28px;
  border-radius: 6px;
  font-size: 11.5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: #ffffff;
  transition: all 0.15s ease;
}

.mcp-search-input:focus {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--accent);
  outline: none;
}

.mcp-search-clear {
  position: absolute;
  right: 7px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 4px;
}

.mcp-search-clear:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.mcp-filter-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.03);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.mcp-filter-tab {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mcp-filter-tab:hover {
  color: #ffffff;
}

.mcp-filter-tab.is-active {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.mcp-bulk-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-bulk {
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-bulk:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.14);
}

.btn-bulk:disabled {
  opacity: 0.4;
  cursor: default;
}

.mcp-tools-list {
  display: flex;
  flex-direction: column;
}

.mcp-tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.15s ease;
}

.mcp-tool-row:last-child {
  border-bottom: 0;
}

.mcp-tool-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.mcp-tool-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.mcp-tool-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mcp-tool-status-dot.is-active {
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.4);
}

.mcp-tool-status-dot.is-disabled {
  background: rgba(255, 255, 255, 0.18);
}

.mcp-tool-text-wrap {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.mcp-tool-title-line,
.native-tool-title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.mcp-tool-display-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #f1f5f9;
  font-family: var(--mono);
  letter-spacing: -0.01em;
}

.mcp-tool-prefix-badge {
  display: inline-flex;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9.5px;
  font-family: var(--mono);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.mcp-tool-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.mcp-tool-info-btn:hover,
.mcp-tool-info-btn.is-open {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.mcp-tool-meta {
  font-size: 10.5px;
  color: var(--text-muted);
}

.mcp-tool-desc-card {
  margin: 6px 0 2px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mcp-tools-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

.mcp-token-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 18px 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.mcp-token-form[hidden] {
  display: none;
}

.mcp-token-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.mcp-token-form input {
  width: 100%;
  box-sizing: border-box;
}

.mcp-row-error {
  margin: 0 18px 12px;
}

.access-name-wrap {
  min-width: 0;
  flex: 1;
}

.access-name {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
}

.access-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.access-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Modern Segmented Control */
.overlay-actions-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.overlay-source {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
  white-space: nowrap;
  line-height: 1.2;
}

.overlay-source.is-inherited {
  color: var(--text-muted);
}

.overlay-source.is-overridden {
  color: #c084fc;
  cursor: pointer;
}

.overlay-source.is-overridden:hover:not(:disabled) {
  color: #e9d5ff;
  text-decoration: underline;
}

.overlay-source.is-overridden:disabled {
  opacity: 0.55;
  cursor: default;
}

.overlay-actions {
  display: inline-flex;
  align-items: center;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.32);
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-segment {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.btn-segment:hover:not(:disabled) {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.04);
}

.btn-segment.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.btn-enable.is-active {
  background: rgba(52, 211, 153, 0.16);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.28);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.15);
}

.btn-disable.is-active {
  background: rgba(248, 113, 113, 0.16);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.28);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.15);
}

.segment-pip {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.segment-pip.is-on {
  background: #34d399;
  box-shadow: 0 0 4px #34d399;
}

.segment-pip.is-off {
  background: rgba(255, 255, 255, 0.25);
}

.btn-segment:disabled {
  opacity: 0.35;
  cursor: default;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.grid-span-2 {
  grid-column: span 2;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.mcp-token-form input {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #ffffff;
  outline: none;
  color-scheme: dark;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.mcp-token-form input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.2);
}

.form-grid textarea {
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
}

.field-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary);
}

.form-disclosure {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-disclosure:not([open]) > :not(summary) {
  display: none;
}

.form-disclosure summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-disclosure summary::-webkit-details-marker {
  display: none;
}

.form-disclosure summary::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  flex-shrink: 0;
  transform: translateY(1px);
  transition: transform 0.15s ease;
}

.form-disclosure[open] > summary::before {
  transform: translateY(1px) rotate(90deg);
}

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

.md-editor-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.md-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  min-height: 240px;
}

.md-editor textarea {
  min-height: 240px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
}

.md-editor-preview {
  min-height: 240px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}

.md-editor-preview.is-empty,
.md-editor-empty {
  color: var(--text-tertiary);
  font-size: 12px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: #cbd5e1;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.form-disclosure summary .field-hint {
  font-weight: 400;
}

.form-disclosure label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.avatar-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.avatar-picker-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.avatar-picker-body {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar-picker-preview {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: transparent;
  border: 1px dashed var(--border);
}

.avatar-picker-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.avatar-picker-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.avatar-picker-legend {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.avatar-picker-sets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.avatar-set-btn {
  font-size: 11px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.avatar-set-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary, #f8fafc);
  border-color: rgba(255, 255, 255, 0.22);
}

.avatar-set-btn.selected {
  background: rgba(124, 92, 255, 0.18);
  border-color: #7c5cff;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(124, 92, 255, 0.35);
}

.avatar-picker-subrow {
  flex-direction: row;
  align-items: center;
  gap: 20px;
}

.avatar-picker-subcol {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.avatar-picker-shapes,
.avatar-picker-colors {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.avatar-randomize-btn {
  width: fit-content;
}

.avatar-shape-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.avatar-shape-btn:hover {
  background: rgba(255, 255, 255, 0.07);
}

.avatar-shape-btn.selected {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.08);
}

.avatar-color-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.avatar-color-btn:hover {
  transform: scale(1.08);
}

.avatar-color-btn.selected {
  box-shadow: 0 0 0 2px var(--surface-solid), 0 0 0 4px currentColor;
}

.form-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.form-actions .modal-studio {
  margin-right: auto;
}

.browser-toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
}

.browser-toggle input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.browser-toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.browser-toggle-title {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
}

.browser-toggle-desc {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
}

.guild-database-toggle {
  margin-top: 12px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 4, 12, 0.72);
  backdrop-filter: blur(8px);
}

.file-create-overlay,
.file-insert-overlay {
  z-index: 1100;
}

.modal-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 24px 28px 28px;
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-glass);
}

.modal-card-wide {
  width: min(920px, 100%);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-title {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 700;
}

.modal-subtitle {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.modal-form .form-grid {
  margin-top: 0;
}

.error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */
@keyframes pulse-glow {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 10px var(--accent);
  }
  50% {
    opacity: 0.3;
    box-shadow: 0 0 2px var(--accent);
  }
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(168, 85, 247, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(168, 85, 247, 0);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-glow 1.2s infinite ease-in-out;
}

/* ==========================================================================
   REDESIGN SUITE: GUILDS.RUN TARGET AESTHETICS (IMAGES 1 & 2)
   ========================================================================== */

/* User Switcher fallback badge */
.user-badge-op {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: #7c3aed;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.05em;
}

.user-switcher-caret {
  margin-left: auto;
  color: #64748b;
  display: flex;
  align-items: center;
}

/* Left Rail Guild Items & Nested Agents */
.guild-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.guild-card-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.guild-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.guild-avatar-stack {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  pointer-events: none;
}

.guild-avatar-slot {
  display: flex;
  margin-inline-start: -9px;
  position: relative;
  filter: drop-shadow(-1px 0 0 #0b0914);
}

.guild-avatar-slot:first-child {
  margin-inline-start: 0;
}

/* Guild Avatar Group Cluster (Left Nav) */
.guild-avatar-group-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  pointer-events: none;
}

.guild-avatar-group {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  position: relative;
  flex-shrink: 0;
  pointer-events: none;
}

.guild-avatar-group-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.guild-avatar-group.count-1 {
  display: flex;
  align-items: center;
  justify-content: center;
}

.guild-avatar-group.count-2 {
  position: relative;
  width: 32px;
  height: 28px;
}

.guild-avatar-group.count-2 .slot-1 {
  position: absolute;
  top: 4px;
  left: 0;
  z-index: 1;
  transform: rotate(-8deg);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.guild-avatar-group.count-2 .slot-2 {
  position: absolute;
  top: 5px;
  right: 0;
  z-index: 2;
  transform: rotate(8deg);
  filter: drop-shadow(-1.5px 0 0 #0b0914) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.guild-card-header:hover .count-2 .slot-1 {
  transform: rotate(-12deg) scale(1.05);
}
.guild-card-header:hover .count-2 .slot-2 {
  transform: rotate(12deg) scale(1.05);
}

.guild-avatar-group.count-3 {
  position: relative;
  width: 32px;
  height: 30px;
}

.guild-avatar-group.count-3 .slot-1 {
  position: absolute;
  top: 0;
  left: 7.5px;
  z-index: 1;
  transform: rotate(-3deg);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

.guild-avatar-group.count-3 .slot-2 {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 2;
  transform: rotate(-8deg);
  filter: drop-shadow(0 -1.5px 0 #0b0914) drop-shadow(1.5px 0 0 #0b0914);
}

.guild-avatar-group.count-3 .slot-3 {
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 3;
  transform: rotate(7deg);
  filter: drop-shadow(-1.5px -1px 0 #0b0914) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.guild-card-header:hover .count-3 .slot-1 {
  transform: rotate(-5deg) scale(1.05);
}
.guild-card-header:hover .count-3 .slot-2 {
  transform: rotate(-12deg) scale(1.05);
}
.guild-card-header:hover .count-3 .slot-3 {
  transform: rotate(11deg) scale(1.05);
}

.guild-avatar-group.count-4 {
  position: relative;
  width: 33px;
  height: 31px;
}

.guild-avatar-group.count-4 .slot-1 {
  position: absolute;
  top: 0;
  left: 1px;
  z-index: 1;
  transform: rotate(-8deg);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

.guild-avatar-group.count-4 .slot-2 {
  position: absolute;
  top: 0;
  right: 1px;
  z-index: 2;
  transform: rotate(7deg);
  filter: drop-shadow(-1.5px 0 0 #0b0914) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.guild-avatar-group.count-4 .slot-3 {
  position: absolute;
  bottom: 0;
  left: 2px;
  z-index: 3;
  transform: rotate(5deg);
  filter: drop-shadow(0 -1.5px 0 #0b0914) drop-shadow(1.5px 0 0 #0b0914);
}

.guild-avatar-group.count-4 .slot-4 {
  position: absolute;
  bottom: 0;
  right: 1px;
  z-index: 4;
  transform: rotate(-7deg);
  filter: drop-shadow(-1.5px -1.5px 0 #0b0914) drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
}

.guild-card-header:hover .count-4 .slot-1 {
  transform: rotate(-12deg) scale(1.06);
}
.guild-card-header:hover .count-4 .slot-2 {
  transform: rotate(11deg) scale(1.06);
}
.guild-card-header:hover .count-4 .slot-3 {
  transform: rotate(8deg) scale(1.06);
}
.guild-card-header:hover .count-4 .slot-4 {
  transform: rotate(-11deg) scale(1.06);
}

.guild-group-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: #c084fc;
  background: rgba(168, 85, 247, 0.16);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 999px;
  padding: 0 5px;
  height: 18px;
  min-width: 18px;
  line-height: 1;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

/* Guild Avatar Overflow Slot (Guild Header Stack) */
.guild-avatar-slot.guild-avatar-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #1e1533, #151128);
  border: 1.5px solid rgba(168, 85, 247, 0.45);
  color: #c084fc;
  font-family: var(--mono);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
  box-sizing: border-box;
  text-align: center;
  user-select: none;
}

.agent-item-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
  width: 22px;
  height: 22px;
}

.guild-caret-btn {
  background: transparent;
  border: none;
  padding: 4px;
  margin: -4px 0 -4px -4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  color: #64748b;
  transition: color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.guild-caret-btn:hover {
  color: #c084fc;
  background: rgba(168, 85, 247, 0.12);
}

.guild-caret-btn:hover .guild-caret {
  color: #c084fc;
}

.guild-caret {
  color: #64748b;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.guild-caret.collapsed {
  transform: rotate(-90deg);
}

.guild-name {
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
  letter-spacing: -0.01em;
}

.guild-card.active-guild > .guild-card-header {
  background: rgba(168, 85, 247, 0.12);
}

.guild-card.active-guild > .guild-card-header .guild-name {
  color: #ffffff;
}

.guild-card.active-guild > .guild-card-header .guild-caret {
  color: #c084fc;
}

.guild-agents-pill {
  font-size: 11px;
  font-family: var(--mono);
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 7px;
  border-radius: 999px;
}

.agent-items-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 2px;
  padding-left: 12px;
}

.agent-item-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3.5px 12px 3.5px 14px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  transition: all 0.15s ease;
}

.agent-item-btn:hover {
  background: rgba(255, 255, 255, 0.03);
}

.agent-item-btn.selected {
  background: rgba(168, 85, 247, 0.15);
}

.agent-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.agent-bullet {
  color: #64748b;
  font-size: 12px;
}

.agent-item-name {
  font-family: var(--mono);
  font-size: 12px;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-item-btn.selected .agent-item-name {
  color: #ffffff;
  font-weight: 600;
}

.agent-item-status {
  font-family: var(--mono);
  font-size: 11px;
}

.agent-item-status.status-run {
  color: #c084fc;
}

.agent-item-status.status-idle {
  color: #64748b;
}

.rail-add-agent-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s ease;
  width: 100%;
  text-align: left;
}

.rail-add-agent-btn:hover {
  color: #a855f7;
}

/* ==========================================================================
   GUILD VIEW HEADER & AGENT QUICK CARDS ROW (IMAGE 1)
   ========================================================================== */
.guild-view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px 80px 14px 32px;
  position: relative;
  background: var(--guild-aurora-bg, transparent);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.3s ease;
}

.guild-title-line {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.guild-title-line .guild-avatar-stack {
  margin-right: 2px;
}

.guild-title-line .guild-avatar-stack .guild-avatar-slot {
  margin-inline-start: -10px;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.7));
  transition: transform 0.18s ease;
}

.guild-title-line .guild-avatar-stack .guild-avatar-slot:first-child {
  margin-inline-start: 0;
}

.guild-heading {
  font-size: 24px;
  font-weight: 800;
  color: #ffffff;
  margin: 0;
  letter-spacing: -0.02em;
}

.guild-count-badge {
  background: rgba(168, 85, 247, 0.16);
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #c084fc;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 10px;
  letter-spacing: 0.02em;
}

.guild-about-row {
  margin-top: 4px;
  max-width: 720px;
}

.guild-about-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 720px;
  margin: 0;
  padding: 2px 6px;
  border-radius: 6px;
  background: transparent;
  border: none;
  font: inherit;
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: none;
}

.guild-about-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
}

.guild-about-btn.is-empty {
  color: #64748b;
  font-style: italic;
}

.guild-about-input {
  display: block;
  width: 100%;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  font: inherit;
  font-size: 13px;
  color: #e2e8f0;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.2);
}

.guild-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.guild-limit-wrap {
  position: relative;
}

.guild-limit-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: 280px;
  padding: 16px 16px 14px;
  border-radius: 14px;
  background: #130f24;
  border: 1px solid rgba(168, 85, 247, 0.28);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.guild-limit-popover[hidden] {
  display: none !important;
}

.guild-limit-popover-arrow {
  position: absolute;
  top: -6px;
  right: 22px;
  width: 10px;
  height: 10px;
  background: #130f24;
  border-left: 1px solid rgba(168, 85, 247, 0.28);
  border-top: 1px solid rgba(168, 85, 247, 0.28);
  transform: rotate(45deg);
}

.guild-limit-popover-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.guild-limit-popover-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.guild-limit-popover-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-tertiary);
}

.guild-limit-popover-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.preset-chip {
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.preset-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.preset-chip.is-active {
  background: rgba(168, 85, 247, 0.22);
  border-color: rgba(192, 132, 252, 0.55);
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.14);
}

.guild-limit-custom-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.guild-limit-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.guild-limit-field span {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.guild-limit-input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.guild-limit-input:focus {
  border-color: rgba(192, 132, 252, 0.6);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.16);
}

.guild-limit-custom-row .btn-primary-sm {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
}

.guild-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  padding: 4px 12px 4px 8px;
  font-size: 12px;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.guild-pill-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  transform: translateY(-1px);
}

.guild-studio-btn {
  color: #e9d5ff;
  border-color: rgba(168, 85, 247, 0.35);
  background: rgba(168, 85, 247, 0.12);
}

.guild-studio-btn:hover {
  color: #ffffff;
  border-color: rgba(192, 132, 252, 0.55);
  background: rgba(168, 85, 247, 0.22);
}

.guild-studio-btn svg {
  flex-shrink: 0;
}

.guild-limit-gauge-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.guild-limit-gauge {
  transform: rotate(-90deg);
}

.guild-limit-gauge .gauge-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 2.2;
}

.guild-limit-gauge .gauge-ring {
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  transition: stroke-dasharray 0.35s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.25s ease;
}

.guild-pill-btn.tier-safe .gauge-ring {
  stroke: #34d399;
  filter: drop-shadow(0 0 3px rgba(52, 211, 153, 0.6));
}
.guild-pill-btn.tier-safe .guild-limit-remaining {
  color: #34d399;
}

.guild-pill-btn.tier-warning .gauge-ring {
  stroke: #fbbf24;
  filter: drop-shadow(0 0 3px rgba(251, 191, 36, 0.6));
}
.guild-pill-btn.tier-warning .guild-limit-remaining {
  color: #fbbf24;
}

.guild-pill-btn.tier-danger .gauge-ring {
  stroke: #f87171;
  filter: drop-shadow(0 0 4px rgba(248, 113, 113, 0.8));
  animation: gauge-pulse 1.8s infinite;
}
.guild-pill-btn.tier-danger .guild-limit-remaining {
  color: #f87171;
}

@keyframes gauge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.guild-options-wrap {
  position: relative;
}

.guild-more-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #94a3b8;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  transition: all 0.15s ease;
}

.guild-more-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.guild-options-menu, .agent-options-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  background: #130f24;
  border: 1px solid rgba(168, 85, 247, 0.28);
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(255, 255, 255, 0.04);
  z-index: 61;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.guild-options-menu .menu-item,
.agent-options-menu .menu-item,
.guild-options-menu .menu-item-danger,
.agent-options-menu .menu-item-danger {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 8px;
  gap: 10px;
}

.guild-options-menu .menu-item svg,
.agent-options-menu .menu-item svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.guild-options-menu .menu-item:hover,
.agent-options-menu .menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.guild-options-menu .menu-divider,
.agent-options-menu .menu-divider {
  margin: 4px 6px;
}

.menu-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: #cbd5e1;
  cursor: pointer;
  border-radius: 4px;
}

.menu-checkbox-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 2px 0;
}

.menu-item-danger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--danger);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.menu-item-danger:hover {
  background: rgba(248, 113, 113, 0.12);
}

/* Agent Quick Cards Row (Directly below Guild Header) */
.guild-agent-cards-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 32px 14px;
  overflow-x: auto;
}

.guild-agent-card {
  background: rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  border-radius: 999px;
  padding: 3px 8px 3px 4px;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: none;
  user-select: none;
}

.guild-agent-card:hover {
  background: rgba(255, 255, 255, 0.07);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.guild-agent-card:active {
  transform: translateY(0);
}

.guild-agent-card.is-responding {
  background: rgba(var(--agent-color-rgb, 168, 85, 247), 0.14);
  box-shadow: 0 0 16px rgba(var(--agent-color-rgb, 168, 85, 247), 0.25);
}

.agent-card-avatar {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.agent-card-details {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.agent-card-name {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
}

.agent-card-status.idle {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  color: #64748b;
  gap: 3px;
  letter-spacing: 0.01em;
  opacity: 0.8;
}

.agent-card-status.idle .pulse-dot {
  background: #10b981;
  box-shadow: 0 0 4px rgba(16, 185, 129, 0.5);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  margin-right: 0;
}

.agent-card-status.responding {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--agent-color, #c084fc);
  text-shadow: 0 0 8px rgba(var(--agent-color-rgb, 192, 132, 252), 0.6);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.agent-card-action {
  display: none;
}

/* Guild & Agent Navigation Tabs (Underline Styling) */
.guild-tabs, .agent-tabs {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0 32px;
  display: flex;
  gap: 20px;
  background: transparent;
  flex-shrink: 0;
}

.agent-tabs {
  padding: 0 24px;
  overflow-x: auto;
  flex-wrap: nowrap;
  gap: 16px;
}

.guild-tabs .tab, .agent-tabs .tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 2px;
  font-size: 14px;
  font-weight: 500;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.guild-tabs .tab:hover, .agent-tabs .tab:hover {
  color: #e2e8f0;
}

.guild-tabs .tab.active {
  color: #ffffff;
  font-weight: 600;
  border-bottom: 2px solid #a855f7;
  box-shadow: none;
  background: transparent;
}

.tab-count {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
  line-height: 1.4;
}

.agent-tabs .tab.active {
  color: #ffffff;
  font-weight: 600;
  border-bottom: 2px solid var(--agent-color, #a855f7);
  text-shadow: 0 0 16px rgba(var(--agent-color-rgb, 168, 85, 247), 0.45);
  box-shadow: none;
  background: transparent;
}

/* ==========================================================================
   GROUP CHAT MESSAGE BUBBLES & COMPOSER (IMAGE 1)
   ========================================================================== */
.group-msg.is-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.group-msg.is-user .group-msg-avatar {
  background: #7c3aed;
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  border-radius: 50%;
  width: 32px;
  height: 32px;
}

.group-msg.is-user .group-msg-content {
  align-items: flex-end;
}

.group-msg.is-user .group-msg-body {
  background: #581c87;
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 14px;
  border-top-right-radius: 3px;
  color: #ffffff;
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(88, 28, 135, 0.3);
}

.group-msg.is-agent {
  align-self: flex-start;
  position: relative;
  overflow: visible;
  padding: 12px 18px 14px 14px;
  border-radius: 14px;
  margin-top: 16px;
  margin-left: 14px;
  border: 1px solid rgba(var(--agent-color-rgb, 168, 85, 247), 0.12);
  background: linear-gradient(
    135deg,
    rgba(var(--agent-color-rgb, 168, 85, 247), 0.12) 0%,
    rgba(22, 18, 42, 0.7) 45%,
    rgba(14, 11, 26, 0.55) 100%
  );
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3), 0 0 20px rgba(var(--agent-color-rgb, 168, 85, 247), 0.05);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.group-msg.is-agent:hover {
  border-color: rgba(var(--agent-color-rgb, 168, 85, 247), 0.28);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4), 0 0 26px rgba(var(--agent-color-rgb, 168, 85, 247), 0.12);
}

.group-msg.is-agent .group-msg-avatar {
  width: 36px;
  height: 36px;
  margin-top: -24px;
  margin-left: -24px;
  margin-right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  overflow: visible;
  flex-shrink: 0;
  z-index: 2;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 14px rgba(var(--agent-color-rgb, 168, 85, 247), 0.45));
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.group-msg.is-agent:hover .group-msg-avatar {
  transform: scale(1.06) translateY(-1px);
}

.group-msg.is-agent .group-msg-author {
  color: var(--agent-color, #c084fc);
  font-weight: 700;
  font-size: 13px;
  text-shadow: 0 0 10px rgba(var(--agent-color-rgb, 168, 85, 247), 0.35);
}

.group-msg.is-agent .group-msg-author.is-clickable,
.group-msg.is-agent .group-msg-avatar.is-clickable,
.group-msg.is-typing .streaming-pill.is-clickable {
  cursor: pointer;
}

.group-msg.is-agent .group-msg-author.is-clickable:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.group-msg.is-agent .group-msg-author.is-clickable:focus-visible,
.group-msg.is-agent .group-msg-avatar.is-clickable:focus-visible,
.group-msg.is-typing .streaming-pill.is-clickable:focus-visible {
  outline: 2px solid rgba(var(--agent-color-rgb, 168, 85, 247), 0.7);
  outline-offset: 2px;
  border-radius: 4px;
}

.group-inspect-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(var(--agent-color-rgb, 168, 85, 247), 0.25);
  background: rgba(var(--agent-color-rgb, 168, 85, 247), 0.08);
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--agent-color, #c084fc);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: 4px;
}

.group-inspect-link:hover {
  background: rgba(var(--agent-color-rgb, 168, 85, 247), 0.22);
  border-color: var(--agent-color, #c084fc);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(var(--agent-color-rgb, 168, 85, 247), 0.35);
  text-decoration: none;
}

.group-msg.is-typing {
  opacity: 0.95;
  position: relative;
  overflow: visible;
  margin-top: 16px;
  margin-left: 14px;
  padding: 10px 18px 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(var(--agent-color-rgb, 192, 132, 252), 0.14);
  background: linear-gradient(
    135deg,
    rgba(var(--agent-color-rgb, 192, 132, 252), 0.12) 0%,
    rgba(22, 18, 42, 0.7) 45%,
    rgba(14, 11, 26, 0.55) 100%
  );
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3), 0 0 20px rgba(var(--agent-color-rgb, 192, 132, 252), 0.05);
}

.group-msg.is-typing .group-msg-avatar {
  width: 36px;
  height: 36px;
  margin-top: -22px;
  margin-left: -22px;
  margin-right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  overflow: visible;
  flex-shrink: 0;
  z-index: 2;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 14px rgba(var(--agent-color-rgb, 192, 132, 252), 0.45));
}

.typing-waiting {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.group-msg.is-typing .group-msg-body.typing-bubble {
  padding: 4px 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--agent-color, var(--accent-light, #c084fc));
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
  box-shadow: 0 0 8px rgba(var(--agent-color-rgb, 168, 85, 247), 0.5);
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.guild-limit-remaining {
  font-weight: 600;
  margin-left: 4px;
  font-size: 11px;
}

.group-msg.is-agent .group-msg-body {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  color: #e2e8f0;
  padding: 2px 0 0 0;
  font-size: 14px;
  line-height: 1.65;
}

/* Composer Mention Pills Bar */
.composer-to-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.to-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}

.to-pills-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.composer-pill {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-family: var(--mono);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s ease;
}

.composer-pill:hover, .composer-pill.active {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.45);
  color: #c084fc;
}

/* ==========================================================================
   AGENT MODAL & FULL-VIEW OVERLAY (IMAGE 2)
   ========================================================================== */
.agent-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(5, 4, 11, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  transition: background 0.2s ease;
}

.agent-modal-overlay.is-fullview {
  background: #090812;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
}

.agent-modal-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-modal-card {
  --agent-color: #a855f7;
  --agent-color-rgb: 168, 85, 247;
  width: 94vw;
  max-width: 1240px;
  height: 86vh;
  max-height: 900px;
  min-height: 480px;
  background: 
    radial-gradient(ellipse 540px 360px at 0% 0%, rgba(var(--agent-color-rgb), 0.16) 0%, transparent 75%),
    #0d0b18;
  border: 1px solid rgba(var(--agent-color-rgb), 0.28);
  border-radius: 20px;
  box-shadow: 
    0 24px 70px rgba(0, 0, 0, 0.85), 
    0 0 55px rgba(var(--agent-color-rgb), 0.18),
    0 0 100px rgba(var(--agent-color-rgb), 0.08);
  display: flex;
  flex-direction: column;
  overflow: visible;
  position: relative;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.agent-modal-card:hover {
  border-color: rgba(var(--agent-color-rgb), 0.38);
  box-shadow: 
    0 24px 75px rgba(0, 0, 0, 0.88), 
    0 0 65px rgba(var(--agent-color-rgb), 0.22),
    0 0 110px rgba(var(--agent-color-rgb), 0.1);
}

.agent-modal-card.is-fullview {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  overflow: hidden !important;
}

.agent-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 24px 14px;
  border-bottom: 1px solid rgba(var(--agent-color-rgb, 255, 255, 255), 0.08);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  flex-shrink: 0;
  position: relative;
}

.agent-modal-header-left {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
}

.agent-modal-avatar {
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  margin-top: -38px;
  margin-left: -42px;
  z-index: 10;
  filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.82))
          drop-shadow(0 0 26px rgba(var(--agent-color-rgb), 0.48));
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), filter 0.25s ease;
  cursor: pointer;
}

.agent-modal-avatar::before {
  content: "";
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--agent-color-rgb), 0.28) 0%, transparent 72%);
  pointer-events: none;
  z-index: -1;
  animation: avatar-ambient-pulse 4s ease-in-out infinite alternate;
}

@keyframes avatar-ambient-pulse {
  0% { transform: scale(0.92); opacity: 0.65; }
  100% { transform: scale(1.08); opacity: 1; }
}

.agent-modal-avatar:hover {
  transform: scale(1.08) rotate(-2deg);
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.92))
          drop-shadow(0 0 36px rgba(var(--agent-color-rgb), 0.75));
}

.agent-modal-card.is-fullview .agent-modal-header {
  border-radius: 0;
  padding: 14px 24px;
}

.agent-modal-card.is-fullview .agent-modal-avatar {
  margin-top: 0;
  margin-left: 0;
  width: 52px;
  height: 52px;
}

.agent-modal-card.is-fullview .agent-modal-avatar ai-avatar {
  transform: scale(0.65);
  transform-origin: center center;
}

.agent-modal-card.is-fullview .agent-modal-meta {
  margin-top: 0;
}

.agent-modal-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.agent-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-modal-name {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  letter-spacing: -0.01em;
}

.agent-status-tag {
  font-family: var(--mono);
  font-size: 12px;
}

.agent-status-tag.responding {
  color: var(--agent-color, #c084fc);
}

.agent-status-tag.responding::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 2px;
  background: var(--agent-color, #c084fc);
  margin-left: 2px;
  animation: pulse-glow 0.8s infinite;
}

.agent-status-tag.idle {
  color: #64748b;
}

.agent-desc-row {
  margin-top: 4px;
}

.agent-modal-desc {
  font-size: 13px;
  color: #94a3b8;
  margin: 0;
  line-height: 1.45;
  max-width: 650px;
}

.agent-modal-desc-btn {
  appearance: none;
  display: block;
  width: 100%;
  max-width: 650px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}

.agent-modal-desc-btn:hover {
  color: #cbd5e1;
}

.agent-modal-desc-btn.is-empty {
  color: #64748b;
  font-style: italic;
}

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

.agent-expand-btn, .agent-more-btn, .agent-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.agent-expand-btn:hover, .agent-more-btn:hover, .agent-close-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.agent-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  position: relative;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
}

/* Chat view: modal body clips outer overflow so chat-workspace & chat-log manage internal scrolling */
.agent-modal-body[data-tab="chat"],
.agent-modal-body:has(.chat-workspace:not([hidden])) {
  overflow: hidden;
  padding: 0;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
}

/* Files, Prompt, and Browser views: fill available space and manage their internal panes */
.agent-modal-body[data-tab="files"],
.agent-modal-body:has(.agent-files-panel:not([hidden])),
.agent-modal-body[data-tab="prompt"],
.agent-modal-body:has(.agent-prompt-panel:not([hidden])),
.agent-modal-body[data-tab="database"],
.agent-modal-body:has(.agent-database-panel:not([hidden])),
.agent-modal-body[data-tab="browser"],
.agent-modal-body:has(.browser-container:not([hidden])) {
  overflow: hidden;
  padding: 20px 24px;
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
}

/* Agent Modal Direct Chat Theming */
.agent-modal-card .composer-card:focus-within {
  border-color: rgba(var(--agent-color-rgb, 192, 132, 252), 0.45);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 32px rgba(var(--agent-color-rgb, 168, 85, 247), 0.22);
}

.agent-modal-card .btn-send {
  background: linear-gradient(135deg, var(--agent-color, #7c3aed), color-mix(in srgb, var(--agent-color, #a855f7) 70%, #9333ea));
  box-shadow: 0 2px 12px rgba(var(--agent-color-rgb, 168, 85, 247), 0.35);
}

.agent-modal-card .btn-send:hover:not(:disabled) {
  box-shadow: 0 4px 18px rgba(var(--agent-color-rgb, 168, 85, 247), 0.55);
}

.agent-modal-card .new-session-hero .category-track {
  color: var(--agent-color, #c084fc);
}

.agent-files-panel,
.agent-prompt-panel,
.agent-database-panel {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-files-panel .file-browser,
.agent-files-panel .db-scoped,
.agent-prompt-panel .file-browser,
.agent-prompt-panel .db-scoped,
.agent-database-panel .db-scoped {
  flex: 1;
  min-height: 0;
  height: 100%;
}

.db-scoped {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 480px;
  border-radius: var(--radius);
  background: rgba(12, 9, 24, 0.5);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.db-scoped-chrome {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.db-scoped.is-solo .db-scoped-chrome {
  display: none;
}

.db-scoped-chrome .fb-roots {
  margin-top: 0;
}

.db-scoped-chrome .fb-root-btn {
  padding: 7px 8px;
}

.db-scoped-pane {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.db-scoped-pane .db-browser,
.db-scoped-pane .file-browser {
  border: none;
  border-radius: 0;
  box-shadow: none;
  min-height: 0;
  height: 100%;
}

/* ==========================================================================
   AGENT FILES BROWSER (IMAGE 2)
   ========================================================================== */
.fb-sidebar {
  width: 220px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  background: transparent;
  overflow: hidden;
  min-height: 0;
}

.fb-sidebar-header {
  padding-bottom: 12px;
  flex-shrink: 0;
}

.fb-sidebar-title .category-track {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.08em;
}

.fb-file-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.fb-file-list:not(.fb-file-list-root) {
  margin: 2px 0 6px 8px;
  padding: 0 0 0 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.fb-file-row {
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fb-file-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.fb-file-row.selected {
  background: rgba(168, 85, 247, 0.22);
}

.fb-file-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.fb-file-ext {
  font-family: var(--mono);
  font-size: 11px;
  color: #64748b;
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}

.fb-file-row.selected .fb-file-ext {
  color: #c084fc;
}

.fb-file-name {
  font-family: var(--mono);
  font-size: 12px;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fb-file-row.selected .fb-file-name {
  color: #ffffff;
  font-weight: 600;
}

.fb-nav-bottom-btn {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #94a3b8;
  font-size: 12px;
  margin-top: auto;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.fb-nav-bottom-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(168, 85, 247, 0.3);
  color: #ffffff;
}

.fb-nav-arrow {
  font-size: 14px;
  color: #64748b;
}

.fb-viewer-header {
  padding: 12px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.crumb-path {
  font-family: var(--mono);
  font-size: 13px;
  color: #cbd5e1;
}

.fb-readonly-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: #64748b;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
}

.fb-version-tag {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: #c4b5fd;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(168, 85, 247, 0.14);
  border: 1px solid rgba(168, 85, 247, 0.28);
}

.fb-version-select {
  height: 28px;
  max-width: 220px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: #e2e8f0;
  font-family: var(--mono);
  font-size: 11px;
}

.fb-version-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.fb-code-pre {
  padding: 24px;
  flex: 1;
  min-height: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: #e2e8f0;
  background: transparent;
  overflow: auto;
  margin: 0;
}

/* ==========================================================================
   GUILD DATABASE TAB - TABULAR DATA VIEWER & INSPECTOR
   ========================================================================== */
.db-browser {
  position: relative;
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
  min-height: 480px;
  border-radius: var(--radius);
  background: rgba(12, 9, 24, 0.5);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Sidebar & Collections */
.db-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(8, 6, 17, 0.4);
  overflow: hidden;
}

.db-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.db-sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.db-sidebar-title svg {
  color: var(--accent-light);
}

.db-add-collection-btn {
  width: 26px;
  height: 26px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* New Collection Card (inline in sidebar) */
.db-create-panel {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 15, 40, 0.7);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeIn 0.15s ease;
}

.db-create-panel[hidden] {
  display: none !important;
}

.db-create-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-light);
}

.db-create-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.db-input {
  width: 100%;
  padding: 6px 10px;
  background: rgba(8, 6, 17, 0.65);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.db-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.db-input-textarea {
  min-height: 52px;
  resize: vertical;
  line-height: 1.4;
  font-family: inherit;
}

.db-create-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.btn-subtle-sm {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-subtle-sm:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

/* Collections Tree / List */
.db-collection-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.db-collection-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
}

.db-collection-row:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
}

.db-collection-row.selected {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.35);
  color: #ffffff;
  font-weight: 600;
}

.db-collection-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.db-col-icon {
  color: var(--accent-light);
  flex-shrink: 0;
}

.db-col-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.db-count-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.db-collection-row.selected .db-count-badge {
  background: rgba(168, 85, 247, 0.25);
  color: var(--accent-light);
}

/* Viewer Main Area */
.db-viewer {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  background: transparent;
  overflow: hidden;
}

/* Viewer Header */
.db-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 6, 17, 0.3);
  flex-shrink: 0;
  min-height: 52px;
}

.db-viewer-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.db-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.db-crumb-name {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

.db-header-count {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: rgba(168, 85, 247, 0.12);
  color: var(--accent-light);
  border: 1px solid rgba(168, 85, 247, 0.22);
}

.db-badge-truncated {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: rgba(251, 191, 36, 0.12);
  color: var(--warning);
  border: 1px solid rgba(251, 191, 36, 0.25);
  font-family: var(--mono);
}

.db-purpose-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  min-width: 0;
}

.db-purpose-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-search-fields {
  flex-shrink: 0;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: rgba(168, 85, 247, 0.12);
  color: var(--accent-light);
  border: 1px solid rgba(168, 85, 247, 0.22);
}

.db-field-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-muted);
}

.db-purpose-edit-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-xs);
  transition: color 0.15s, background 0.15s;
}

.db-purpose-edit-btn:hover {
  color: var(--accent-light);
  background: rgba(255, 255, 255, 0.05);
}

.db-viewer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Search bar */
.db-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.db-search-icon {
  position: absolute;
  left: 9px;
  color: var(--text-muted);
  pointer-events: none;
}

.db-search-input {
  padding: 5px 26px 5px 28px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  width: 170px;
  transition: all 0.15s ease;
}

.db-search-input:focus {
  width: 220px;
  border-color: var(--accent);
  background: rgba(20, 15, 40, 0.6);
  outline: none;
}

.db-search-clear {
  position: absolute;
  right: 7px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 12px;
  display: flex;
  align-items: center;
}

.db-search-clear:hover {
  color: #ffffff;
}

/* Inline Purpose Popover */
.db-purpose-popover {
  position: absolute;
  top: 56px;
  left: 18px;
  z-index: 30;
  width: 380px;
  background: var(--surface-2-solid);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fadeIn 0.15s ease;
}

.db-purpose-popover[hidden] {
  display: none !important;
}

.db-purpose-popover-title {
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
}

.db-purpose-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Tabular Data Grid Container */
.db-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
  background: rgba(8, 6, 17, 0.2);
}

.db-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  text-align: left;
}

.db-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(13, 10, 26, 0.95);
  backdrop-filter: blur(8px);
}

.db-table th {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.db-th-id {
  width: 180px;
  min-width: 140px;
}

.db-th-actions {
  width: 76px;
  text-align: right;
  padding-right: 18px;
}

.db-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 0.12s ease;
}

.db-table tbody tr:hover {
  background: rgba(168, 85, 247, 0.08);
}

.db-table tbody tr.selected {
  background: rgba(168, 85, 247, 0.16);
}

.db-table td {
  padding: 9px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.db-cell-id {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-light);
}

.db-id-inner {
  display: flex;
  align-items: center;
  gap: 6px;
}

.db-id-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.db-cell-copy-btn {
  opacity: 0;
  transition: opacity 0.15s;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.db-table tbody tr:hover .db-cell-copy-btn {
  opacity: 1;
}

.db-cell-copy-btn:hover {
  color: #ffffff;
}

/* Typed Cell Representations */
.db-cell-bool {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
}

.db-cell-bool.bool-true {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.db-cell-bool.bool-false {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.db-cell-number {
  font-family: var(--mono);
  color: #38bdf8;
}

.db-cell-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-tertiary);
}

.db-cell-null {
  color: var(--text-muted);
  opacity: 0.6;
  font-style: italic;
}

.db-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  opacity: 0.3;
  transition: opacity 0.15s;
}

.db-table tbody tr:hover .db-row-actions {
  opacity: 1;
}

/* Table Footer Summary */
.db-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: rgba(8, 6, 17, 0.4);
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--mono);
  flex-shrink: 0;
}

/* Empty States */
.db-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
}

.db-empty-icon {
  color: var(--accent-light);
  opacity: 0.7;
  margin-bottom: 6px;
}

.db-empty h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.db-empty p {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
  max-width: 400px;
  line-height: 1.5;
}

.db-empty-table {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 280px;
  padding: 32px;
  text-align: center;
  gap: 12px;
  color: var(--text-tertiary);
}

.db-empty-table h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
}

.db-empty-table p {
  margin: 0;
  font-size: 13px;
  max-width: 360px;
  line-height: 1.5;
  color: var(--text-tertiary);
}

/* Slide-Over Record Inspector Drawer */
.db-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 450px;
  max-width: 92%;
  background: rgba(13, 10, 24, 0.97);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border-light);
  box-shadow: -8px 0 36px rgba(0, 0, 0, 0.65);
  z-index: 25;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.db-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.db-drawer-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.db-drawer-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: rgba(168, 85, 247, 0.18);
  color: var(--accent-light);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.db-drawer-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}

.db-drawer-close {
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.db-drawer-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.db-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.db-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.db-form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.db-form-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.db-json-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.db-json-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.db-tool-btn {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.db-tool-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
}

.db-validity-pill {
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.db-validity-pill.valid {
  background: rgba(52, 211, 153, 0.12);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.db-validity-pill.invalid {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.db-editor-textarea {
  width: 100%;
  min-height: 240px;
  background: rgba(8, 6, 17, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: #e2e8f0;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  tab-size: 2;
}

.db-editor-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.db-drawer-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.db-drawer-status {
  font-size: 12px;
  color: var(--text-tertiary);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.db-drawer-status.error {
  color: var(--danger);
}

.db-drawer-status.success {
  color: var(--success);
}

.db-drawer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.routine-create {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: rgba(14, 10, 28, 0.45);
  border: 1px solid var(--border);
}

.routine-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.routine-field-wide {
  min-width: 0;
}

.routine-instruction-field {
  grid-column: 1 / -1;
}

.routine-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(8, 6, 18, 0.7);
  color: #fff;
  padding: 8px 10px;
  font: inherit;
}

.routine-input[name="cron"] {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
}

.routine-create-actions {
  display: flex;
  align-items: center;
}

.routine-create .routine-error {
  grid-column: 1 / -1;
}

.routine-card {
  cursor: default;
}

.routine-card .run-card-type {
  align-items: flex-start;
}

.routine-card:hover {
  transform: none;
}

.routine-card.is-paused {
  opacity: 0.72;
}

.routine-card-actions {
  display: flex;
  gap: 6px;
}

.routine-paused {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fbbf24;
}

.routine-when {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.routine-cron-label {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
}

.routine-cron {
  font-size: 13px;
  color: #e2e8f0;
}

.routine-cron-raw {
  font-size: 11px;
  color: var(--text-tertiary);
}

.routine-cron-hint {
  font-size: 11px;
  color: var(--text-tertiary);
}

.routine-description {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.routine-instruction-wrap {
  margin: 0;
  font-size: 12px;
  color: var(--text-tertiary);
}

.routine-instruction-wrap summary {
  cursor: pointer;
  user-select: none;
}

.routine-instruction {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.guild-routine-summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.guild-routine-agent {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guild-routine-agent-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.guild-routine-agent-avatar {
  display: flex;
  flex-shrink: 0;
}

.guild-routine-agent-name {
  font-size: 13px;
  font-weight: 650;
  color: #e2e8f0;
}

.guild-routine-agent-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-tertiary);
}

.routine-card.is-openable {
  cursor: pointer;
}

.routine-card.is-openable:hover {
  transform: translateY(-1px);
}

.issue-view .history-view-header {
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.issue-filters {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.issue-filter {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-tertiary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.issue-filter:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.16);
}

.issue-filter.is-active {
  color: #ffffff;
  background: rgba(168, 85, 247, 0.16);
  border-color: rgba(168, 85, 247, 0.4);
}

.issue-card {
  cursor: default;
}

.issue-card.is-resolved {
  opacity: 0.72;
}

.issue-card .run-card-type {
  align-items: flex-start;
  min-width: 0;
}

.issue-agent-avatar {
  flex-shrink: 0;
  margin-top: 2px;
}

.issue-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.issue-summary {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}

.issue-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.issue-kind,
.issue-severity {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
}

.issue-kind.kind-tool_failure {
  background: rgba(248, 113, 113, 0.16);
  color: #fca5a5;
}

.issue-kind.kind-truncated {
  background: rgba(251, 191, 36, 0.16);
  color: #fbbf24;
}

.issue-kind.kind-api {
  background: rgba(96, 165, 250, 0.16);
  color: #93c5fd;
}

.issue-kind.kind-other {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.issue-severity.severity-high {
  color: #fca5a5;
}

.issue-severity.severity-medium {
  color: #fbbf24;
}

.issue-severity.severity-low {
  color: var(--text-tertiary);
}

.issue-tool {
  font-size: 11px;
  color: var(--accent-light);
}

.issue-detail {
  font-size: 13px;
  color: var(--text-secondary);
}

.issue-run-link {
  border: 0;
  background: transparent;
  color: var(--accent-light);
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.issue-run-link:hover {
  text-decoration: underline;
}

.scripts-create {
  grid-template-columns: minmax(140px, 200px) 1fr auto;
}

.scripts-source-field {
  grid-column: 1 / -1;
}

.scripts-source-input,
.script-source {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.script-source {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(8, 6, 18, 0.7);
  border: 1px solid var(--border);
  color: #e2e8f0;
  overflow: auto;
  white-space: pre-wrap;
  max-height: 240px;
}

.usage-page {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 880px;
}

.usage-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.usage-section-title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.usage-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.usage-stats.is-compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
}

.usage-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.usage-stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.usage-stat-value {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
}

.usage-account {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.usage-account.is-current {
  border-color: rgba(168, 85, 247, 0.35);
  background: rgba(168, 85, 247, 0.08);
}

.usage-account-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.usage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(8, 6, 18, 0.35);
  border: 1px solid transparent;
  color: inherit;
  text-align: left;
}

.usage-row.is-nested {
  margin-left: 28px;
  width: calc(100% - 28px);
}

.usage-row.is-openable {
  cursor: pointer;
}

.usage-row.is-openable:hover {
  border-color: rgba(168, 85, 247, 0.28);
  background: rgba(168, 85, 247, 0.1);
}

.usage-row-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.usage-row-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.usage-row-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.usage-row-title {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
}

.usage-row-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.usage-row-metrics {
  display: flex;
  gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.usage-empty,
.usage-crumb {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ==========================================================================
   AGENT MODAL LOADER & SPINNERS
   ========================================================================== */

.agent-modal-loading-card {
  position: relative;
  background: 
    radial-gradient(ellipse 540px 360px at 0% 0%, rgba(var(--agent-color-rgb, 168, 85, 247), 0.15) 0%, transparent 75%),
    #0d0b18;
  border: 1px solid rgba(var(--agent-color-rgb, 168, 85, 247), 0.28);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.85), 0 0 50px rgba(var(--agent-color-rgb, 168, 85, 247), 0.18);
}

.agent-modal-loading-body {
  flex: 1;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.agent-modal-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 440px;
  gap: 22px;
  animation: agentLoaderFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* Futuristic Multi-ring Orbital Loader */
.agent-modal-loader-visual {
  position: relative;
  width: 84px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-loader-orbit-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: #c084fc;
  border-right-color: #a855f7;
  border-bottom-color: rgba(99, 102, 241, 0.4);
  animation: agentOrbitSpin 1.3s linear infinite;
  filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.5));
}

.agent-loader-glow-core {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.15) 0%, rgba(168, 85, 247, 0.25) 50%, rgba(99, 102, 241, 0.2) 100%);
  border: 1px solid rgba(168, 85, 247, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c084fc;
  box-shadow: 0 0 32px rgba(168, 85, 247, 0.35), inset 0 0 18px rgba(168, 85, 247, 0.2);
}

.agent-loader-pulse-ring {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px solid rgba(168, 85, 247, 0.25);
  animation: pulse-ring 2.2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
  pointer-events: none;
}

.agent-loader-icon {
  animation: float 3.2s ease-in-out infinite;
  filter: drop-shadow(0 0 8px rgba(192, 132, 252, 0.65));
}

@keyframes agentOrbitSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Loader Text */
.agent-loader-text-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.agent-loader-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  font-family: var(--font);
}

.agent-loader-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.5;
}

/* Animated Shimmer Progress Bar */
.agent-loader-progress-track {
  width: 190px;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.agent-loader-progress-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 45%;
  background: linear-gradient(90deg, transparent, #c084fc 50%, #6366f1 100%);
  border-radius: 9999px;
  animation: agentProgressBar 1.4s ease-in-out infinite;
  box-shadow: 0 0 12px #c084fc;
}

@keyframes agentProgressBar {
  0% {
    left: -45%;
  }
  100% {
    left: 100%;
  }
}

/* Skeleton Loading Elements for Header */
.agent-modal-avatar-skeleton {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(var(--agent-color-rgb, 168, 85, 247), 0.2) 50%, rgba(255, 255, 255, 0.04) 75%);
  background-size: 200% 100%;
  animation: agentShimmer 1.8s infinite;
  border: 1px solid rgba(var(--agent-color-rgb, 255, 255, 255), 0.1);
}

.agent-modal-title-skeleton {
  width: 130px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(168, 85, 247, 0.14) 50%, rgba(255, 255, 255, 0.04) 75%);
  background-size: 200% 100%;
  animation: agentShimmer 1.8s infinite;
}

@keyframes agentShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Status tag loading / connecting */
.agent-status-tag.connecting,
.agent-status-tag.loading {
  color: #c084fc;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Generic Spinner / History Loading Fallbacks */
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(168, 85, 247, 0.2);
  border-top-color: #c084fc;
  animation: agentOrbitSpin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

.history-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 16px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ==========================================================================
   MOBILE SUPPORT & RESPONSIVE DESIGN
   ========================================================================== */

/* Mobile App Bar Elements (Hidden on Desktop) */
.mobile-header {
  display: none;
}

.rail-close-btn {
  display: none;
}

.rail-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(4, 3, 10, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.rail-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Tablet and Mobile Shell (< 768px) */
@media (max-width: 768px) {
  html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  .app {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100%;
    height: 100dvh;
    grid-template-columns: 1fr;
    overflow: hidden;
    position: relative;
  }

  /* Mobile Top Navigation Bar */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 14px;
    padding-top: max(0px, env(safe-area-inset-top));
    background: rgba(9, 7, 20, 0.88);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 30;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
  }

  .mobile-menu-btn:active,
  .mobile-menu-btn:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.4);
    color: #ffffff;
  }

  .mobile-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #ffffff;
    max-width: calc(100vw - 120px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-view-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-light);
    box-shadow: 0 0 8px var(--accent);
    flex-shrink: 0;
    animation: pulse-glow 2.5s infinite ease-in-out;
  }

  .mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 44px;
  }

  .account-wrap {
    position: absolute;
    top: calc(max(0px, env(safe-area-inset-top)) + 8px);
    right: 14px;
    z-index: 35;
  }

  /* Rail as Off-Canvas Drawer */
  .rail-backdrop {
    display: block;
  }

  .rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 86vw;
    max-width: 310px;
    height: 100%;
    height: 100dvh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: none;
    border-right: 1px solid rgba(168, 85, 247, 0.25);
    background: #0d0a1c;
  }

  .rail.is-open {
    transform: translateX(0);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.92), 0 0 24px rgba(168, 85, 247, 0.18);
  }

  .rail-brand {
    padding: max(14px, env(safe-area-inset-top)) 16px 14px;
    justify-content: space-between;
  }

  .rail-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    margin-left: auto;
    color: var(--text-tertiary);
    cursor: pointer;
  }

  .rail-close-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
  }

  .rail-user {
    padding: 0 14px 12px;
  }

  .rail-section-header {
    padding: 8px 16px;
  }

  .rail-footer {
    padding: 12px 14px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  /* Workspace & Pane */
  .workspace {
    width: 100vw;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: auto;
  }

  .pane {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .pane-empty {
    padding: 16px;
  }

  .empty-hero {
    max-width: 100%;
  }

  .empty-title {
    font-size: 22px;
  }

  .empty-subtitle {
    font-size: 13px;
  }

  .pane-header {
    padding: 14px 16px 10px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .pane-body {
    padding: 12px 14px;
  }

  /* Guild View Header & Controls */
  .guild-view-header {
    padding: 12px 64px 6px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .guild-header-main {
    flex: 1;
    min-width: 160px;
  }

  .guild-heading {
    font-size: 18px;
  }

  .guild-about-row {
    max-width: 100%;
  }

  .guild-header-controls {
    margin-top: 2px;
    flex-wrap: wrap;
  }

  .guild-limit-popover {
    width: min(280px, calc(100vw - 32px));
    right: -8px;
  }

  .guild-pill-btn {
    padding: 4px 10px;
    font-size: 11.5px;
  }

  /* Quick Agent Cards Strip */
  .guild-agent-cards-row {
    padding: 4px 14px 8px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .guild-agent-cards-row::-webkit-scrollbar {
    display: none;
  }

  .guild-agent-card {
    flex-shrink: 0;
  }

  /* Tabs Bar */
  .tabs,
  .guild-tabs,
  .agent-tabs {
    padding: 4px 14px 0;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar,
  .guild-tabs::-webkit-scrollbar,
  .agent-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    padding: 8px 12px;
    font-size: 12.5px;
    flex-shrink: 0;
    min-height: 38px;
  }

  /* Chat Workspace & Logs */
  .chat-workspace {
    padding: 0;
    height: 100%;
    max-width: 100%;
  }

  .chat-log,
  .group-chat-log {
    padding: 8px 10px 4px;
    gap: 12px;
  }

  .msg {
    max-width: 93%;
    padding: 10px 12px;
    font-size: 13.5px;
  }

  .msg pre {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 12px;
  }

  .msg table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Chat Composers */
  .group-composer {
    margin: 0 8px 8px;
  }

  .composer-card {
    margin: 0 0 6px;
    padding: 8px 10px 6px;
  }

  .composer-inner textarea {
    font-size: 16px !important; /* Prevents auto-zoom on iOS Safari */
    min-height: 48px;
    padding: 2px 0 6px;
  }

  .composer-toolbar {
    padding-top: 4px;
  }

  .composer-hints {
    display: none; /* Hide desktop keyboard hints on mobile touch */
  }

  .composer-buttons {
    margin-left: auto;
    gap: 6px;
  }

  .btn-send {
    padding: 7px 14px;
    font-size: 12.5px;
    min-height: 36px;
  }

  .composer-to-bar {
    padding: 4px 0 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .composer-to-bar::-webkit-scrollbar {
    display: none;
  }

  .composer-pill {
    flex-shrink: 0;
  }

  /* Full-Screen Agent Modal for Mobile */
  .agent-modal-overlay {
    padding: 0;
  }

  .agent-modal-container {
    width: 100vw;
    height: 100%;
    height: 100dvh;
  }

  .agent-modal-card {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100% !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  .agent-modal-avatar {
    width: 48px;
    height: 48px;
    margin-top: 0;
    margin-left: 0;
  }

  .agent-modal-avatar ai-avatar {
    transform: scale(0.6);
    transform-origin: center center;
  }

  .agent-modal-meta {
    margin-top: 0;
  }

  .agent-modal-header {
    padding: max(12px, env(safe-area-inset-top)) 14px 10px;
    gap: 8px;
  }

  .agent-modal-name {
    font-size: 16px;
  }

  .agent-expand-btn {
    display: none !important; /* Always full-view on mobile */
  }

  .agent-modal-header-right button {
    width: 38px;
    height: 38px;
  }

  .agent-modal-body {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  /* Split View Adapters (Files & Database) */
  .file-browser,
  .db-browser {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    min-height: 360px;
  }

  .fb-sidebar,
  .db-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 150px;
    overflow-y: auto;
  }

  .file-browser.fb-solo {
    grid-template-rows: 1fr;
  }

  .file-browser.fb-solo > .fb-sidebar {
    display: none;
  }

  .db-viewer-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
  }

  .db-viewer-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .db-search-wrap {
    width: 100%;
  }

  .db-search-input {
    width: 100% !important;
  }

  .fb-search-input,
  .fb-find-input {
    font-size: 16px;
  }

  .fb-find-bar {
    padding: 8px 12px;
  }

  .fb-preview {
    padding: 14px 16px 24px;
  }

  .fb-mode-toggle {
    order: -1;
  }

  .db-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Form & Settings Responsiveness */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .grid-span-2 {
    grid-column: span 1;
  }

  .md-editor {
    grid-template-columns: 1fr;
  }

  .routine-create,
  .scripts-create {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .modal-card {
    width: min(94vw, 440px);
    max-height: calc(100dvh - 32px);
    padding: 18px 16px;
  }

  .modal-header {
    margin-bottom: 14px;
  }

  .usage-page {
    padding: 12px 14px;
  }

  .usage-stats.is-compact {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .usage-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .usage-row-metrics {
    width: 100%;
    justify-content: flex-start;
  }
}

/* Extra Compact Phones (< 480px) */
@media (max-width: 480px) {
  .guild-heading {
    font-size: 17px;
  }

  .empty-title {
    font-size: 20px;
  }

  .empty-subtitle {
    font-size: 13px;
  }

  .msg {
    max-width: 96%;
    padding: 9px 11px;
  }

  .usage-stats.is-compact {
    grid-template-columns: 1fr;
  }

  .tab {
    padding: 7px 10px;
    font-size: 12px;
  }
}

/* OAuth Authorization Modal */
.oauth-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 3, 10, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: oauth-fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.oauth-modal-card {
  width: min(540px, 100%);
  background: var(--surface-solid, #12101c);
  border: 1px solid var(--border-light, rgba(255, 255, 255, 0.12));
  border-radius: var(--radius-lg, 16px);
  padding: 24px 28px 26px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(168, 85, 247, 0.2);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: oauth-scale-up 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes oauth-scale-up {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.oauth-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.oauth-modal-title {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.oauth-modal-subtitle {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-tertiary, #94a3b8);
  line-height: 1.45;
}

.oauth-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.oauth-option-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.oauth-option-box:hover {
  border-color: rgba(168, 85, 247, 0.3);
  background: rgba(255, 255, 255, 0.045);
}

.oauth-option-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.oauth-option-title {
  font-size: 13px;
  font-weight: 600;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.oauth-option-desc {
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.45;
  margin: 0;
}

.oauth-copy-feedback {
  font-size: 11px;
  color: #34d399;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 4px;
}

.oauth-copy-feedback.is-visible {
  display: inline-flex;
}

.oauth-url-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md, 8px);
  padding: 3px 4px 3px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.oauth-url-bar:focus-within {
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

.oauth-url-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 11px;
  color: #e2e8f0;
  text-overflow: ellipsis;
  padding: 6px 0;
  cursor: text;
}

.oauth-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.oauth-copy-btn:hover {
  background: rgba(168, 85, 247, 0.25);
  border-color: rgba(168, 85, 247, 0.45);
}

.oauth-copy-btn.copied {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.oauth-status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md, 8px);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.oauth-status-card.is-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.25);
}

.oauth-pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
  animation: oauth-pulse 1.8s infinite;
  flex-shrink: 0;
}

@keyframes oauth-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

.oauth-status-card.is-success .oauth-pulse-dot {
  background: #10b981;
  box-shadow: none;
  animation: none;
}

.oauth-status-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}

.oauth-status-title {
  font-weight: 600;
  color: #f1f5f9;
}

.oauth-status-desc {
  color: var(--text-tertiary, #94a3b8);
  font-size: 11px;
}

.oauth-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

/* Mention Autocomplete Dropdown in Chat */
.mention-autocomplete {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 10px;
  right: 10px;
  max-width: 360px;
  max-height: 220px;
  overflow-y: auto;
  background: rgba(20, 16, 32, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 1px rgba(168, 85, 247, 0.5);
  padding: 4px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mention-autocomplete-header {
  padding: 4px 8px 3px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a855f7;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 2px;
}

.mention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.12s ease;
  color: #cbd5e1;
}

.mention-item:hover,
.mention-item.active {
  background: rgba(168, 85, 247, 0.2);
  color: #ffffff;
}

.mention-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.mention-item-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.mention-item-name {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: #c084fc;
}

.mention-item:hover .mention-item-name,
.mention-item.active .mention-item-name {
  color: #e9d5ff;
}

.mention-item-focus {
  font-size: 11px;
  color: #94a3b8;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Thinking Level Config Field */
.thinking-level-field {
  transition: opacity 0.2s ease, max-height 0.2s ease;
}

.thinking-level-field[hidden] {
  display: none !important;
}

/* Prompt Studio */
.pane:has(> .studio-landing),
.pane:has(> .studio-workspace) {
  overflow: hidden;
}

.studio-landing,
.studio-workspace {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: 8px;
  padding: 8px 12px 10px;
}

.studio-landing {
  overflow: auto;
}

.studio-landing.studio-needs-guild {
  justify-content: center;
}

.studio-landing.studio-landing-guild > .pane-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.studio-workspace {
  flex: 1 1 auto;
  overflow: hidden;
}

.studio-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .studio-mode-grid {
    grid-template-columns: 1fr;
  }
}

.studio-mode-card {
  position: relative;
  text-align: left;
  padding: 22px 24px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(13, 10, 26, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: inherit;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.studio-mode-card:hover:not(.is-disabled) {
  border-color: rgba(168, 85, 247, 0.45);
  background: rgba(20, 15, 40, 0.65);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.12);
}

.studio-mode-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.studio-mode-icon.is-muted {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text-tertiary);
}

.studio-mode-card h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.studio-mode-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.studio-mode-action {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-light);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.studio-mode-card.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  border-style: dashed;
}

.studio-create-card-wrap {
  border: 1px solid var(--border-light);
  border-radius: 16px;
  background: rgba(13, 10, 26, 0.7);
  backdrop-filter: blur(16px);
  padding: 22px 24px;
  margin-bottom: 24px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.studio-create-head {
  margin-bottom: 18px;
}

.studio-create-head h4 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.studio-create-head p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.studio-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.studio-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.studio-create,
.studio-recent {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.studio-session-row,
.studio-agent-btn {
  display: flex;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
}

.studio-session-row:hover,
.studio-agent-btn:hover,
.studio-agent-btn.selected {
  border-color: rgba(168, 85, 247, 0.35);
  background: rgba(168, 85, 247, 0.08);
}

.studio-session-copy,
.studio-agent-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.studio-session-title,
.studio-agent-name {
  font-weight: 600;
}

.studio-session-sub,
.studio-agent-sub,
.studio-agent-meta,
.studio-agent-warn,
.studio-focus-note,
.studio-empty {
  font-size: 12px;
  color: var(--text-secondary);
}

.studio-evidence-note {
  display: none;
}

.studio-agent-warn,
.studio-warn {
  color: #fbbf24;
  font-size: 12px;
}

.studio-workspace {
  padding-bottom: 8px;
}

.studio-landing > .pane-header,
.studio-header.pane-header {
  padding: 0 0 2px;
  border-bottom: none;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.studio-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.studio-header .pane-title-wrap,
.studio-landing > .pane-header .pane-title-wrap {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
}

.studio-header .pane-title,
.studio-landing > .pane-header .pane-title {
  font-size: 16px;
  line-height: 1.2;
}

.studio-header .pane-subtitle,
.studio-landing > .pane-header .pane-subtitle {
  margin: 0;
  font-size: 12px;
}

.studio-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.studio-chip {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Studio Top Agent Bar & Strip */
.studio-agent-bar {
  display: flex;
  align-items: stretch;
  gap: 8px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0;
  min-height: 0;
  flex-shrink: 0;
}

.studio-agent-strip {
  display: flex;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  padding: 0;
  scrollbar-width: thin;
}

.studio-agent-strip::-webkit-scrollbar {
  height: 4px;
}

.studio-agent-strip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

.studio-bar-search {
  flex-shrink: 0;
  width: 170px;
  display: flex;
  align-items: center;
  padding-bottom: 4px;
}

.studio-bar-search .studio-filter {
  margin-bottom: 0;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
}

.studio-agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 8px;
  border-radius: 6px 6px 0 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.studio-agent-pill:hover {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.03);
  color: #ffffff;
}

.studio-agent-pill.selected {
  border-color: transparent;
  border-bottom-color: var(--accent);
  background: rgba(168, 85, 247, 0.08);
  box-shadow: none;
  color: #ffffff;
}

.studio-guild-overview-pill {
  border-color: transparent;
  background: transparent;
}

.studio-guild-overview-pill.selected {
  border-bottom-color: var(--accent);
  background: rgba(168, 85, 247, 0.08);
}

.studio-agent-pill-icon {
  font-size: 14px;
  display: inline-flex;
  align-items: center;
}

.studio-agent-pill-avatar {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.studio-agent-pill-name {
  font-weight: 600;
  color: inherit;
}

.studio-agent-pill-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

.studio-agent-pill.selected .studio-agent-pill-meta {
  color: #e2e8f0;
}

.studio-agent-pill-count {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.studio-agent-pill.selected .studio-agent-pill-count {
  background: rgba(168, 85, 247, 0.35);
  color: #ffffff;
}

.studio-agent-pill.has-pending-draft {
  border-color: transparent;
  background: transparent;
}

.studio-agent-pill.has-pending-draft:hover {
  border-color: transparent;
  background: rgba(245, 158, 11, 0.08);
}

.studio-agent-pill.has-pending-draft.selected {
  border-color: transparent;
  border-bottom-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  box-shadow: none;
}

.studio-pending-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.8);
}

.studio-pending-dot.pulse {
  animation: pulsePendingDot 1.8s infinite ease-in-out;
}

.studio-pending-dot.mini {
  width: 5px;
  height: 5px;
}

@keyframes pulsePendingDot {
  0% {
    transform: scale(0.9);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  }
  70% {
    transform: scale(1.2);
    box-shadow: 0 0 0 5px rgba(245, 158, 11, 0);
  }
  100% {
    transform: scale(0.9);
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

.studio-agent-pill-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
}

.studio-agent-pill-badge.is-draft {
  background: rgba(168, 85, 247, 0.25);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.4);
}

.studio-agent-pill-badge.is-draft.has-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.studio-agent-pill-badge.is-warn {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.studio-empty-pill {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 8px;
}

/* Horizontal Collapsible Inspector Panel */
.studio-inspector-panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
  overflow: hidden;
  flex: 1.65 1 0;
  min-height: 0;
}

.studio-inspector-panel.is-collapsed {
  background: rgba(255, 255, 255, 0.015);
  border-color: rgba(255, 255, 255, 0.07);
  flex: 0 0 auto;
}

.studio-inspector-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  min-height: 0;
  flex-shrink: 0;
}

.studio-inspector-bar.is-collapsed-bar {
  border-bottom: none;
  cursor: pointer;
  padding: 6px 14px;
  transition: background 0.15s ease;
}

.studio-inspector-bar.is-collapsed-bar:hover {
  background: rgba(168, 85, 247, 0.06);
}

.studio-inspector-bar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex-wrap: wrap;
}

.studio-inspector-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.studio-inspector-target-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.studio-target-avatar {
  display: inline-flex;
  align-items: center;
}

.studio-inspector-target-name {
  font-weight: 600;
  font-size: 13px;
  color: #ffffff;
}

.studio-inspector-target-badge {
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 7px;
  border-radius: 999px;
}

.studio-inspector-target-dim {
  font-size: 12px;
  color: #c4b5fd;
  font-weight: 500;
  margin-left: 2px;
}

.studio-inspector-collapsed-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #a855f7;
  font-weight: 700;
  background: rgba(168, 85, 247, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.studio-dimension-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.studio-dimension-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.studio-dimension-select {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.studio-dimension-select:hover {
  border-color: rgba(168, 85, 247, 0.45);
}

.studio-dimension-select:focus {
  border-color: #a855f7;
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

.studio-dimension-select option {
  background: #18181b;
  color: #f1f5f9;
}

.studio-collapse-icon {
  font-size: 9px;
  display: inline-block;
  margin-right: 2px;
}

/* Notice Banner */
.studio-draft-notice-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: rgba(245, 158, 11, 0.08);
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  font-size: 12px;
  color: #fef08a;
  flex-shrink: 0;
}

.studio-banner-text {
  font-weight: 500;
}

.studio-banner-btn {
  margin-left: auto;
  padding: 3px 10px;
  font-size: 11px;
}

/* Body & Split Grid */
.studio-inspector-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 8px 10px;
  overflow-y: auto;
  overflow-x: hidden;
}

.studio-inspector-single-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.studio-inspector-body:has(.is-browser) {
  overflow: hidden;
  padding: 0;
}

.studio-inspector-single-content.is-browser,
.studio-col-content.is-browser {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.studio-inspector-single-content .file-browser,
.studio-inspector-single-content .db-scoped,
.studio-inspector-single-content .db-browser,
.studio-col-content .file-browser,
.studio-col-content .db-scoped,
.studio-col-content .db-browser {
  flex: 1;
  min-height: 0;
  height: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.studio-inspector-body.is-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
}

.studio-inspector-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.15);
}

.studio-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.studio-col-content {
  overflow-y: auto;
  min-width: 0;
  min-height: 0;
  flex: 1;
}

.studio-empty-card {
  padding: 12px;
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.01);
}

.studio-all-drafts-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.studio-pane-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c4b5fd;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.studio-chat .studio-pane-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.studio-chat .studio-pane-title .streaming-pill {
  text-transform: none;
  letter-spacing: 0;
}

.studio-filter {
  width: 100%;
  margin-bottom: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  color: inherit;
  border-radius: 10px;
  padding: 8px 10px;
}

.studio-section,
.studio-draft {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.studio-inspector-single-content > .studio-draft:only-child,
.studio-col-content > .studio-draft:only-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.studio-section header,
.studio-draft header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.studio-section h4,
.studio-draft h4 {
  margin: 0;
  font-size: 13px;
}

.studio-section header span,
.studio-draft header span {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  font-family: var(--mono);
  opacity: 0.8;
}

.studio-chat .msg-time {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  font-family: var(--mono);
}

.studio-draft-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  flex-shrink: 0;
}

.studio-draft-flags .studio-warn,
.studio-draft-flags .studio-focus-note {
  margin: 0;
  font-size: 11px;
}

.studio-draft-rationale {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-secondary);
  max-height: 5.8em;
  overflow: auto;
  flex-shrink: 0;
}

.studio-draft-rationale strong {
  color: var(--text);
  font-weight: 600;
}

.studio-draft > p {
  margin: 0;
}

.studio-draft .form-actions,
.studio-draft-actions {
  margin-top: 6px;
  flex-shrink: 0;
}

/* Multi-draft switcher */
.studio-draft-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 8px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.2);
  flex-shrink: 0;
}

.studio-draft-switcher-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.studio-draft-switcher-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.studio-draft-switcher-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.1);
  color: #fef08a;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.studio-draft-switcher-chip:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.6);
}

.studio-diff-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 2px 0 0;
  flex-shrink: 0;
}

.studio-diff-wrap {
  margin-bottom: 0;
  flex: 1;
  min-height: 120px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.studio-diff-split {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.studio-diff-split-head,
.studio-diff-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.studio-diff-split-head {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: rgba(12, 10, 22, 0.95);
  border-bottom: 1px solid var(--border);
}

.studio-diff-split-head > span:first-child,
.studio-diff-cell:first-child {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.studio-diff-proposed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-right: 6px;
}

.studio-diff-edit-btn {
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.studio-diff-split-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.studio-diff-cell {
  padding: 1px 8px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11px;
  line-height: 1.4;
  min-width: 0;
  border-left: 3px solid transparent;
}

.studio-diff-cell.is-del {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-left-color: #ef4444;
}

.studio-diff-cell.is-add {
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
  border-left-color: #22c55e;
}

.studio-diff-cell.is-eq {
  color: #94a3b8;
}

.studio-diff-cell.is-empty {
  background: rgba(255, 255, 255, 0.02);
}

.studio-draft-edit-details {
  margin-bottom: 0;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.studio-draft-edit-details[open] {
  flex: 0 1 auto;
  max-height: 28vh;
  overflow: auto;
}

.studio-draft-edit-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.studio-draft-edit-summary {
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
}

.studio-draft-edit-summary:hover {
  color: #c4b5fd;
}

.studio-draft-edit-label {
  display: block;
  margin-top: 8px;
  font-size: 12px;
}

.studio-draft-editor {
  max-height: 22vh;
  overflow: auto;
  resize: vertical;
}

.studio-draft-edit-modal {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}

.studio-draft-edit-modal .studio-draft-editor {
  min-height: 48vh;
  max-height: none;
  flex: 1;
  width: 100%;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
}

.studio-source,
.studio-diff,
.studio-draft-editor {
  width: 100%;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  color: inherit;
}

.studio-diff {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  line-height: 1.45;
  padding: 4px 0;
}

.studio-diff.studio-diff-split {
  padding: 0;
  overflow: hidden;
  white-space: normal;
}

.studio-diff-line {
  padding: 2px 10px;
  white-space: pre-wrap;
  word-break: break-all;
}

.studio-diff-line.is-add {
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
  border-left: 3px solid #22c55e;
}

.studio-diff-line.is-del {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-left: 3px solid #ef4444;
}

.studio-diff-line.is-eq {
  color: #94a3b8;
  border-left: 3px solid transparent;
}

/* Full-width Studio Coach Chat */
.studio-chat {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 140px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 10px;
}

.studio-composer {
  flex-shrink: 0;
}

.studio-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.studio-chat .form-actions {
  margin-top: 8px;
}

.studio-composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 52px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  color: inherit;
  border-radius: 8px;
  padding: 8px 10px;
}

.studio-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 0;
}

.studio-starter {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
}

.studio-starter:hover:not(:disabled) {
  border-color: rgba(168, 85, 247, 0.35);
  background: rgba(168, 85, 247, 0.08);
}

.studio-starter:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.studio-roster-list {
  margin: 0;
  padding-left: 18px;
}

.studio-roster-item {
  font-size: 13px;
  margin: 4px 0;
}

.studio-inspect-tabs {
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.studio-artifact-row {
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.studio-run-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

@media (max-width: 980px) {
  .studio-mode-grid,
  .studio-header {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
  }

  .studio-agent-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .studio-bar-search {
    width: 100%;
  }

  .studio-inspector-body.is-split {
    grid-template-columns: 1fr;
  }

  .studio-inspector-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .studio-inspector-bar-left {
    width: 100%;
    justify-content: space-between;
  }

  .studio-inspector-bar-right {
    margin-left: auto;
  }
}

.mcp-card-description {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted, #9aa3b2);
}

/* ==========================================================================
   MCP CATALOG (PLATFORM INFRASTRUCTURE)
   ========================================================================== */
.admin-mcp {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 8px 0 32px;
}

.admin-mcp-header {
  margin-bottom: 4px;
}

.admin-mcp-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.admin-mcp-badge-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(168, 85, 247, 0.14);
  color: var(--accent-light);
  border: 1px solid rgba(168, 85, 247, 0.25);
}

.admin-mcp-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1024px) {
  .admin-mcp-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .admin-mcp-metrics-grid {
    grid-template-columns: 1fr;
  }
}

.admin-mcp-metric-card {
  padding: 18px 20px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(13, 10, 26, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-mcp-metric-card:hover {
  border-color: rgba(168, 85, 247, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.admin-mcp-metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.admin-mcp-metric-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.admin-mcp-metric-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

.admin-mcp-metric-card.is-pending .admin-mcp-metric-icon {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
}

.admin-mcp-metric-card.is-ready .admin-mcp-metric-icon {
  background: rgba(52, 211, 153, 0.12);
  color: #34d399;
}

.admin-mcp-metric-card.is-live .admin-mcp-metric-icon {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.admin-mcp-metric-card.is-servers .admin-mcp-metric-icon {
  background: rgba(99, 102, 241, 0.14);
  color: #a5b4fc;
}

.admin-mcp-metric-count {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
  font-family: var(--mono);
}

.admin-mcp-metric-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.admin-mcp-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
  background: rgba(13, 10, 26, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
}

.admin-mcp-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.admin-mcp-meta {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--text-secondary);
}

.admin-mcp-form {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-mcp-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.admin-mcp-field input,
.admin-mcp-field textarea,
.admin-mcp-field select,
.builder-input,
.builder-select {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(7, 6, 14, 0.65);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.admin-mcp-field input:focus,
.admin-mcp-field textarea:focus,
.admin-mcp-field select:focus,
.builder-input:focus,
.builder-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.admin-mcp-field textarea {
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
}

.admin-mcp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.95fr);
  gap: 18px;
  align-items: start;
}

@media (max-width: 1100px) {
  .admin-mcp-layout {
    grid-template-columns: 1fr;
  }
}

.admin-mcp-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.01em;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-tertiary);
  white-space: nowrap;
}

.admin-mcp-chip.is-ready {
  background: rgba(52, 211, 153, 0.14);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.admin-mcp-chip.is-live {
  background: rgba(168, 85, 247, 0.18);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.admin-mcp-chip.is-warn,
.admin-mcp-chip.is-draft {
  background: rgba(251, 191, 36, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.admin-mcp-chip.is-source {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
}

.admin-mcp-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-mcp-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.admin-mcp-search {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(7, 6, 14, 0.6);
  color: var(--text);
  font-size: 13px;
}

.admin-mcp-search:focus {
  outline: none;
  border-color: var(--border-focus);
}

.admin-mcp-filter {
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.admin-mcp-filter:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.admin-mcp-filter.is-on {
  border-color: rgba(168, 85, 247, 0.4);
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-light);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.18);
}

.admin-mcp-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.admin-mcp-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.admin-mcp-group-head strong {
  font-size: 14px;
  color: var(--text);
  display: block;
}

.admin-mcp-group-head span {
  font-size: 11px;
  color: var(--text-tertiary);
}

.admin-mcp-connector,
.admin-mcp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.025);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.admin-mcp-connector:hover,
.admin-mcp-row:hover {
  border-color: rgba(168, 85, 247, 0.3);
  background: rgba(168, 85, 247, 0.06);
}

.admin-mcp-connector.is-open {
  border-color: rgba(168, 85, 247, 0.4);
  background: rgba(168, 85, 247, 0.08);
}

.admin-mcp-row-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.admin-mcp-row-main strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.admin-mcp-row-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-mcp-row-wrap,
.admin-mcp-inline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(7, 6, 14, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.admin-mcp-inline .admin-mcp-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-mcp-inline .admin-mcp-field-wide {
  grid-column: 1 / -1;
}

.admin-mcp-empty {
  margin: 10px 0;
  font-size: 13px;
  color: var(--text-tertiary);
  font-style: italic;
}

.admin-mcp-status {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  background: rgba(52, 211, 153, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

/* ==========================================================================
   BUILDER STUDIO & WORKSPACE
   ========================================================================== */
.builder-workspace,
.recipe-workspace,
.recipe-library,
.apply-workspace {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.builder-header,
.recipe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 10, 26, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-shrink: 0;
}

.builder-header-left,
.recipe-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.builder-back-btn,
.recipe-back-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.builder-back-btn:hover,
.recipe-back-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: rgba(168, 85, 247, 0.4);
}

.builder-title-row,
.recipe-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.builder-pane-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.builder-status-pill,
.recipe-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-tertiary);
  border: 1px solid var(--border);
}

.builder-status-pill.is-draft,
.recipe-status-pill.is-draft {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.3);
}

.builder-status-pill.is-ready,
.recipe-status-pill.is-ready {
  background: rgba(52, 211, 153, 0.14);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
}

.builder-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.builder-version-pill,
.recipe-source-pill {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-tertiary);
  font-family: var(--mono);
}

.builder-header-actions,
.recipe-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.builder-publish,
.builder-deploy,
.recipe-export,
.recipe-apply {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* 2-Column Grid (Blueprint + Coach) */
.builder-grid {
  display: grid;
  grid-template-columns: minmax(460px, 1.45fr) minmax(360px, 1fr);
  gap: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

@media (max-width: 1100px) {
  .builder-grid {
    grid-template-columns: 1.25fr 1fr;
  }
}

@media (max-width: 960px) {
  .builder-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .builder-col {
    border-right: none !important;
    border-bottom: 1px solid var(--border);
    min-height: 400px;
  }
}

.builder-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: rgba(8, 6, 17, 0.3);
}

.builder-col:last-child {
  border-right: 0;
}

.builder-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}

.builder-col-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.builder-col-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
}

.builder-col-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-light);
}

.builder-col-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-tertiary);
}

.builder-col-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
}

/* Empty States */
.builder-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 20px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.015);
  gap: 10px;
  margin: 10px 0;
}

.builder-empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.2);
  color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.15);
}

.builder-empty-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.builder-empty-desc {
  margin: 0;
  font-size: 12px;
  color: var(--text-tertiary);
  max-width: 260px;
  line-height: 1.45;
}

/* Roles List & Role Cards */
.builder-roles-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recipe-roles-tally-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  color: var(--text-secondary);
}

.recipe-tally-item strong {
  color: var(--text);
}

.recipe-tally-dot {
  color: var(--text-muted);
}

.builder-role-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(13, 10, 26, 0.5);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}

.builder-role-card:hover {
  border-color: rgba(168, 85, 247, 0.4);
  background: rgba(20, 15, 40, 0.65);
  transform: translateY(-1px);
}

.builder-role-card.selected {
  border-color: rgba(168, 85, 247, 0.7);
  background: rgba(168, 85, 247, 0.12);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.2);
}

.builder-role-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.builder-role-avatar {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(13, 10, 26, 0.7);
  border: 1px solid rgba(168, 85, 247, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.builder-role-avatar ai-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.builder-role-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.builder-role-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.builder-role-slug {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-tertiary);
}

.builder-role-focus {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.builder-role-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.builder-role-chip {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-tertiary);
}

.builder-role-chip.is-warn {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.builder-role-chip.is-routine {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}

.builder-role-chip.is-conn {
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
}

/* Blueprint Section Styling */
.recipe-plan {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.recipe-plan-tally {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.recipe-plan-metric {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(13, 10, 26, 0.6);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  transition: all 0.15s ease;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

.recipe-plan-metric:hover {
  border-color: rgba(168, 85, 247, 0.45);
  background: rgba(168, 85, 247, 0.1);
  transform: translateY(-1px);
}

.recipe-plan-metric:active {
  transform: translateY(0);
}

.recipe-metric-count {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  font-family: var(--mono);
}

.recipe-metric-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.recipe-plan-metric.is-warn {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}

.recipe-plan-metric.is-warn .recipe-metric-count {
  color: #fbbf24;
}

/* Sections & Stack */
.recipe-plan-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-margin-top: 16px;
  transition: outline 0.3s ease;
}

.recipe-plan-section.is-highlighted {
  animation: sectionHighlightPulse 1.4s ease;
}

@keyframes sectionHighlightPulse {
  0% {
    outline: 2px solid rgba(168, 85, 247, 0.7);
    outline-offset: 4px;
    border-radius: 8px;
  }
  100% {
    outline: 2px solid transparent;
    outline-offset: 4px;
  }
}

.recipe-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  transition: all 0.15s ease;
}

.recipe-section-header:hover h3 {
  color: var(--text);
}

.recipe-section-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recipe-section-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recipe-section-chevron-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  color: var(--text-tertiary);
  transition: all 0.15s ease;
}

.recipe-section-header:hover .recipe-section-chevron-wrap {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.recipe-section-chevron {
  transition: transform 0.2s ease;
}

.recipe-plan-section.is-open .recipe-section-chevron {
  transform: rotate(180deg);
}

.recipe-section-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recipe-plan-section.is-collapsed .recipe-section-body {
  display: none;
}

.btn-subtle-xs {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
}

.btn-subtle-xs:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

.recipe-plan-section h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.recipe-section-count {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-weight: 600;
}

.recipe-plan-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Base Recipe Card */
.recipe-plan-card {
  position: relative;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(18, 14, 32, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.15s ease;
}

/* Collapsible Agent Card */
.recipe-agent-card.is-collapsible {
  padding: 12px 16px;
  transition: all 0.2s ease;
}

.recipe-agent-card.is-collapsible.is-condensed:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(26, 20, 48, 0.6);
}

.recipe-agent-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  user-select: none;
}

.recipe-agent-summary-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.recipe-agent-summary-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.recipe-agent-summary-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.3;
}

.recipe-agent-card .recipe-agent-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.recipe-agent-card .recipe-agent-slug {
  font-size: 11.5px;
  font-family: var(--mono);
  color: #c084fc;
  font-weight: 600;
}

.recipe-agent-card .recipe-model-badge {
  font-size: 10px;
  font-family: var(--mono);
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-tertiary);
}

.recipe-agent-card .recipe-agent-focus {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recipe-agent-summary-aside {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.recipe-agent-mini-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.recipe-mini-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  font-family: var(--mono);
}

.recipe-mini-badge.is-conn {
  border-color: rgba(56, 189, 248, 0.25);
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.07);
}

.recipe-mini-badge.is-routine {
  border-color: rgba(251, 191, 36, 0.25);
  color: #fde047;
  background: rgba(251, 191, 36, 0.07);
}

.recipe-mini-badge.is-tools {
  border-color: rgba(168, 85, 247, 0.25);
  color: #d8b4fe;
  background: rgba(168, 85, 247, 0.07);
}

.recipe-reveal-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  transition: color 0.15s ease;
  white-space: nowrap;
}

.recipe-agent-toggle-btn,
.recipe-routine-toggle-btn,
.recipe-connector-toggle-btn {
  background: none;
  border: none;
  padding: 3px 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
  font-family: inherit;
}

.recipe-agent-summary:hover .recipe-agent-toggle-btn,
.recipe-routine-row-toggle:hover .recipe-routine-toggle-btn,
.recipe-connector-toggle:hover .recipe-connector-toggle-btn {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.recipe-agent-summary:hover .recipe-reveal-label,
.recipe-routine-row-toggle:hover .recipe-reveal-label,
.recipe-connector-toggle:hover .recipe-reveal-label {
  color: var(--text-secondary);
}

@media (max-width: 640px) {
  .recipe-reveal-label {
    display: none;
  }
}

.recipe-card-chevron {
  transition: transform 0.2s ease;
}

.recipe-agent-card.is-expanded .recipe-card-chevron {
  transform: rotate(180deg);
}

.recipe-agent-details {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: default;
}

.recipe-plan-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(22, 17, 40, 0.55);
}

.recipe-plan-card.is-selected {
  border-color: rgba(168, 85, 247, 0.4);
  background: rgba(26, 18, 48, 0.55);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.1);
}

.recipe-plan-card.is-review,
.recipe-plan-card.is-warn {
  border-color: rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.03);
}

.recipe-plan-card.is-connect,
.recipe-plan-card.is-action {
  border-color: rgba(56, 189, 248, 0.25);
  background: rgba(56, 189, 248, 0.03);
}

.recipe-plan-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.recipe-plan-card-head strong {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

/* Swarm Document Hero Header */
.recipe-guild-hero {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.recipe-guild-hero-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.recipe-guild-hero-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.recipe-guild-hero-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.25;
}

.recipe-guild-hero-about {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.recipe-guild-hero-meta {
  flex-shrink: 0;
}

.recipe-hero-cap {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-tertiary);
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.recipe-guild-hero-objective {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-top: 2px;
}

.recipe-hero-obj-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-light);
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(168, 85, 247, 0.14);
  flex-shrink: 0;
}

/* Action Summary Bar at top of Blueprint */
.recipe-action-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  margin-bottom: 14px;
  transition: all 0.2s ease;
}

.recipe-action-summary-bar.is-pending {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.recipe-action-summary-bar.is-ready {
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.recipe-summary-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
}

.recipe-action-summary-bar.is-pending .recipe-summary-pill {
  color: #fbbf24;
}

.recipe-action-summary-bar.is-ready .recipe-summary-pill {
  color: #34d399;
}

.recipe-summary-hint {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

/* Agent Header Status */
.recipe-agent-header-status {
  display: flex;
  align-items: center;
}

/* Agent Notice (Contextual Tips/Findings) */
.recipe-agent-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 7px;
  margin-top: 8px;
  font-size: 11.5px;
}

.recipe-agent-notice.is-info,
.recipe-agent-notice.is-warning {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  color: #fde68a;
}

.recipe-agent-notice .notice-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.recipe-agent-notice .notice-text {
  flex: 1;
  line-height: 1.4;
}

/* Sub-card (Browser Login, Scripts, Routines) */
.recipe-agent-subcard {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.recipe-agent-subcard.is-routine {
  padding: 0;
  border-radius: 7px;
  background: rgba(18, 14, 32, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.15s ease;
}

.recipe-agent-subcard.is-routine:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(26, 20, 48, 0.45);
}

.recipe-agent-subcard.is-routine .recipe-routine-row-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  margin-bottom: 0;
  cursor: pointer;
  user-select: none;
}

.recipe-agent-subcard.is-routine .recipe-subcard-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
}

.recipe-agent-subcard.is-routine .recipe-subcard-title strong {
  flex-shrink: 0;
}

.recipe-agent-subcard.is-routine .recipe-routine-cron {
  flex-shrink: 0;
}

.recipe-routine-snippet {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.recipe-agent-subcard.is-routine .recipe-subcard-status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.recipe-routine-chevron {
  color: var(--text-tertiary);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.recipe-agent-subcard.is-routine.is-expanded .recipe-routine-chevron,
.recipe-routine-item.is-expanded .recipe-routine-chevron {
  transform: rotate(180deg);
}

.recipe-agent-subcard.is-routine .recipe-routine-detail {
  padding: 8px 10px 10px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11.5px;
}

.recipe-routine-detail-cadence {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.recipe-routine-detail-cadence strong {
  color: var(--text);
}

.recipe-routine-detail-label {
  color: var(--text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.recipe-agent-subcard.is-pending {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.05);
}

.recipe-operator-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recipe-agent-subcard.recipe-operator-action,
.recipe-agent-subcard.is-browser {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.06);
}

.recipe-operator-lead {
  color: #fde68a;
}

.recipe-subcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.recipe-subcard-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.recipe-subcard-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 8px 0;
}

.recipe-subcard-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Prompt Container */
.recipe-prompt-container {
  margin-top: 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 10px 12px;
}

.recipe-prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.recipe-prompt-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.recipe-prompt-body-wrap {
  position: relative;
}

.recipe-prompt-container .recipe-task {
  margin: 0;
  padding: 10px 52px 10px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #e2e8f0;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.recipe-prompt-editor-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recipe-prompt-editor {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  background: rgba(10, 8, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 10px 12px;
  resize: vertical;
}

.recipe-prompt-editor:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

.recipe-prompt-edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recipe-prompt-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Feedback Tray */
.recipe-feedback-tray {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.25);
  animation: fadeInMsg 0.15s ease;
}

.recipe-feedback-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-light);
  margin-bottom: 6px;
}

.recipe-feedback-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.recipe-feedback-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
}

.recipe-feedback-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Subtle Buttons */
.btn-subtle-sm {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-subtle-sm:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-subtle-xs {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-subtle-xs:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.btn-prompt-confirm {
  background: var(--gradient-primary);
  border: none;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.25);
}

/* Agent Card Identity Header */
.recipe-agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.recipe-agent-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.recipe-agent-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(13, 10, 26, 0.8);
  border: 1px solid rgba(168, 85, 247, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.15);
  overflow: hidden;
}

.recipe-agent-avatar ai-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.recipe-agent-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.recipe-agent-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.recipe-agent-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.recipe-agent-slug {
  font-family: var(--mono);
  color: var(--text-tertiary);
}

.recipe-model-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  font-family: var(--mono);
  font-size: 10.5px;
}

/* Agent Focus: Clean typography, no box inside box */
.recipe-agent-focus {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
}

/* Agent Metric Pills & Detail Popovers */
.recipe-metrics-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 8px;
  flex-wrap: wrap;
}

.recipe-metric-pill-wrap {
  position: relative;
  display: inline-flex;
}

.recipe-metric-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  transition: all 0.15s ease;
  user-select: none;
}

.recipe-metric-pill:hover,
.recipe-metric-pill-wrap.is-open .recipe-metric-pill {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.recipe-metric-pill .metric-icon {
  font-size: 11px;
  line-height: 1;
}

.recipe-metric-pill.is-conn {
  border-color: rgba(34, 211, 238, 0.25);
  color: #38bdf8;
}
.recipe-metric-pill.is-conn:hover,
.recipe-metric-pill-wrap.is-open .recipe-metric-pill.is-conn {
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(34, 211, 238, 0.45);
  color: #7dd3fc;
}

.recipe-metric-pill.is-routine {
  border-color: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}
.recipe-metric-pill.is-routine:hover,
.recipe-metric-pill-wrap.is-open .recipe-metric-pill.is-routine {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fde68a;
}

.recipe-metric-pill.is-tools {
  border-color: rgba(168, 85, 247, 0.25);
  color: #c084fc;
}
.recipe-metric-pill.is-tools:hover,
.recipe-metric-pill-wrap.is-open .recipe-metric-pill.is-tools {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.45);
  color: #e9d5ff;
}

.recipe-metric-pill.is-zero {
  opacity: 0.5;
  border-color: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}
.recipe-metric-pill.is-zero:hover,
.recipe-metric-pill-wrap.is-open .recipe-metric-pill.is-zero {
  opacity: 0.9;
}

.recipe-metric-pill.has-warning {
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.06);
  opacity: 0.95;
}
.recipe-metric-pill.has-warning:hover,
.recipe-metric-pill-wrap.is-open .recipe-metric-pill.has-warning {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.6);
  color: #fde68a;
}

.metric-warning-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fbbf24;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.7);
  flex-shrink: 0;
  display: inline-block;
}

/* Metric Popover (Floating modal card) */
.recipe-metric-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 70;
  width: max-content;
  min-width: 230px;
  max-width: min(340px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 9px;
  background: rgba(16, 12, 26, 0.97);
  border: 1px solid rgba(168, 85, 247, 0.32);
  box-shadow: 0 14px 34px -4px rgba(0, 0, 0, 0.75), 0 0 1px 1px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.recipe-metric-pill-wrap:last-child .recipe-metric-popover {
  right: 0;
  left: auto;
}

@media (hover: hover) {
  .recipe-metric-pill-wrap:hover .recipe-metric-popover {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
}

.recipe-metric-pill-wrap.is-open .recipe-metric-popover {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 7px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11.5px;
  color: var(--text);
}

.popover-badge {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-tertiary);
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
}

.popover-body {
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.popover-notice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 11px;
  line-height: 1.45;
}

.popover-notice.is-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fde68a;
}

.popover-notice-icon {
  font-size: 13px;
  line-height: 1.2;
  flex-shrink: 0;
}

.popover-notice-text {
  flex: 1;
}

.popover-section + .popover-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.popover-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-bottom: 5px;
}

.popover-desc {
  margin: 0;
  font-size: 11px;
  color: var(--text-secondary);
}

.popover-empty {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.popover-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.popover-list li {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 11px;
  padding: 4px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.popover-list li strong {
  color: var(--text);
  font-size: 11px;
}

.popover-list li span {
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--mono);
}

.popover-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.popover-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--mono);
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.2);
  color: #d8b4fe;
}

.popover-chip.is-grant {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

/* Capability Chips: Understated metadata row */
.recipe-chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 8px;
}

.recipe-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-tertiary);
  border: 1px solid rgba(255, 255, 255, 0.06);
  line-height: 1.25;
  white-space: nowrap;
}

.recipe-chip svg {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

.recipe-chip.is-conn,
.recipe-chip.is-action {
  background: rgba(56, 189, 248, 0.08);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.2);
  font-weight: 600;
}

.recipe-chip.is-browser,
.recipe-chip.is-warn {
  background: rgba(251, 191, 36, 0.08);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.2);
  font-weight: 600;
}

.recipe-chip.is-grant {
  background: rgba(52, 211, 153, 0.06);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.16);
}

.recipe-chip.is-native {
  background: rgba(168, 85, 247, 0.06);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.16);
  font-family: var(--mono);
  font-size: 10px;
}

.recipe-chip.is-ok {
  background: rgba(52, 211, 153, 0.08);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.2);
}

.recipe-chip.is-muted {
  background: none;
  color: var(--text-muted);
  border-color: transparent;
  font-style: italic;
  padding: 0;
}

/* Standing Prompt: Sleek, non-boxy accordion */
.recipe-prompt {
  border: none;
  background: none;
  padding: 0;
  margin: 2px 0 0 0;
}

.recipe-prompt summary {
  padding: 2px 0;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  background: none;
  border: none;
  transition: color 0.15s;
}

.recipe-prompt summary:hover {
  color: var(--text-secondary);
  background: none;
}

.recipe-prompt-summary-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.recipe-prompt-badge {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-muted);
  padding: 0;
  background: none;
}

.recipe-task-wrapper {
  position: relative;
  margin-top: 6px;
}

.recipe-task {
  margin: 0;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #e2e8f0;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow-x: auto;
  max-height: 240px;
  white-space: pre-wrap;
  word-break: break-word;
}

.recipe-task-copy-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
}

.recipe-task-copy-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
}

/* Compact Recipe Routine List */
.recipe-routine-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recipe-routine-item {
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 9px;
  background: rgba(18, 14, 32, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.15s ease;
  overflow: hidden;
}

.recipe-routine-item:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(26, 20, 48, 0.55);
}

.recipe-routine-item.is-pending {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.05);
}

.recipe-routine-item.is-pending:hover {
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.08);
}

.recipe-routine-row-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}

.recipe-routine-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.35;
}

.recipe-routine-cadence {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.recipe-routine-icon {
  font-size: 13px;
  line-height: 1;
}

.recipe-routine-cron {
  font-size: 11px;
  font-family: var(--mono);
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.05);
  line-height: 1.4;
  flex-shrink: 0;
}

.recipe-routine-sep {
  color: rgba(255, 255, 255, 0.2);
  font-size: 11px;
  user-select: none;
  flex-shrink: 0;
}

.recipe-routine-target {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  flex-shrink: 0;
}

.recipe-routine-role {
  font-weight: 600;
  color: #c084fc;
}

.recipe-routine-key {
  color: var(--text-secondary);
  font-weight: 500;
}

.recipe-routine-inline-desc {
  color: var(--text-secondary);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.recipe-routine-meta {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.recipe-routine-detail {
  padding: 8px 12px 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.15);
}

.recipe-routine-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
}

/* Compact Recipe Connector List */
.recipe-connector-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recipe-connector-item {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 9px;
  background: rgba(18, 14, 32, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.15s ease;
  overflow: hidden;
}

.recipe-connector-item:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(26, 20, 48, 0.55);
}

.recipe-connector-item.is-warn {
  border-color: rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.03);
}

.recipe-connector-item.is-connect {
  border-color: rgba(56, 189, 248, 0.25);
  background: rgba(56, 189, 248, 0.03);
}

.recipe-connector-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}

.recipe-connector-summary-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
}

.recipe-connector-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}

.recipe-connector-snippet {
  font-size: 11.5px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.recipe-connector-summary-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.recipe-connector-chevron {
  color: var(--text-tertiary);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.recipe-connector-item.is-expanded .recipe-connector-chevron {
  transform: rotate(180deg);
}

.recipe-connector-detail {
  padding: 10px 14px 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.15);
  cursor: default;
}

.recipe-collection-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recipe-collection-item .recipe-connector-icon.is-collection {
  font-size: 14px;
  line-height: 1;
}

.recipe-collection-detail {
  padding: 8px 12px 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.15);
  cursor: default;
}

.recipe-note-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recipe-note-item .recipe-connector-icon.is-note {
  font-size: 14px;
  line-height: 1;
}

.recipe-note-detail {
  padding: 8px 12px 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.15);
  cursor: default;
}

.recipe-note-body {
  margin: 8px 0 0;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: #e2e8f0;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.recipe-note-empty {
  font-size: 12.5px;
  color: var(--text-tertiary);
  line-height: 1.45;
  margin: 8px 0 0;
}

.recipe-connector-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.recipe-connector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  line-height: 1.35;
}

.recipe-connector-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.recipe-connector-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  flex-shrink: 0;
  line-height: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-sizing: border-box;
  font-size: 11px;
}

.recipe-connector-icon svg {
  display: block;
  max-width: 14px;
  max-height: 14px;
  flex-shrink: 0;
}

.recipe-connector-icon.is-secret {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.28);
}

.recipe-connector-icon.is-system {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.popover-connector-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.popover-connector-icon {
  width: 18px !important;
  height: 18px !important;
  border-radius: 4px !important;
}

.popover-connector-icon svg {
  max-width: 12px !important;
  max-height: 12px !important;
}

.recipe-connector-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.recipe-connector-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.recipe-connector-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
  overflow-wrap: anywhere;
}

.recipe-connector-meta {
  font-size: 11.5px;
  color: var(--text-tertiary, #94a3b8);
  line-height: 1.35;
  margin: 0;
  overflow-wrap: anywhere;
}

.recipe-section-action-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.recipe-access-pending {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.22);
  border-radius: 8px;
}

.recipe-connection-tools {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.recipe-connection-tool-role {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.recipe-connection-tool-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recipe-connection-tool {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12px;
  color: var(--text-secondary);
}

.recipe-connection-tool.is-removed {
  opacity: 0.55;
  text-decoration: line-through;
}

.recipe-connection-tool input {
  margin: 0;
}

.recipe-connection-tool-name {
  font-family: var(--mono);
  font-size: 12px;
}

.recipe-connection-remove {
  margin-top: 10px;
}

/* Mini Lists (Routines, Access, Notes) */
.recipe-mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.recipe-mini-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.recipe-mini-list li strong {
  color: var(--text);
  flex-shrink: 0;
}

.recipe-mini-list li span {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.recipe-handoff-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recipe-handoff-nodes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 4px;
  padding: 12px 10px 10px;
  border-radius: 12px;
  background: rgba(18, 14, 32, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.recipe-handoff-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 72px;
  padding: 0 8px;
  position: relative;
}

.recipe-handoff-node + .recipe-handoff-node::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 18px;
  width: 12px;
  height: 0;
  border-top: 1px dashed rgba(168, 85, 247, 0.35);
}

.recipe-handoff-node span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-handoff-flows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recipe-handoff-row {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) minmax(110px, 1.3fr) minmax(92px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(18, 14, 32, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.recipe-handoff-actor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  min-width: 0;
}

.recipe-handoff-avatar {
  display: inline-flex;
}

.recipe-handoff-actor-name {
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-handoff-actor-role {
  font-size: 10.5px;
  color: var(--text-tertiary);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-handoff-edge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.recipe-handoff-vias {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.recipe-handoff-via {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-handoff-via.is-collection {
  color: #e9d5ff;
  background: rgba(168, 85, 247, 0.16);
  border: 1px solid rgba(192, 132, 252, 0.28);
}

.recipe-handoff-via.is-tagged {
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
}

.recipe-handoff-arrow {
  display: flex;
  align-items: center;
  width: 100%;
  color: rgba(192, 132, 252, 0.7);
}

.recipe-handoff-arrow-line {
  flex: 1;
  height: 0;
  border-top: 1px solid rgba(192, 132, 252, 0.35);
}

.recipe-handoff-arrow svg {
  flex-shrink: 0;
  margin-left: -2px;
}

@media (max-width: 640px) {
  .recipe-handoff-row {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 6px;
  }

  .recipe-handoff-arrow {
    max-width: 160px;
    transform: rotate(90deg);
  }
}

.recipe-review {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
}

.recipe-review.is-open {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.recipe-review.is-ok {
  background: rgba(52, 211, 153, 0.12);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.recipe-guild-card {
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(13, 10, 26, 0.65);
  backdrop-filter: blur(16px);
  position: relative;
  overflow: hidden;
}

.recipe-guild-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
}

.recipe-guild-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.recipe-guild-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-light);
}

.recipe-guild-cap {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-tertiary);
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.recipe-guild-details {
  display: grid;
  gap: 8px;
}

.recipe-guild-row {
  display: grid;
  grid-template-columns: 85px 1fr;
  gap: 10px;
  font-size: 13px;
  align-items: baseline;
}

.recipe-guild-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.recipe-guild-val {
  color: var(--text);
  overflow-wrap: anywhere;
}

.recipe-empty-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.07);
}

.recipe-empty-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.recipe-empty-text {
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
}

/* Chat & Real-Time Streaming */
.builder-chat-header {
  padding: 10px 16px;
}

.builder-coach-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--gradient-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.3);
  flex-shrink: 0;
}

.builder-coach-sub {
  margin: 0;
  font-size: 11px;
  color: var(--text-tertiary);
}

.builder-coach-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.builder-coach-status.is-generating {
  color: var(--accent-light);
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.3);
}

.builder-coach-status.is-waiting {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.3);
}


.builder-chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.builder-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 92%;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.5;
  animation: fadeInMsg 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.builder-msg.is-user {
  align-self: flex-end;
  background: var(--gradient-user-msg);
  border: 1px solid rgba(168, 85, 247, 0.25);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.builder-msg.is-assistant {
  align-self: flex-start;
  background: rgba(13, 10, 26, 0.75);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text-secondary);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.builder-msg.is-streaming {
  border-color: rgba(168, 85, 247, 0.45);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.15);
}

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

.builder-msg-author-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.builder-msg-avatar {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.builder-msg-avatar.is-assistant {
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-light);
}

.builder-msg-avatar.is-user {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.builder-msg-role {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

.builder-msg.is-user .builder-msg-role {
  color: #e2e8f0;
}

.builder-msg-seq {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-muted);
}


.builder-msg-body {
  overflow-wrap: anywhere;
}

.builder-msg-body p {
  margin: 0 0 8px;
}

.builder-msg-body p:last-child {
  margin-bottom: 0;
}

.builder-connect-widget {
  align-self: stretch;
  max-width: 100%;
  margin: 2px 0 4px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(168, 85, 247, 0.28);
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.1), rgba(13, 10, 26, 0.78));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.builder-connect-widget.is-connected {
  border-color: rgba(52, 211, 153, 0.35);
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.08), rgba(13, 10, 26, 0.78));
}

.builder-connect-kicker {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 2px;
}

.builder-connect-title {
  display: block;
  font-size: 14px;
  color: var(--text);
}

.builder-connect-reason,
.builder-connect-storage {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.builder-connect-storage {
  color: var(--text-muted);
}

.builder-connect-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.builder-connect-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.builder-connect-field strong {
  color: var(--text);
  font-size: 13px;
}

.builder-connect-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.builder-connect-status.is-ok {
  color: #6ee7b7;
}

.builder-connect-status.is-error {
  color: #fca5a5;
}

.builder-connect-status.is-later {
  color: var(--text-muted);
}

.builder-connect-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.builder-connect-form-mount .apply-connect-form,
.builder-connect-form-mount .mcp-token-form {
  margin-top: 4px;
}

.recipe-connection-resources {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-secondary);
}

@media (max-width: 720px) {
  .builder-connect-fields {
    grid-template-columns: 1fr;
  }
}

.builder-question-widget {
  align-self: stretch;
  max-width: 100%;
  margin: 2px 0 4px;
  padding: 14px 16px 12px;
  border-radius: 14px;
  border: 1px solid rgba(251, 191, 36, 0.32);
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.1), rgba(13, 10, 26, 0.82));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.builder-question-widget.is-resolved {
  border-color: rgba(52, 211, 153, 0.3);
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.08), rgba(13, 10, 26, 0.78));
  opacity: 0.88;
}

.builder-question-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fde68a;
}

.builder-question-widget.is-resolved .builder-question-kicker {
  color: #6ee7b7;
}

.builder-question-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.builder-question-header {
  display: inline-flex;
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.22);
  font-size: 11px;
  font-weight: 600;
  color: #fde68a;
}

.builder-question-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}

.builder-question-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.builder-question-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(13, 10, 26, 0.72);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.builder-question-option:hover:not(:disabled) {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}

.builder-question-option.is-selected,
.builder-question-option.is-focused {
  border-color: rgba(251, 191, 36, 0.55);
  background: rgba(251, 191, 36, 0.14);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.18);
}

.builder-question-option:disabled {
  cursor: default;
  opacity: 0.75;
}

.builder-question-letter {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.28);
}

.builder-question-option.is-selected .builder-question-letter {
  color: #0d0a1a;
  background: #fbbf24;
  border-color: #fbbf24;
}

.builder-question-option-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.builder-question-option-body strong {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}

.builder-question-option-hint {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.builder-question-other-input {
  width: 100%;
  margin-top: 4px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(7, 6, 14, 0.7);
  color: var(--text);
  font-size: 13px;
}

.builder-question-other-input:focus {
  outline: none;
  border-color: rgba(251, 191, 36, 0.5);
}

.builder-question-actions {
  display: flex;
  justify-content: flex-end;
}

.builder-pending-slot {
  flex-shrink: 0;
  max-height: 46%;
  overflow-y: auto;
  padding: 10px 16px 12px;
  border-top: 1px solid rgba(251, 191, 36, 0.18);
  background: rgba(251, 191, 36, 0.04);
}

.builder-pending-slot .builder-question-widget {
  margin: 0;
}

.builder-pending-questions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px 12px;
}

.builder-pending-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fde68a;
}

.builder-pending-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(13, 10, 26, 0.7);
  border: 1px solid rgba(251, 191, 36, 0.22);
}

.builder-pending-card strong {
  font-size: 13px;
  color: var(--text);
}

.builder-pending-card p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.builder-chat-form {
  padding: 12px 16px 16px;
  background: rgba(7, 6, 14, 0.5);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.builder-composer-wrap {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(13, 10, 26, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 10px 12px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.builder-composer-wrap:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.builder-composer-wrap textarea {
  width: 100%;
  min-height: 148px;
  max-height: 45vh;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  resize: vertical;
  line-height: 1.45;
  padding: 0 0 4px;
  overflow-y: auto;
}

.builder-composer-wrap textarea:focus {
  outline: none;
}

.builder-chat-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.builder-send-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12.5px;
}

/* Builder Landing */
.builder-landing {
  padding: 24px 32px 40px;
  overflow-y: auto;
}

.builder-landing-header {
  margin-bottom: 24px;
}

.builder-create-card {
  border: 1px solid var(--border-light);
  border-radius: 18px;
  background: rgba(13, 10, 26, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 26px 30px;
  margin-bottom: 32px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

.builder-create-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
}

.builder-create-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.builder-icon-sparkle {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--gradient-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px rgba(168, 85, 247, 0.35);
  flex-shrink: 0;
}

.builder-card-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.builder-card-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.builder-start-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.builder-field-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.builder-start-actions {
  display: flex;
  justify-content: flex-end;
}

.builder-start-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 13.5px;
}

.builder-recent-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.builder-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.builder-section-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.builder-count-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.builder-drafts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.builder-draft-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(13, 10, 26, 0.5);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.builder-draft-card:hover {
  border-color: rgba(168, 85, 247, 0.45);
  background: rgba(20, 15, 40, 0.65);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.builder-draft-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.builder-draft-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.25);
  color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.builder-draft-status {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.builder-draft-status.is-draft {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
}

.builder-draft-status.is-ready {
  background: rgba(52, 211, 153, 0.14);
  color: #34d399;
}

.builder-draft-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  display: block;
}

.builder-draft-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ==========================================================================
   RECIPE LIBRARY & BLUEPRINTS
   ========================================================================== */
.recipe-library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.recipe-library-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.recipe-import-label,
.recipe-capture-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px 14px;
}

.recipe-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.capture-guild-body {
  min-height: 80px;
}

.capture-guild-loading,
.capture-guild-body .builder-empty-desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.capture-guild-list {
  display: grid;
  gap: 8px;
  max-height: min(360px, 50vh);
  overflow-y: auto;
}

.capture-guild-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(13, 10, 26, 0.45);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.capture-guild-item:hover:not(:disabled) {
  border-color: rgba(168, 85, 247, 0.45);
  background: rgba(20, 15, 40, 0.65);
}

.capture-guild-item strong {
  font-size: 14px;
}

.capture-guild-item span {
  font-size: 12px;
  color: var(--text-tertiary);
}

.capture-guild-item:disabled {
  opacity: 0.7;
  cursor: wait;
}

.recipe-export:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.recipe-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 20px 0;
}

.recipe-library-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(13, 10, 26, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.recipe-library-card:hover {
  border-color: rgba(168, 85, 247, 0.45);
  background: rgba(20, 15, 40, 0.65);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.recipe-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.recipe-card-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.25);
  color: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.recipe-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.recipe-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  display: block;
}

.recipe-card-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recipe-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.recipe-card-action {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-light);
}

.apply-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 20px 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(168, 85, 247, 0.12);
}

.apply-preview,
.apply-checklist {
  display: grid;
  gap: 16px;
}

.apply-inventory h3,
.apply-connection strong {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #9aa3b2);
}

.apply-inventory ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.apply-inventory li,
.apply-connection {
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.apply-inventory li p,
.apply-connection p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted, #9aa3b2);
}

.apply-inventory .recipe-task {
  margin-top: 8px;
}

.apply-guild-name,
.apply-connection label,
.apply-inventory li label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.apply-inventory li label {
  margin-top: 8px;
}

.apply-collision {
  color: #f87171;
}

.apply-created-summary {
  margin: 0;
  font-size: 13px;
  color: var(--muted, #9aa3b2);
}

.apply-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.apply-step .apply-step-actions {
  margin-top: 0;
  flex-shrink: 0;
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.apply-step .apply-connect-form,
.apply-step .mcp-token-form {
  grid-column: 1 / -1;
  margin: 4px 0 0;
}

.apply-step-actions a.btn-primary-sm,
.apply-step-actions a.btn-cancel-sm {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.apply-step-status {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted, #9aa3b2);
}

.apply-step-note {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted, #9aa3b2);
}

.apply-step-hint {
  margin: 6px 0 0;
  font-size: 13px;
  color: #f87171;
}

.apply-step.is-verified,
.apply-step.is-confirmed {
  opacity: 1;
}

.apply-step.is-skipped {
  opacity: 1;
}

.apply-validated,
.apply-hero,
.apply-skip-banner,
.apply-skip-warn {
  border-radius: 14px;
}

.apply-validated {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--success-soft);
  border: 1px solid rgba(52, 211, 153, 0.28);
}

.apply-validated.is-blocked {
  background: var(--danger-bg);
  border-color: rgba(248, 113, 113, 0.35);
}

.apply-step-copy {
  min-width: 0;
}

.apply-validated strong,
.apply-hero-copy strong,
.apply-step-copy strong {
  display: block;
  font-size: 15px;
  color: var(--text);
}

.apply-validated p,
.apply-hero-copy p,
.apply-step-copy p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.apply-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "check copy"
    "bar bar";
  align-items: center;
  gap: 8px 16px;
  padding: 18px 20px 16px;
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.12), rgba(168, 85, 247, 0.08));
  border: 1px solid rgba(52, 211, 153, 0.22);
}

.apply-hero-check {
  grid-area: check;
}

.apply-hero-copy {
  grid-area: copy;
}

.apply-hero-copy strong {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.apply-progress-track {
  grid-area: bar;
  height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.apply-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #34d399, #a855f7);
  box-shadow: 0 0 16px rgba(52, 211, 153, 0.45);
  transition: width 0.45s ease;
}

.apply-celebrate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 100%;
  padding: 48px 24px;
  text-align: center;
}

.apply-celebrate h2 {
  margin: 8px 0 0;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.apply-celebrate p {
  margin: 0;
  color: var(--text-secondary);
}

.apply-celebrate-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
  min-width: min(360px, 100%);
  text-align: left;
}

.apply-celebrate-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

.apply-celebrate-list li.is-done {
  color: var(--text);
  background: var(--success-soft);
}

.apply-celebrate-list li.is-next {
  border: 1px dashed rgba(168, 85, 247, 0.35);
}

.apply-pip-check,
.apply-pip-dot,
.apply-celebrate-check,
.apply-hero-check,
.apply-step-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.apply-pip-dot {
  width: 28px;
  height: 28px;
}

.apply-pip-dot::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-light);
  box-shadow: 0 0 10px var(--accent);
}

.apply-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
}

.apply-step.is-open {
  border-color: rgba(168, 85, 247, 0.18);
}

.apply-step.is-activate.is-open {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.28);
}

.apply-step.is-verified,
.apply-step.is-confirmed,
.apply-milestone {
  background: rgba(52, 211, 153, 0.08);
  border-color: rgba(52, 211, 153, 0.18);
}

.apply-step.is-skipped {
  background: var(--warning-soft);
  border-color: rgba(251, 191, 36, 0.28);
}

.apply-step-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.apply-step-mark.is-open {
  border-color: rgba(168, 85, 247, 0.45);
}

.apply-step-mark.is-checked,
.apply-step-mark.is-confirmed,
.apply-hero-check,
.apply-celebrate-check,
.apply-pip-check {
  width: 44px;
  height: 44px;
  border: 0;
  background: rgba(52, 211, 153, 0.16);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.35), 0 0 22px rgba(52, 211, 153, 0.25);
}

.apply-pip-check {
  width: 28px;
  height: 28px;
}

.apply-step-mark.is-skipped {
  border: 0;
  background: rgba(251, 191, 36, 0.16);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.4);
}

.apply-step-mark.is-blocked {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(248, 113, 113, 0.12);
}

.apply-check-svg {
  width: 100%;
  height: 100%;
}

.apply-check-ring {
  stroke: var(--success);
  stroke-width: 3;
  stroke-dasharray: 140;
  stroke-dashoffset: 140;
}

.apply-check-mark {
  stroke: var(--success);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 36;
  stroke-dashoffset: 36;
}

.apply-step-mark.is-skipped .apply-check-ring,
.apply-step-mark.is-skipped .apply-check-mark {
  stroke: var(--warning);
}

.apply-step.is-pop .apply-check-ring,
.apply-hero-check.is-pop .apply-check-ring,
.apply-celebrate-check.is-pop .apply-check-ring,
.apply-validated .apply-check-ring,
.apply-milestone .apply-check-ring,
.apply-step.is-verified .apply-check-ring,
.apply-step.is-confirmed .apply-check-ring,
.apply-step.is-skipped .apply-check-ring,
.apply-celebrate-list .apply-check-ring {
  animation: applyRingDraw 0.45s ease forwards;
}

.apply-step.is-pop .apply-check-mark,
.apply-hero-check.is-pop .apply-check-mark,
.apply-celebrate-check.is-pop .apply-check-mark,
.apply-validated .apply-check-mark,
.apply-milestone .apply-check-mark,
.apply-step.is-verified .apply-check-mark,
.apply-step.is-confirmed .apply-check-mark,
.apply-step.is-skipped .apply-check-mark,
.apply-celebrate-list .apply-check-mark {
  animation: applyMarkDraw 0.35s 0.28s ease forwards;
}

.apply-hero-check.is-pending {
  background: rgba(168, 85, 247, 0.14);
  box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.35), 0 0 22px rgba(168, 85, 247, 0.2);
  color: var(--accent-light);
  font-size: 16px;
  font-weight: 700;
}

.apply-celebrate-check,
.apply-hero-check {
  width: 72px;
  height: 72px;
  border-radius: 50%;
}

.apply-step.is-pop,
.apply-celebrate-check.is-pop,
.apply-hero-check.is-pop {
  animation: applyCheckPop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.apply-skip-banner {
  padding: 12px 14px;
  background: var(--warning-soft);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: var(--text);
}

.apply-skip-banner p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.apply-skip-warn {
  grid-column: 1 / -1;
  padding: 12px 14px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.28);
}

.apply-skip-warn p {
  margin: 4px 0 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.apply-skip-warn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@keyframes applyRingDraw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes applyMarkDraw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes applyCheckPop {
  0% {
    transform: scale(0.72);
  }
  60% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

.admin-access-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 18px;
}

.admin-access-form .admin-mcp-field {
  min-width: 220px;
  flex: 1;
}

@media (max-width: 960px) {
  .builder-grid {
    grid-template-columns: 1fr;
  }
}




