/**
 * Istakoza Swarm — Grok Bot Obsidian Design System
 * High-End 3-Tier Multi-Agent Workspace (Chat + Live Stage + Takeover)
 * Owner: retr0 (Abdelrahman El-Haraki, Madinaty, Cairo)
 * Platform: Istakoza.com by AINET.Solutions
 */

:root {
  --bg-obsidian: #000000;
  --bg-sidebar: #05070a;
  --bg-card: #090c12;
  --bg-card-hover: #101520;
  --bg-card-elevated: #131926;
  --bg-input: #0b0f17;

  --border-hairline: rgba(255, 255, 255, 0.07);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-hover: rgba(255, 255, 255, 0.20);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-ghost: #475569;

  --accent-grok: #00E599;
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-crimson: #f43f5e;
  --accent-purple: #a855f7;
  --accent-blue: #3b82f6;

  --font-sans: 'Plus Jakarta Sans', 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Space Mono', Consolas, monospace;
  --font-arabic: 'Zain', var(--font-sans);

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-obsidian: 0 12px 40px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 20px rgba(0, 229, 153, 0.18);
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-obsidian);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   3-TIER APPLICATION LAYOUT
   ========================================================================== */
#app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background: var(--bg-obsidian);
}

/* ==========================================================================
   TIER 1: LEFT SIDEBAR (COLLAPSIBLE PINNED 8 + ACTIVE CHATS)
   ========================================================================== */
#sidebar {
  width: 270px;
  min-width: 270px;
  height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1), min-width 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

#sidebar.collapsed {
  width: 68px;
  min-width: 68px;
}

#sidebar.collapsed .brand-text-group,
#sidebar.collapsed .sidebar-search,
#sidebar.collapsed .sidebar-section-header,
#sidebar.collapsed .pinned-card-text,
#sidebar.collapsed .nav-item-text,
#sidebar.collapsed .nav-item-badge,
#sidebar.collapsed .operator-details,
#sidebar.collapsed #btn-open-brand-modal {
  display: none !important;
}

#sidebar.collapsed .sidebar-pinned-grid {
  grid-template-columns: 1fr;
  padding: 6px 0;
}

#sidebar.collapsed .pinned-card {
  justify-content: center;
  padding: 6px 0;
}

#sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 8px 0;
}

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

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.brand-glyph {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(0, 229, 153, 0.12);
  border: 1px solid rgba(0, 229, 153, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 0 14px rgba(0, 229, 153, 0.2);
  flex-shrink: 0;
}

.brand-text-group {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.brand-badge {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--accent-grok);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-family: var(--font-mono);
}

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

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

.btn-sidebar-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: var(--border-subtle);
}

/* Sidebar Search */
.sidebar-search {
  padding: 10px 12px 6px;
}

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

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

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 6px 10px 6px 30px;
  font-size: 11.5px;
  color: var(--text-primary);
  outline: none;
  font-family: var(--font-sans);
  transition: border-color 0.15s ease;
}

.search-input:focus {
  border-color: var(--accent-grok);
  background: #0d121c;
}

/* Navigation Lists */
.sidebar-nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 16px;
}

.sidebar-nav-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px 4px;
  user-select: none;
}

.section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.badge-count {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}

.btn-section-plus {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}

.btn-section-plus:hover {
  color: #fff;
}

/* --- 2-Column Pinned Agents Grid --- */
.sidebar-pinned-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 2px 2px 8px;
}

.pinned-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  min-width: 0;
}

.pinned-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-subtle);
  transform: translateY(-1px);
}

.pinned-card.active {
  background: rgba(0, 229, 153, 0.08);
  border-color: rgba(0, 229, 153, 0.4);
}

.pinned-avatar-wrap {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.pinned-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.status-dot-ring {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--bg-sidebar);
  background: #10b981;
}

.status-dot-ring.busy { background: #f59e0b; }
.status-dot-ring.idle { background: #3b82f6; }

.pinned-card-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.pinned-card-name {
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-card-sub {
  font-size: 9.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Active Chats List --- */
.sidebar-active-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  user-select: none;
}

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

.nav-item.active {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
}

.nav-item-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.nav-item-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.nav-item-icon-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 229, 153, 0.15);
  border: 1px solid rgba(0, 229, 153, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-grok);
  flex-shrink: 0;
}

.nav-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.nav-item-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item-badge {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

/* Sidebar Footer: Operator Info */
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-hairline);
  background: rgba(0, 0, 0, 0.4);
}

.operator-profile-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.operator-profile-bar:hover {
  background: rgba(255, 255, 255, 0.05);
}

.operator-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.operator-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.operator-name {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.operator-handle {
  font-size: 10px;
  color: var(--text-muted);
}

.btn-settings-gear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.btn-settings-gear:hover { color: #fff; }

/* ==========================================================================
   TIER 2: CENTER STREAM (GROK OBSIDIAN CONVERSATION)
   ========================================================================== */
#main-chat {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-obsidian);
  position: relative;
  min-width: 0;
}

.chat-topbar {
  height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.chat-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-header-avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-header-avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-title-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.2px;
}

.chat-header-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
}

.chat-header-topic {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.btn-topbar-pill:hover, .btn-topbar-pill.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-subtle);
  color: #fff;
}

.btn-topbar-icon {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-topbar-icon:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-hairline);
  color: #fff;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

/* Message Rows */
.chat-message-row {
  display: flex;
  flex-direction: column;
  max-width: 820px;
  width: 100%;
}

.chat-message-row.user {
  align-self: flex-end;
  max-width: 720px;
}

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

.msg-sender-avatar-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.msg-sender-avatar-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-sender-name {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

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

.msg-timestamp {
  font-size: 10px;
  color: var(--text-ghost);
  margin-left: auto;
}

.msg-bubble {
  background: #0d0f14;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-primary);
  position: relative;
}

.chat-message-row.user .msg-bubble {
  background: #171b24;
  border-color: rgba(255, 255, 255, 0.1);
  border-bottom-right-radius: 4px;
}

/* In-Stream Inter-Bot Coordination Pill */
.inter-bot-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #090c12;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 11px;
  color: var(--text-secondary);
  margin: 6px 0;
  user-select: none;
}

.inter-bot-pill .bot-avatar-icons {
  display: flex;
  align-items: center;
  margin-right: 2px;
}

.inter-bot-pill .bot-avatar-icons img {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin-right: -4px;
  border: 1px solid #000;
}

/* Rich @ Mention Pill in Chat */
.chat-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  background: #131720;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  vertical-align: middle;
}

.chat-tag-pill img {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

/* Multi-Image Gallery Grid (+N) */
.image-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
  max-width: 600px;
}

.gallery-thumb-wrap {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  background: #05070a;
}

.gallery-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-plus-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

/* Interactive Option Picker Cards */
.choice-card-container {
  background: #080b11;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 520px;
}

.choice-card-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.choice-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s ease;
  text-align: left;
}

.choice-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--border-subtle);
}

.choice-btn.selected {
  background: rgba(0, 229, 153, 0.12);
  border-color: rgba(0, 229, 153, 0.4);
  color: #fff;
}

.choice-letter-badge {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
}

.choice-btn.selected .choice-letter-badge {
  background: var(--accent-grok);
  color: #000;
}

.btn-choice-done {
  align-self: flex-end;
  background: #fff;
  color: #000;
  border: none;
  font-weight: 700;
  font-size: 11px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  margin-top: 4px;
}

/* Native Floating Emoji Reactions */
.emoji-reaction-pill {
  position: absolute;
  top: -10px;
  right: 12px;
  background: #11141c;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  padding: 1px 6px;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  cursor: pointer;
}

/* Floating Capsule Composer */
.composer-container {
  padding: 8px 24px 16px;
  position: relative;
}

.composer-capsule {
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-obsidian);
  transition: border-color 0.15s ease;
}

.composer-capsule:focus-within {
  border-color: rgba(255, 255, 255, 0.25);
}

.composer-left-actions, .composer-right-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-composer-tool {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-composer-tool:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.btn-composer-tag {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-composer-tag:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.composer-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  max-height: 160px;
}

.btn-composer-send {
  background: #ffffff;
  border: none;
  color: #000000;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.btn-composer-send:hover {
  transform: scale(1.05);
  background: #f1f5f9;
}

.composer-footnote {
  text-align: center;
  font-size: 10.5px;
  color: var(--text-ghost);
  margin-top: 6px;
}

/* ==========================================================================
   TIER 3: RIGHT INSPECTOR PANEL (DETAILS | LIBRARY | CHIBI LOBSTER 🦞)
   ========================================================================== */
.stage-panel {
  width: 320px;
  min-width: 320px;
  height: 100%;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 30;
}

.stage-panel.hidden {
  display: none;
}

.stage-panel.takeover-mode {
  position: fixed;
  inset: 0;
  width: 100vw !important;
  min-width: 100vw !important;
  height: 100vh !important;
  z-index: 1000;
}

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

.inspector-agent-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.inspector-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.inspector-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.inspector-title-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.inspector-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inspector-name-row h3 {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
}

.btn-edit-agent-pencil {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
}

.btn-edit-agent-pencil:hover { color: #fff; }

.inspector-badge {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-stage-tool {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-stage-tool:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }

/* Inspector Tabs Bar */
.inspector-tabs-bar {
  display: flex;
  padding: 0 14px;
  border-bottom: 1px solid var(--border-hairline);
  gap: 14px;
}

.inspector-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 2px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.inspector-tab-btn.active {
  color: #fff;
  border-bottom-color: var(--accent-grok);
}

.stage-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.stage-view-content {
  display: none;
  flex: 1;
  flex-direction: column;
}

.stage-view-content.active {
  display: flex;
}

/* Details Tab: Routines */
.details-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.details-section-header span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.btn-primary-micro {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-hairline);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.routines-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.routine-toggle-card {
  padding: 8px 10px;
  background: #090c12;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.routine-toggle-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.routine-toggle-sub {
  font-size: 10px;
  color: var(--text-muted);
}

/* iOS Style Switch */
.ios-switch {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 16px;
  flex-shrink: 0;
}

.ios-switch input { opacity: 0; width: 0; height: 0; }

.ios-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  transition: 0.2s ease;
}

.ios-slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: 0.2s ease;
}

input:checked + .ios-slider { background: #3b82f6; }
input:checked + .ios-slider:before { transform: translateX(12px); }

/* Skills Chips */
.skills-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.skill-pill {
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
}

.btn-outline-wide {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline-wide:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Library Tab */
.library-group-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-family: var(--font-mono);
  display: block;
  margin-bottom: 6px;
}

.library-files-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.library-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
}

.library-file-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-hairline);
}

.library-file-icon { font-size: 13px; }
.library-file-name { font-size: 11.5px; color: var(--text-primary); }

/* Chibi Lobster 🦞 Mascot Header */
.lobster-stage-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.chibi-lobster-mascot {
  font-size: 26px;
  animation: bounceLobster 2s infinite ease-in-out;
}

@keyframes bounceLobster {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px) rotate(4deg); }
}

.lobster-stage-title {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.lobster-stage-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.stage-sandbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: #090c12;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-xs);
  margin-bottom: 8px;
}

.sandbox-url-pill {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.stage-sandbox-tool {
  background: transparent;
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.stage-frame-container {
  flex: 1;
  background: #000;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-height: 240px;
}

.stage-frame-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Modals */
.grok-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #090c12;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
  color: var(--text-primary);
  width: 90%;
  max-width: 480px;
  padding: 0;
  z-index: 1000;
  outline: none;
}

.grok-modal::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

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

.modal-title { font-size: 14px; font-weight: 700; color: #fff; }
.btn-modal-close { background: transparent; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; max-height: 70vh; overflow-y: auto; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.form-input, .form-select, .form-textarea { background: #030508; border: 1px solid var(--border-hairline); border-radius: var(--radius-sm); padding: 8px 10px; color: #fff; font-size: 12.5px; font-family: var(--font-sans); outline: none; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent-grok); }
.modal-footer { padding: 12px 18px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border-hairline); background: rgba(0, 0, 0, 0.25); }
.btn-ghost { background: transparent; border: 1px solid var(--border-hairline); color: var(--text-secondary); padding: 6px 14px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; }
.btn-primary { background: var(--accent-grok); color: #000; border: none; font-weight: 700; padding: 7px 16px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; }

@media (max-width: 900px) {
  .stage-panel { display: none; }
  .only-mobile { display: flex; }
}
