:root {
  --bg: #f5f1e9;
  --bg-ink: #1b2a27;
  --card: #ffffff;
  --muted: #5a6c68;
  --accent: #d66b4a;
  --accent-2: #2f7a74;
  --ring: rgba(27, 42, 39, 0.1);
  --shadow: 0 20px 50px rgba(27, 42, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    'Space Grotesk',
    system-ui,
    -apple-system,
    sans-serif;
  color: var(--bg-ink);
  background: radial-gradient(circle at top left, #ffffff 0%, var(--bg) 55%, #ece2d5 100%);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(214, 107, 74, 0.08), transparent 40%),
    linear-gradient(300deg, rgba(47, 122, 116, 0.12), transparent 45%);
  pointer-events: none;
  z-index: 0;
}

main {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 4rem;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2.5rem;
}

.brand {
  display: inline-flex;
  flex-direction: column;
  gap: 0.5rem;
}

.brand h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  letter-spacing: -0.02em;
}

.beta-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
}

.beta-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(214, 107, 74, 0.2);
}

.hero p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  max-width: 520px;
  line-height: 1.5;
}

.hero aside {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(27, 42, 39, 0.08);
}

.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.panel {
  background: var(--card);
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(27, 42, 39, 0.08);
  position: relative;
  overflow: hidden;
  animation: rise 0.7s ease both;
}

.panel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgba(214, 107, 74, 0.06), transparent 60%);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.panel:hover::after {
  opacity: 1;
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.3rem;
}

label {
  display: block;
  margin-top: 1rem;
  font-weight: 600;
  font-size: 0.95rem;
}

input,
select {
  width: 100%;
  padding: 0.75rem 0.9rem;
  margin-top: 0.4rem;
  border-radius: 12px;
  border: 1px solid rgba(27, 42, 39, 0.15);
  background: #fbfaf7;
  font-size: 0.95rem;
}

input:focus,
select:focus {
  outline: 2px solid rgba(214, 107, 74, 0.35);
  border-color: rgba(214, 107, 74, 0.6);
}

.checkbox {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.checkbox input {
  width: auto;
  margin-top: 0.2rem;
}

button {
  margin-top: 1.2rem;
  padding: 0.75rem 1.1rem;
  border-radius: 14px;
  border: none;
  background: var(--bg-ink);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(27, 42, 39, 0.2);
}

button.secondary {
  background: transparent;
  color: var(--bg-ink);
  border: 1px solid rgba(27, 42, 39, 0.2);
  box-shadow: none;
}

.link {
  display: inline-block;
  margin-top: 0.6rem;
  color: var(--accent-2);
  font-weight: 600;
  text-decoration: none;
}

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

.docs-list {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.docs-list li {
  margin-bottom: 0.4rem;
}

.status {
  margin-top: 1rem;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  background: rgba(47, 122, 116, 0.1);
  color: #18423f;
  display: none;
}

.status.error {
  background: rgba(214, 107, 74, 0.12);
  color: #7b3a26;
}

.console {
  margin-top: 2rem;
  display: none;
}

.console.active {
  display: block;
  animation: fade 0.6s ease both;
}

.console-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(47, 122, 116, 0.12);
  color: var(--accent-2);
  font-weight: 600;
  font-size: 0.85rem;
}

.keys {
  display: grid;
  gap: 1rem;
}

.key-card {
  border-radius: 16px;
  border: 1px solid rgba(27, 42, 39, 0.1);
  padding: 1rem;
  background: #fefcf8;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.key-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.key-actions {
  display: flex;
  gap: 0.6rem;
}

.key-actions button {
  margin-top: 0;
  font-size: 0.85rem;
}

.mono {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

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

@media (max-width: 720px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-grid {
    grid-template-columns: 1fr;
  }

  .chat-messages {
    padding: 1rem 0.75rem;
    gap: 1rem;
  }

  .chat-bubble {
    max-width: min(85%, 100%);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }

  .chat-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
  }

  .chat-input-container {
    padding: 0.5rem;
    border-radius: 20px;
  }

  .chat-input-container textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.5rem;
  }

  .chat-send-button {
    width: 32px;
    height: 32px;
  }

  .chat-empty-state {
    padding: 2rem 1rem;
  }

  .chat-empty-icon {
    font-size: 2.5rem;
  }

  .chat-empty-state h3 {
    font-size: 1.1rem;
  }

  .chat-empty-state p {
    font-size: 0.9rem;
  }
}

.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;
}

.chat-main {
  max-width: 1400px;
  padding: 2.75rem 1.5rem 3.5rem;
}

.chat-hero {
  margin-bottom: 1.75rem;
}

.chat-hero-links {
  display: inline-flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.chat-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}

.chat-panel,
.canvas-panel {
  display: flex;
  flex-direction: column;
  min-height: 70vh;
  max-height: 85vh;
}

.chat-panel {
  overflow: hidden;
}

.chat-panel-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.chat-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

#chat-byok-note {
  display: none;
  margin-top: 0.35rem;
}

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 1rem;
}

.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  scroll-behavior: smooth;
  position: relative;
}

.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.chat-empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.6;
}

.chat-empty-state h3 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  color: var(--bg-ink);
  font-weight: 600;
}

.chat-empty-state p {
  margin: 0;
  font-size: 0.95rem;
  max-width: 400px;
  line-height: 1.5;
}

.chat-trace-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.35rem;
}

.chat-trace-toggle {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

/* Black-box guarantee: never display internal provenance (e.g., step IDs). */
#canvas-provenance {
  display: none !important;
}

.chat-trace-toggle input {
  width: auto;
  margin: 0;
}

.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: messageSlideIn 0.3s ease-out;
  max-width: 100%;
}

.chat-message-user {
  flex-direction: row-reverse;
}

.chat-message-assistant,
.chat-message-system {
  flex-direction: row;
}

.chat-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: rgba(27, 42, 39, 0.08);
  border: 1px solid rgba(27, 42, 39, 0.1);
}

.chat-message-user .chat-avatar {
  background: linear-gradient(135deg, #2f7a74 0%, #1b5e57 100%);
  border-color: rgba(47, 122, 116, 0.3);
  color: white;
}

.chat-message-assistant .chat-avatar,
.chat-message-system .chat-avatar {
  background: linear-gradient(135deg, #d66b4a 0%, #c0553a 100%);
  border-color: rgba(214, 107, 74, 0.3);
  color: white;
}

.chat-bubble {
  max-width: min(75%, 680px);
  padding: 0.875rem 1.125rem;
  border-radius: 18px;
  line-height: 1.6;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  position: relative;
}

.chat-message-user .chat-bubble {
  background: linear-gradient(135deg, #2f7a74 0%, #1b5e57 100%);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(47, 122, 116, 0.15);
}

.chat-message-assistant .chat-bubble,
.chat-message-system .chat-bubble {
  background: #ffffff;
  color: var(--bg-ink);
  border: 1px solid rgba(27, 42, 39, 0.1);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chat-bubble pre {
  margin: 0.75rem 0;
  padding: 0.875rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.5;
}

.chat-message-user .chat-bubble pre {
  background: rgba(0, 0, 0, 0.15);
  color: white;
}

.chat-message-assistant .chat-bubble pre,
.chat-message-system .chat-bubble pre {
  background: rgba(27, 42, 39, 0.05);
  color: var(--bg-ink);
}

.chat-bubble code {
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

.chat-message-user .chat-bubble code {
  background: rgba(0, 0, 0, 0.2);
  color: white;
}

.chat-message-assistant .chat-bubble code,
.chat-message-system .chat-bubble code {
  background: rgba(27, 42, 39, 0.08);
  color: var(--bg-ink);
}

.chat-bubble p {
  margin: 0.5rem 0;
}

.chat-bubble p:first-child {
  margin-top: 0;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-message-user .chat-bubble a {
  opacity: 0.9;
}

.chat-message-assistant .chat-bubble a,
.chat-message-system .chat-bubble a {
  color: var(--accent-2);
}

.chat-bubble ul,
.chat-bubble ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.chat-bubble strong {
  font-weight: 600;
}

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

.chat-message-tool {
  justify-content: flex-start;
}

.chat-bubble-tool {
  max-width: 92%;
  padding: 0;
  background: transparent;
  border: none;
}

.tool-card {
  border-radius: 14px;
  border: 1px dashed rgba(27, 42, 39, 0.22);
  background: rgba(255, 255, 255, 0.85);
  padding: 0.65rem 0.85rem;
}

.tool-card-summary {
  list-style: none;
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  cursor: pointer;
  user-select: none;
}

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

.tool-card-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  border: 1px solid rgba(27, 42, 39, 0.12);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  background: rgba(27, 42, 39, 0.04);
  flex: 0 0 auto;
}

.tool-card-title {
  font-size: 0.92rem;
  color: var(--bg-ink);
  line-height: 1.3;
}

.tool-card-body {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(27, 42, 39, 0.08);
}

.tool-card-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.tool-card-summary.status-running .tool-card-label {
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.08);
  color: #1b3b7a;
}

.tool-card-summary.status-completed .tool-card-label {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.08);
  color: #0c5c3f;
}

.tool-card-summary.status-failed .tool-card-label {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.08);
  color: #7a1b1b;
}

.tool-trace-disabled .chat-message-tool {
  display: none;
}

.chat-input-wrapper {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(27, 42, 39, 0.08);
}

.chat-input-container {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(27, 42, 39, 0.1);
  border-radius: 24px;
  padding: 0.5rem 0.75rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chat-input-container:focus-within {
  border-color: var(--accent-2);
  box-shadow: 0 2px 12px rgba(47, 122, 116, 0.12);
}

.chat-input-container textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  min-height: 24px;
  max-height: 200px;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--bg-ink);
  outline: none;
}

.chat-input-container textarea::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.chat-send-button {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent-2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(47, 122, 116, 0.2);
}

.chat-send-button:hover:not(:disabled) {
  background: #1b5e57;
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(47, 122, 116, 0.3);
}

.chat-send-button:active:not(:disabled) {
  transform: scale(0.95);
}

.chat-send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chat-send-button svg {
  width: 18px;
  height: 18px;
}

.canvas-body {
  margin-top: 1rem;
  flex: 1 1 auto;
  overflow: auto;
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid rgba(27, 42, 39, 0.08);
  background: rgba(255, 255, 255, 0.7);
}

.canvas-body h1,
.canvas-body h2,
.canvas-body h3,
.canvas-body h4,
.canvas-body h5,
.canvas-body h6 {
  margin: 0.75rem 0 0.4rem;
}

.canvas-body p {
  margin: 0.45rem 0;
  line-height: 1.6;
}

.canvas-body ul {
  margin: 0.45rem 0;
  padding-left: 1.25rem;
}

.canvas-body ul.task-list {
  list-style: none;
  padding-left: 0;
}

.canvas-body .task-list-item {
  margin: 0.25rem 0;
}

.canvas-body .task-list-label {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.canvas-body .task-list-label input[type='checkbox'] {
  margin-top: 0.25rem;
  width: 1rem;
  height: 1rem;
  accent-color: #2f7a6d;
}

.canvas-body hr {
  border: none;
  border-top: 1px solid rgba(27, 42, 39, 0.12);
  margin: 1rem 0;
}

.canvas-table-wrapper {
  overflow-x: auto;
  margin: 0.75rem 0;
  border: 1px solid rgba(27, 42, 39, 0.1);
  border-radius: 12px;
  background: rgba(250, 248, 244, 0.8);
}

.canvas-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.canvas-table th,
.canvas-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(27, 42, 39, 0.08);
  vertical-align: top;
}

.canvas-table th {
  font-weight: 700;
  background: rgba(27, 42, 39, 0.04);
}

.canvas-code-wrapper {
  margin: 1rem 0;
  border-radius: 14px;
  border: 1px solid rgba(27, 42, 39, 0.12);
  overflow: hidden;
  background: #0f1a18;
}

.canvas-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(27, 42, 39, 0.2);
}

.canvas-code-lang {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: rgba(234, 242, 242, 0.6);
  text-transform: uppercase;
  font-weight: 600;
}

.canvas-code-copy {
  background: transparent;
  border: 1px solid rgba(234, 242, 242, 0.2);
  border-radius: 6px;
  padding: 0.25rem 0.75rem;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: #eaf2f2;
  cursor: pointer;
  transition: all 0.2s ease;
}

.canvas-code-copy:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(234, 242, 242, 0.4);
}

.canvas-code-copy.copied {
  background: rgba(47, 122, 116, 0.3);
  border-color: var(--accent-2);
  color: #eaf2f2;
}

.canvas-code {
  margin: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  color: #eaf2f2;
  padding: 0.95rem;
  overflow: auto;
}

.canvas-code code {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  white-space: pre;
}

.inline-code {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: rgba(27, 42, 39, 0.08);
  padding: 0.12rem 0.28rem;
  border-radius: 8px;
}

.canvas-artifacts {
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
}

.canvas-artifacts-title {
  font-weight: 600;
}

.canvas-artifact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-radius: 14px;
  border: 1px solid rgba(27, 42, 39, 0.1);
  padding: 0.75rem 0.9rem;
  background: rgba(255, 255, 255, 0.75);
}

.canvas-artifact-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.canvas-artifact button {
  margin-top: 0;
}

/* ============================================================
   Orchestration Transparency UI
   ============================================================ */

/* CSS Variables for Orchestration */
:root {
  --orch-panel-width: 320px;
  --orch-panel-bg: rgba(255, 255, 255, 0.95);
  --orch-section-border: rgba(27, 42, 39, 0.08);

  /* Status colors */
  --status-pending: #9ca3af;
  --status-running: #3b82f6;
  --status-completed: #10b981;
  --status-failed: #ef4444;
  --status-warning: #f59e0b;
  --status-skipped: #6b7280;

  /* Pipeline */
  --pipeline-dot-size: 12px;
  --pipeline-connector-width: 24px;

  /* Activity log */
  --activity-max-height: 200px;

  /* Animation */
  --spin-duration: 1s;
  --pulse-duration: 2s;

  /* Font */
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* 3-column grid layout */
.chat-grid-3col {
  display: grid;
  /* Use an auto third column so collapsing the orchestration panel doesn’t leave a large empty gutter. */
  grid-template-columns: minmax(350px, 1fr) minmax(350px, 1.2fr) auto;
  gap: 1.25rem;
  align-items: stretch;
}

/* When orchestration panel is collapsed, use 2-column layout */
.chat-grid-3col:has(.orch-panel.collapsed) {
  grid-template-columns: minmax(350px, 1fr) minmax(350px, 1.2fr);
}

/* ============================================================
   Pipeline Indicator
   ============================================================ */
.pipeline-indicator {
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  border: 1px solid var(--orch-section-border);
  min-height: 60px;
}

.pipeline-indicator:empty {
  display: none;
}

.pipeline-indicator[data-status='idle'] {
  display: none;
}

.pipeline-stages {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0;
}

.pipeline-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  flex: 0 0 auto;
}

.stage-dot {
  width: var(--pipeline-dot-size);
  height: var(--pipeline-dot-size);
  border-radius: 50%;
  background: var(--status-pending);
  border: 2px solid var(--status-pending);
  transition: all 0.3s ease;
}

.pipeline-stage.completed .stage-dot {
  background: var(--status-completed);
  border-color: var(--status-completed);
}

.pipeline-stage.active .stage-dot {
  background: var(--status-running);
  border-color: var(--status-running);
}

.stage-dot.pulsing {
  animation: pulse var(--pulse-duration) ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
  }
}

.stage-label {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
}

.pipeline-stage.active .stage-label,
.pipeline-stage.completed .stage-label {
  color: var(--bg-ink);
}

.pipeline-connector {
  flex: 1;
  height: 2px;
  background: var(--status-pending);
  margin: 0 0.25rem;
  margin-bottom: 1rem;
}

.pipeline-connector.completed {
  background: var(--status-completed);
}

.pipeline-progress {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

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

/* ============================================================
   Orchestration Panel
   ============================================================ */
.orch-panel {
  width: var(--orch-panel-width);
  min-width: var(--orch-panel-width);
  background: var(--orch-panel-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Prevent the shared panel “rise” animation (uses transform) from overriding drawer transforms. */
  animation: none;
  transition:
    width 0.3s ease,
    min-width 0.3s ease;
  padding: 0;
}

.orch-panel.collapsed {
  display: none;
}

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

.orch-panel-title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.orch-icon {
  font-size: 1.1rem;
}

.orch-collapse-btn {
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  border-radius: 6px;
  margin-top: 0;
}

.orch-collapse-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.orch-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

/* Sections */
.orch-section {
  margin-bottom: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--orch-section-border);
  background: #fff;
  overflow: hidden;
}

.orch-section-header {
  padding: 0.6rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.02);
  cursor: pointer;
}

.collapse-toggle {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  margin-top: 0;
}

.collapse-toggle:hover {
  transform: none;
  box-shadow: none;
}

.collapse-icon {
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

.orch-section-header[data-collapsed='true'] .collapse-icon {
  transform: rotate(-90deg);
}

.section-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--status-pending);
  color: #fff;
  font-weight: 600;
}

.section-badge.passed {
  background: var(--status-completed);
}

.section-badge.failed {
  background: var(--status-failed);
}

.orch-section-body {
  padding: 0.5rem 0.75rem;
  max-height: 300px;
  overflow-y: auto;
}

.orch-section-header[data-collapsed='true'] + .orch-section-body {
  display: none;
}

/* ============================================================
   Task Tree
   ============================================================ */
.task-tree {
  list-style: none;
  padding: 0;
  margin: 0;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  font-size: 0.85rem;
}

.task-item:last-child {
  border-bottom: none;
}

.task-status-icon {
  width: 1.2rem;
  text-align: center;
  flex-shrink: 0;
}

.task-item.completed .task-status-icon {
  color: var(--status-completed);
}

.task-item.running .task-status-icon {
  color: var(--status-running);
}

.task-item.failed .task-status-icon {
  color: var(--status-failed);
}

.task-status-icon.spinning {
  animation: spin var(--spin-duration) linear infinite;
}

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

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

.task-item.completed .task-name {
  color: var(--muted);
}

.task-duration {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.task-progress {
  width: 60px;
  height: 4px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.task-progress-bar {
  height: 100%;
  background: var(--status-running);
  transition: width 0.3s ease;
}

.task-parallel-badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  background: rgba(59, 130, 246, 0.15);
  color: var(--status-running);
  border-radius: 4px;
  font-weight: 500;
}

.task-depends {
  font-size: 0.7rem;
  color: var(--muted);
  font-style: italic;
}

.task-empty,
.activity-empty,
.gate-empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 0.75rem;
}

/* ============================================================
   Activity Log
   ============================================================ */
.activity-log .orch-section-header {
  position: relative;
}

.clear-log-btn {
  background: none;
  border: none;
  padding: 0.15rem 0.4rem;
  font-size: 1rem;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  margin-top: 0;
}

.clear-log-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: none;
  box-shadow: none;
}

.activity-list {
  max-height: var(--activity-max-height);
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.activity-time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  flex-shrink: 0;
  min-width: 52px;
}

.activity-icon {
  flex-shrink: 0;
  width: 1rem;
  text-align: center;
}

.activity-item.success .activity-icon {
  color: var(--status-completed);
}

.activity-item.warning .activity-icon {
  color: var(--status-warning);
}

.activity-item.error .activity-icon {
  color: var(--status-failed);
}

.activity-message {
  flex: 1;
  line-height: 1.4;
}

.activity-item.error .activity-message {
  color: var(--status-failed);
}

/* ============================================================
   Quality Gates
   ============================================================ */
.gate-group {
  margin-bottom: 0.5rem;
}

.gate-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0;
  font-weight: 600;
  font-size: 0.85rem;
}

.gate-header.passed .gate-icon {
  color: var(--status-completed);
}

.gate-header.failed .gate-icon {
  color: var(--status-failed);
}

.gate-header.running .gate-icon {
  color: var(--status-running);
  animation: spin var(--spin-duration) linear infinite;
}

.gate-checks {
  list-style: none;
  padding: 0 0 0 1.5rem;
  margin: 0;
}

.gate-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0;
  font-size: 0.8rem;
}

.gate-check.passed .check-icon {
  color: var(--status-completed);
}

.gate-check.failed .check-icon {
  color: var(--status-failed);
}

.gate-check.failed .check-name {
  color: var(--status-failed);
}

/* ============================================================
   Enhanced Canvas Header
   ============================================================ */
.canvas-header-enhanced {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.canvas-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.canvas-version-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  background: rgba(47, 122, 116, 0.12);
  color: var(--accent-2);
  border-radius: 8px;
  font-weight: 500;
}

.canvas-version-badge:empty {
  display: none;
}

.canvas-meta-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.canvas-provenance {
  font-size: 0.8rem;
  color: var(--muted);
}

.canvas-provenance:empty {
  display: none;
}

/* ============================================================
   Enhanced Artifact Cards
   ============================================================ */
.canvas-artifact.enhanced {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(27, 42, 39, 0.1);
  padding: 0.75rem 0.9rem;
  background: rgba(255, 255, 255, 0.85);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.canvas-artifact.enhanced:hover {
  border-color: rgba(47, 122, 116, 0.3);
  box-shadow: 0 2px 8px rgba(27, 42, 39, 0.08);
}

.artifact-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

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

.artifact-name {
  font-weight: 500;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}

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

.artifact-step {
  color: var(--accent-2);
  font-style: italic;
}

.artifact-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.artifact-download-btn,
.artifact-preview-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  border-radius: 8px;
  border: 1px solid rgba(27, 42, 39, 0.15);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background 0.2s ease;
}

.artifact-download-btn:hover,
.artifact-preview-btn:hover {
  background: rgba(47, 122, 116, 0.08);
  transform: none;
  box-shadow: none;
}

.artifact-download-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   Floating Action Button (Mobile)
   ============================================================ */
.orch-toggle-fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-ink);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-top: 0;
}

/* ============================================================
   Responsive Breakpoints
   ============================================================ */
@media (max-width: 1200px) {
  .chat-grid-3col {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .orch-panel {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    max-height: 45vh;
    border-top: 1px solid var(--orch-section-border);
  }
}

@media (min-width: 1201px) {
  .orch-panel {
    align-self: start;
    position: sticky;
    top: 1.25rem;
    max-height: calc(100vh - 2.5rem);
  }

  .orch-panel-body {
    max-height: calc(100vh - 2.5rem - 56px);
  }
}

@media (max-width: 980px) {
  .chat-grid,
  .chat-grid-3col {
    grid-template-columns: 1fr;
  }
  .chat-panel,
  .canvas-panel {
    min-height: auto;
  }
  .chat-messages,
  .canvas-body {
    max-height: 55vh;
  }

  .pipeline-stages {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .pipeline-connector {
    display: none;
  }
}

@media (max-width: 768px) {
  .orch-panel {
    background: #fff;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    max-height: none;
    border-top: none;
  }

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

  .orch-toggle-fab {
    display: flex;
  }

  .orch-panel {
    width: 100%;
    min-width: 100%;
  }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

/* Modern scrollbar for webkit browsers */
.orch-section-body::-webkit-scrollbar,
.activity-list::-webkit-scrollbar,
.task-tree::-webkit-scrollbar,
.canvas-body::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.orch-section-body::-webkit-scrollbar-track,
.activity-list::-webkit-scrollbar-track,
.task-tree::-webkit-scrollbar-track,
.canvas-body::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.orch-section-body::-webkit-scrollbar-thumb,
.activity-list::-webkit-scrollbar-thumb,
.task-tree::-webkit-scrollbar-thumb,
.canvas-body::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(27, 42, 39, 0.2);
  border-radius: 3px;
}

.orch-section-body::-webkit-scrollbar-thumb:hover,
.activity-list::-webkit-scrollbar-thumb:hover,
.task-tree::-webkit-scrollbar-thumb:hover,
.canvas-body::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(27, 42, 39, 0.35);
}

/* Firefox scrollbar */
.orch-section-body,
.activity-list,
.task-tree,
.canvas-body,
.chat-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(27, 42, 39, 0.2) transparent;
}

/* ============================================
   SKELETON LOADING ANIMATIONS
   ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(27, 42, 39, 0.08) 25%,
    rgba(27, 42, 39, 0.15) 50%,
    rgba(27, 42, 39, 0.08) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
  width: 70%;
}

.skeleton-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.skeleton-task {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.skeleton-task .skeleton-circle {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.skeleton-task .skeleton-text {
  flex: 1;
  margin-bottom: 0;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Loading states for sections */
.task-tree.loading,
.activity-list.loading,
.quality-gates.loading {
  padding: 1rem;
}

.task-tree.loading::before,
.activity-list.loading::before {
  content: '';
  display: block;
  height: 80px;
  background: linear-gradient(
    90deg,
    rgba(27, 42, 39, 0.06) 25%,
    rgba(27, 42, 39, 0.12) 50%,
    rgba(27, 42, 39, 0.06) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}

/* ============================================
   ACCESSIBILITY: REDUCED MOTION
   ============================================ */

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

  .stage-dot.pulsing {
    animation: none;
  }

  .task-status-icon.spinning {
    animation: none;
  }

  .skeleton {
    animation: none;
    background: rgba(27, 42, 39, 0.1);
  }

  .orch-panel {
    transition: none;
  }
}

/* ============================================
   ADDITIONAL FOCUS STYLES FOR ACCESSIBILITY
   ============================================ */

.collapse-toggle:focus-visible,
.orch-collapse-btn:focus-visible,
.orch-toggle-fab:focus-visible,
.clear-log-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.task-item:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: -2px;
  background: rgba(47, 122, 116, 0.08);
}

/* ============================================
   ACTIVITY ITEM ANIMATIONS
   ============================================ */

.activity-item {
  animation: activityFadeIn 0.3s ease-out;
}

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

/* New items highlight briefly */
.activity-item.new {
  background: rgba(47, 122, 116, 0.1);
}

/* ============================================
   TASK ITEM STATE TRANSITIONS
   ============================================ */

.task-item {
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.task-item.running {
  background: rgba(59, 130, 246, 0.06);
  border-left: 2px solid var(--status-running);
  padding-left: calc(0.75rem - 2px);
}

.task-item.completed {
  opacity: 0.85;
}

.task-item.failed {
  background: rgba(239, 68, 68, 0.06);
  border-left: 2px solid var(--status-failed);
  padding-left: calc(0.75rem - 2px);
}

/* ============================================
   PANEL OPEN/CLOSE ANIMATION ENHANCEMENT
   ============================================ */

.orch-section-body {
  transition:
    max-height 0.25s ease,
    opacity 0.2s ease,
    padding 0.25s ease;
  overflow: hidden;
}

.orch-section-header[data-collapsed='true'] + .orch-section-body {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.orch-section-header[data-collapsed='false'] + .orch-section-body {
  max-height: 400px;
  opacity: 1;
}
