/* ==========================================================================
   EuropaFreelancer Orchestrator - Staging Console Prototype V2 (Updated)
   Mission Control Premium & Conversational Experience Design System
   ========================================================================== */

:root {
  /* Premium Dark Mode Palette (Default - Blue Ink & Warm Slate) */
  --bg-app: #050a14;
  --bg-sidebar: #09101f;
  --bg-card: #0e172a;
  --bg-card-hover: #14213d;
  --bg-card-active: #1a2a4c;
  --bg-header: rgba(9, 16, 31, 0.88);
  --bg-subtle: #121d36;
  --bg-terminal: #03060c;

  --border-color: rgba(255, 255, 255, 0.09);
  --border-color-strong: rgba(255, 255, 255, 0.18);
  --border-focus: #38bdf8;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #020617;

  /* Accent Colors */
  --accent-primary: #38bdf8;
  --accent-primary-hover: #0284c7;
  --accent-indigo: #6366f1;
  --accent-glow: rgba(56, 189, 248, 0.2);

  /* Status Colors (Icon + Text + Color Rule & Valid CSS Fix) */
  --status-verified-bg: rgba(16, 185, 129, 0.14);
  --status-verified-border: rgba(16, 185, 129, 0.35);
  --status-verified-text: #34d399;
  --status-verified-icon: #10b981;

  --status-partial-bg: rgba(245, 158, 11, 0.14);
  --status-partial-border: rgba(245, 158, 11, 0.35);
  --status-partial-text: #fbbf24;
  --status-partial-icon: #f59e0b;

  --status-blocked-bg: rgba(239, 68, 68, 0.14);
  --status-blocked-border: rgba(239, 68, 68, 0.35);
  --status-blocked-text: #f87171;
  --status-blocked-icon: #ef4444;

  --status-quarantined-bg: rgba(168, 85, 247, 0.14);
  --status-quarantined-border: rgba(168, 85, 247, 0.35);
  --status-quarantined-text: #c084fc;
  --status-quarantined-icon: #a855f7;

  --status-demo-bg: rgba(6, 182, 212, 0.14);
  --status-demo-border: rgba(6, 182, 212, 0.35);
  --status-demo-text: #22d3ee;
  --status-demo-icon: #06b6d4;

  /* Typography Stack - Expressive Local Fonts Only */
  --font-sans: "Aptos Display", "Segoe UI Variable Display", "Bahnschrift", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

  /* Spacing & Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Light Theme Overrides */
[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-card-active: #e2e8f0;
  --bg-header: rgba(255, 255, 255, 0.92);
  --bg-subtle: #f1f5f9;
  --bg-terminal: #0f172a;

  --border-color: #e2e8f0;
  --border-color-strong: #cbd5e1;
  --border-focus: #0284c7;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --status-verified-bg: #ecfdf5;
  --status-verified-border: #a7f3d0;
  --status-verified-text: #047857;

  --status-partial-bg: #fffbeb;
  --status-partial-border: #fde68a;
  --status-partial-text: #b45309;

  --status-blocked-bg: #fef2f2;
  --status-blocked-border: #fecaca;
  --status-blocked-text: #b91c1c;

  --status-quarantined-bg: #faf5ff;
  --status-quarantined-border: #e9d5ff;
  --status-quarantined-text: #6b21a8;

  --status-demo-bg: #ecfeff;
  --status-demo-border: #a5f3fc;
  --status-demo-text: #0e7490;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.12);
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.55;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Accessible Focus Ring */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  transform: translateY(-200%);
  background: var(--bg-card);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-weight: 700;
  padding: 0.6rem 0.8rem;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Top Fixed Banner */
.banner-top-demo {
  background: var(--status-demo-bg);
  border-bottom: 1px solid var(--status-demo-border);
  color: var(--status-demo-text);
  padding: 0.5rem 1.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
}

.banner-top-demo svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Application Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-header);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}

.brand-info h1 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.project-select-dropdown {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color-strong);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.825rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.header-right-tools {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.runtime-status-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 0.775rem;
  font-weight: 600;
}

.dot-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-indicator.verified { background: var(--status-verified-icon); box-shadow: 0 0 8px var(--status-verified-icon); }
.dot-indicator.partial { background: var(--status-partial-icon); box-shadow: 0 0 8px var(--status-partial-icon); }
.dot-indicator.blocked { background: var(--status-blocked-icon); box-shadow: 0 0 8px var(--status-blocked-icon); }

.theme-toggle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-color-strong);
}

/* App Main Container */
.app-container {
  display: flex;
  flex: 1;
}

/* Sidebar Navigation */
.app-sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0.75rem 0.75rem 0.35rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--bg-card-active);
  color: var(--accent-primary);
  border-color: rgba(56, 189, 248, 0.3);
}

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

.nav-badge-proposed {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--status-demo-bg);
  color: var(--status-demo-text);
  border: 1px solid var(--status-demo-border);
}

/* Main Viewport */
.app-viewport {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.view-pane {
  display: none;
  animation: paneFade 0.2s ease-in-out;
}

.view-pane.active {
  display: block;
}

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

/* Screen Headers & Actions */
.screen-header-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.screen-title-area h2 {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.screen-title-area p {
  color: var(--text-secondary);
  font-size: 0.925rem;
  margin-top: 0.25rem;
}

/* Primary Action Button */
.btn-primary-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-indigo));
  color: #ffffff;
  border: none;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
  transition: all 0.2s ease;
}

.btn-primary-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.45);
}

/* Disabled Action Buttons with Lock Tooltip */
.btn-disabled-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.7;
  position: relative;
  transition: all 0.2s ease;
}

.btn-disabled-action svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
}

.btn-disabled-action:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 115%;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #f8fafc;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color-strong);
  z-index: 100;
}

/* Status Badges - Icon + Text + Color Rule */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.badge-status svg {
  width: 13px;
  height: 13px;
}

.badge-verified {
  background: var(--status-verified-bg);
  border: 1px solid var(--status-verified-border);
  color: var(--status-verified-text);
}

.badge-partial {
  background: var(--status-partial-bg);
  border: 1px solid var(--status-partial-border);
  color: var(--status-partial-text);
}

.badge-blocked {
  background: var(--status-blocked-bg);
  border: 1px solid var(--status-blocked-border);
  color: var(--status-blocked-text);
}

.badge-quarantined {
  background: var(--status-quarantined-bg);
  border: 1px solid var(--status-quarantined-border);
  color: var(--status-quarantined-text);
}

.badge-demo {
  background: var(--status-demo-bg);
  border: 1px solid var(--status-demo-border);
  color: var(--status-demo-text);
}

/* Cards & Editorial Content Panels */
.editorial-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.editorial-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.editorial-card-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Narrative Timeline (Sequential Role Workflow) */
.role-timeline {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  padding-left: 2rem;
  margin: 1.5rem 0;
}

.role-timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border-color-strong);
}

.role-timeline-step {
  position: relative;
}

.role-timeline-node {
  position: absolute;
  left: -2rem;
  top: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.role-timeline-content {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.role-timeline-role {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

/* Conversational Experience (ChatGPT-Style Mission UI) */
.chat-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  height: 650px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.chat-header {
  padding: 1rem 1.5rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-select-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-thread-pane {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: var(--bg-app);
}

.chat-message-row {
  display: flex;
  gap: 1rem;
  max-width: 85%;
}

.chat-message-row.owner {
  margin-left: auto;
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.chat-message-row.orchestrator .chat-avatar {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #fff;
  border: none;
}

.chat-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  font-size: 0.925rem;
}

.chat-message-row.owner .chat-bubble {
  background: var(--bg-card-active);
  border-color: rgba(56, 189, 248, 0.3);
}

.chat-step-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--status-demo-bg);
  color: var(--status-demo-text);
  border: 1px solid var(--status-demo-border);
  font-size: 0.75rem;
  font-weight: 700;
}

.chat-composer-box {
  padding: 1.25rem 1.5rem;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.chat-intent-chips {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chip-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.chat-input-row {
  display: flex;
  gap: 0.75rem;
}

.chat-input-row textarea {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.9rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  resize: none;
  height: 48px;
}

/* Structured Mission Conversation Box */
.conversation-block {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.conversation-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  font-size: 0.9rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.conversation-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.conversation-label {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.conversation-value {
  color: var(--text-primary);
}

/* Code & Hash Monospace Box */
.code-hash-box {
  background: var(--bg-terminal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  color: #38bdf8;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}

/* Slide-Over Drawer for "Nueva Misión" */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  background: var(--bg-card);
  border-left: 1px solid var(--border-color-strong);
  width: 100%;
  max-width: 580px;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer-backdrop.open .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}

.drawer-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.drawer-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.drawer-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.drawer-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  background: var(--bg-subtle);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.9rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Integration Diagram Nodes */
.roadmap-flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.roadmap-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.roadmap-card.active {
  border-color: var(--accent-primary);
  background: var(--bg-card);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.15);
}

.font-mono {
  font-family: var(--font-mono);
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
  .roadmap-flow {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  .app-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    flex-direction: row;
    overflow-x: auto;
    padding: 0.5rem;
  }
  .sidebar-title {
    display: none;
  }
  .nav-link {
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
  }
  .app-viewport {
    padding: 1.25rem;
  }
  .app-header {
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
  }
  .conversation-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
  .chat-message-row {
    max-width: 100%;
  }
}

/* ==========================================================================
   3-COLUMN MISSION CONTROL CHAT SYSTEM (ChatGPT + Codex + Antigravity blend)
   ========================================================================== */

.chat-layout-3col {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 1rem;
  height: calc(100vh - 165px);
  min-height: 680px;
  align-items: stretch;
  position: relative;
  transition: grid-template-columns 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-layout-3col.collapsed-context {
  grid-template-columns: 280px 1fr 0px;
}

/* Column 1: Left Sidebar Pane */
.chat-sidebar-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}

.chat-sidebar-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.project-pill-select {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color-strong);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-primary);
}

.chat-sidebar-section-title {
  font-size: 0.725rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.6rem;
}

.chat-thread-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chat-thread-item {
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
  display: block;
}

.chat-thread-item:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--border-color-strong);
}

.chat-thread-item.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-primary);
}

.chat-thread-item:focus-visible {
  outline: 2px solid var(--accent-primary) !important;
  outline-offset: 2px !important;
}

.chat-recent-mission-card {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  margin-bottom: 0.4rem;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.chat-recent-mission-card:hover {
  border-color: var(--accent-primary);
}

/* Column 2: Center Main Chat Pane */
.chat-main-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-md);
}

.chat-channel-header {
  padding: 0.85rem 1.25rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-channel-agent-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.agent-avatar-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: #0f172a;
  font-weight: 900;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.3);
}

.user-avatar-badge {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color-strong);
  color: var(--text-primary);
  font-weight: 800;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

:focus-visible {
  outline: 2px solid var(--accent-primary) !important;
  outline-offset: 2px !important;
}

.chat-pipeline-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.45rem;
  padding: 0.5rem 1rem;
  background: #090f1d;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.725rem;
  overflow: hidden;
}

.pipeline-step-item {
  color: var(--text-muted);
  font-weight: 600;
}

.pipeline-step-item.active {
  color: var(--accent-primary);
  font-weight: 800;
}

.pipeline-arrow {
  color: var(--border-color-strong);
}

/* Chat Message Stream & Rows */
.chat-messages-stream {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.chat-time-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.5rem 0;
}

.chat-time-divider::before, .chat-time-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.chat-time-divider span {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-message-row {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}

.chat-message-row.owner {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.chat-message-row.orchestrator {
  align-self: flex-start;
}

.chat-bubble-owner {
  background: #1e293b;
  border: 1px solid #334155;
  color: var(--text-primary);
  padding: 0.85rem 1.1rem;
  border-radius: 16px 16px 4px 16px;
  font-size: 0.925rem;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  max-width: 680px;
}

.chat-bubble-orch {
  background: #0b1326;
  border: 1px solid var(--border-color-strong);
  color: var(--text-primary);
  padding: 1rem 1.25rem;
  border-radius: 16px 16px 16px 4px;
  font-size: 0.925rem;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  max-width: 720px;
}

/* System Activity Event Block (Compact, distinct from owner chat) */
.system-event-card {
  background: #070e1c;
  border: 1px dashed var(--border-color-strong);
  border-left: 3px solid var(--accent-secondary);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin: 0.35rem 0;
  font-size: 0.825rem;
}

.system-event-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.system-event-role-badge {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--accent-secondary);
  text-transform: uppercase;
}

/* Composer Box */
.chat-composer-container {
  background: #080e1a;
  border-top: 1px solid var(--border-color);
  padding: 0.85rem 1.25rem;
}

.chat-intent-chips {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.chip-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.1);
}

.chat-textarea-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.chat-textarea-multiline {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  resize: vertical;
  min-height: 54px;
}

.chat-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-attachment-disabled {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: not-allowed;
  opacity: 0.65;
}

.btn-send-prominent {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2) 0%, rgba(99, 102, 241, 0.2) 100%) !important;
  border-color: var(--accent-primary) !important;
  color: var(--accent-primary) !important;
  font-weight: 700 !important;
}

/* Column 3: Right Context Pane */
.chat-context-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}

.btn-subtle-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-icon-subtle {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 4px;
  cursor: pointer;
}

.btn-icon-subtle:hover {
  color: var(--text-primary);
  border-color: var(--border-color-strong);
}

.mobile-only {
  display: none !important;
}

.desktop-only {
  display: inline-flex !important;
}

/* Responsive Rules for Chat 3-Col */
@media (max-width: 1024px) {
  .chat-layout-3col {
    grid-template-columns: 240px 1fr 280px;
  }
}

@media (max-width: 900px) {
  .mobile-only {
    display: inline-flex !important;
  }
  .desktop-only {
    display: none !important;
  }

  .chat-layout-3col {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
  }

  .chat-sidebar-pane, .chat-context-pane {
    display: none;
    position: fixed;
    top: 70px;
    bottom: 20px;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    width: 320px;
    max-width: 85vw;
  }

  .chat-sidebar-pane.mobile-open {
    display: flex;
    left: 15px;
  }

  .chat-context-pane.mobile-open {
    display: flex;
    right: 15px;
  }
}

/* Code Hash Box Word Break Safety */
.code-hash-box {
  word-break: break-all;
  overflow-wrap: anywhere;
}

/* Responsive Media Queries (390px Mobile, 768px Tablet, 1024px Small Desktop) */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .app-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    gap: 0.4rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .app-sidebar::-webkit-scrollbar {
    display: none;
  }

  .sidebar-title {
    display: none;
  }

  .nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .app-viewport {
    padding: 1.25rem 1rem;
  }

  .screen-header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
  }

  .btn-primary-action {
    width: 100%;
    justify-content: center;
  }

  .roadmap-flow {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .app-header {
    padding: 0.75rem 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .header-right-tools {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .runtime-status-pill {
    font-size: 0.7rem;
    padding: 3px 8px;
  }

  .drawer-panel {
    width: 100%;
    max-width: 100vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
