/* Slot Studio Pipeline Dashboard - Light Theme Default */

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-hover: #f0f4ff;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --border-color: #e5e7eb;
  --accent: #6366f1;
  --accent-dim: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #38bdf8;
  --user-highlight: #3b82f6;
  --scrollbar-thumb: #c4c9d4;
  --scrollbar-track: #f1f5f9;

  /* Role colors */
  --role-concept: #6366f1;
  --role-math: #8b5cf6;
  --role-design: #d946ef;
  --role-build: #3b82f6;
  --role-qa: #10b981;
  --role-package: #f59e0b;
  --role-gate: #fbbf24;
}

/* Dark theme overrides */
[data-theme="dark"] {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --bg-surface: #202040;
  --bg-hover: #2a2a4a;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b8;
  --text-muted: #6a6a80;
  --border-color: #2a2a4a;
  --accent: #7c5cfc;
  --accent-dim: #5a3fd6;
  --accent-glow: rgba(124, 92, 252, 0.15);
  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;
  --info: #38bdf8;
  --user-highlight: #3b82f6;
  --scrollbar-thumb: #3a3a5a;
  --scrollbar-track: #1a1a2e;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* Layout */
.app-container {
  display: grid;
  grid-template-columns: 1fr 360px;
  grid-template-rows: 48px auto 1fr auto 56px;
  height: 100vh;
  gap: 1px;
  background: var(--border-color);
  overflow: hidden;
}

/* ── Header ── */
.header {
  grid-column: 1 / -1;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
  position: relative;
  z-index: 1200;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.logo {
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ── Phase Timeline (header bar) ── */
.phase-timeline {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  justify-content: center;
  max-width: 600px;
}

.timeline-phase {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: default;
  transition: opacity 0.3s;
}

.timeline-phase.pending {
  opacity: 0.4;
}

.timeline-phase.active {
  opacity: 1;
}

.timeline-phase.completed {
  opacity: 0.8;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--text-muted);
  transition: all 0.3s;
  flex-shrink: 0;
}

.timeline-phase.active .timeline-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
  animation: timelinePulse 2s infinite;
}

.timeline-phase.completed .timeline-dot {
  background: var(--success);
  border-color: var(--success);
}

.timeline-phase.failed .timeline-dot {
  background: var(--error);
  border-color: var(--error);
}

@keyframes timelinePulse {
  0%, 100% { box-shadow: 0 0 4px rgba(99, 102, 241, 0.3); }
  50% { box-shadow: 0 0 12px rgba(99, 102, 241, 0.6); }
}

.timeline-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.timeline-phase.active .timeline-label {
  color: var(--accent);
}

.timeline-phase.completed .timeline-label {
  color: var(--success);
}

.timeline-connector {
  width: 24px;
  height: 2px;
  background: var(--border-color);
  flex-shrink: 0;
  margin: 0 2px;
  transition: background 0.3s;
}

.timeline-connector.completed {
  background: var(--success);
}

.timeline-connector.active {
  background: linear-gradient(90deg, var(--success), var(--accent));
}

/* ── Connection + Status ── */
.connection-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
  transition: background 0.3s;
}

.connection-dot.connected {
  background: var(--success);
}

.pipeline-status-badge {
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-surface);
  color: var(--text-muted);
}

.pipeline-status-badge.running {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
}

.pipeline-status-badge.complete {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.pipeline-status-badge.paused {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

.pipeline-status-badge.error {
  background: rgba(248, 113, 113, 0.15);
  color: var(--error);
}

.agent-counter {
  font-variant-numeric: tabular-nums;
}

.header-nav-link {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  transition: all 0.2s;
}

.header-nav-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

/* ── Chat Filter Bar ── */
.chat-filter-bar {
  grid-column: 1 / 2;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border-color);
}

.filter-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.filter-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-surface);
}

.filter-btn.active {
  color: var(--text-primary);
  background: var(--bg-surface);
  border-color: var(--border-color);
}

/* ── Chat Panel ── */
.chat-panel {
  grid-column: 1 / 2;
  grid-row: 3 / 4;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

/* ── Chat Message ── */
.chat-message {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.15s;
  animation: messageIn 0.2s ease-out;
}

.chat-message:hover {
  background: var(--bg-hover);
}

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

.message-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  margin-top: 2px;
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.message-agent-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.message-role-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  opacity: 0.8;
}

.message-phase-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-weight: 500;
}

.message-timestamp {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

.message-content {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  word-break: break-word;
  white-space: pre-wrap;
}

/* Collapsible long messages */
.message-content.collapsed {
  max-height: 120px;
  overflow: hidden;
  position: relative;
}

.message-content.collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--bg-primary));
  pointer-events: none;
}

.message-expand-btn {
  display: none;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  font-family: inherit;
}

.message-expand-btn.visible {
  display: inline-block;
}

.message-expand-btn:hover {
  text-decoration: underline;
}

/* Inline code in messages */
.message-content code {
  background: var(--bg-surface);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
}

/* Code blocks in messages */
.message-content pre {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 4px 0;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.5;
}

/* Bold text in messages */
.message-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Lists in messages */
.message-content ul, .message-content ol {
  padding-left: 20px;
  margin: 4px 0;
}

/* User message highlight */
.chat-message.user-message {
  background: rgba(59, 130, 246, 0.08);
  border-left: 3px solid var(--user-highlight);
}

.chat-message.user-message .message-agent-name {
  color: var(--user-highlight);
}

/* ── Tool Use Cards ── */
.tool-card {
  display: flex;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 6px;
  animation: messageIn 0.2s ease-out;
  border-left: 2px solid var(--bg-tertiary);
}

.tool-card .tool-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  margin-top: 2px;
}

.tool-card .tool-body {
  flex: 1;
  min-width: 0;
}

.tool-card .tool-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.tool-card .tool-agent {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.tool-card .tool-name {
  font-size: 11px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
  padding: 1px 6px;
  border-radius: 3px;
}

.tool-card .tool-timestamp {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.tool-card .tool-result {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tool-specific icon colors */
.tool-card[data-tool="run_simulation"] .tool-icon { color: var(--role-math); }
.tool-card[data-tool="write_file"] .tool-icon { color: var(--success); }
.tool-card[data-tool="read_file"] .tool-icon { color: var(--info); }
.tool-card[data-tool="generate_symbol_svg"] .tool-icon { color: var(--role-design); }
.tool-card[data-tool="generate_sounds"] .tool-icon { color: #f472b6; }
.tool-card[data-tool="build_game_template"] .tool-icon { color: var(--role-build); }
.tool-card[data-tool="package_math"] .tool-icon { color: var(--role-package); }
.tool-card[data-tool="package_frontend"] .tool-icon { color: var(--role-package); }

/* Spinning indicator for active tool */
.tool-card.running .tool-icon {
  animation: toolSpin 1s linear infinite;
}

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

/* ── Artifact Cards ── */
.artifact-card {
  display: flex;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 6px;
  animation: messageIn 0.2s ease-out;
  border-left: 2px solid rgba(52, 211, 153, 0.3);
}

.artifact-card .artifact-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 6px;
  background: rgba(52, 211, 153, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  margin-top: 2px;
}

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

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

.artifact-card .artifact-agent {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.artifact-card .artifact-filename {
  font-size: 12px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--success);
}

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

/* ── Pipeline Panel ── */
.pipeline-panel {
  grid-row: 2 / 5;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: auto;
  border-left: 1px solid var(--border-color);
}

.pipeline-header {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
}

.pipeline-stages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-stages::-webkit-scrollbar {
  width: 4px;
}

.pipeline-stages::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 2px;
}

/* ── Pipeline Stage ── */
.pipeline-stage {
  background: var(--bg-surface);
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid transparent;
  transition: all 0.3s;
}

.pipeline-stage.completed {
  border-color: rgba(52, 211, 153, 0.25);
  background: rgba(52, 211, 153, 0.04);
}

.pipeline-stage.active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.06);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.08);
}

.pipeline-stage.pending {
  opacity: 0.5;
}

.stage-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.stage-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.pipeline-stage.completed .stage-number {
  background: var(--success);
  color: white;
}

.pipeline-stage.active .stage-number {
  background: var(--accent);
  color: white;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0); }
}

.stage-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.pipeline-stage.pending .stage-title {
  color: var(--text-muted);
}

.stage-status-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: auto;
  text-transform: uppercase;
}

.stage-status-badge.running {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
  animation: badgePulse 2s infinite;
}

.stage-status-badge.paused {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

@keyframes badgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Total pipeline timer */
.pipeline-total-timer {
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.total-timer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.total-timer-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.total-timer-status {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.total-timer-status.running {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
}

.total-timer-status.completed {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

.total-timer-status.paused {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}

.total-timer-status.error {
  background: rgba(248, 113, 113, 0.15);
  color: var(--error);
}

.total-timer-value {
  margin-left: auto;
  font-size: 14px;
  font-weight: 600;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Overall pipeline progress bar */
.pipeline-overall-progress {
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.overall-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.overall-progress-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.overall-progress-pct {
  font-size: 13px;
  font-weight: 700;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.overall-progress-track {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.overall-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent), #a78bfa);
  transition: width 0.8s ease;
  min-width: 0;
}

/* Turn counter + timer row */
.stage-turn-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  margin-bottom: 6px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.stage-turn-timer.completed {
  opacity: 0.7;
}

.turn-counter {
  font-weight: 600;
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 10px;
}

.turn-elapsed {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--text-secondary);
  font-size: 11px;
}

.turn-eta {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 10px;
  font-style: italic;
}

/* Current speaker display */
.current-speaker-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.current-speaker-display .speaker-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  opacity: 0.8;
}

.current-speaker-display .speaker-avatar {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: white;
}

.current-speaker-display .speaker-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.current-speaker-display .speaker-turn-timer {
  margin-left: auto;
  font-size: 12px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}

/* Pending stage turn counter */
.stage-turn-timer.pending {
  opacity: 0.5;
}

.turn-counter.pending-turns {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

/* Current speaking agent highlight */
.stage-agent-chip.current-speaker {
  background: rgba(99, 102, 241, 0.15);
  color: var(--text-primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.stage-agent-chip.current-speaker .agent-status-dot {
  background: var(--accent);
  animation: blink 1s infinite;
}

.stage-progress-bar {
  height: 3px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  margin-bottom: 8px;
  overflow: hidden;
}

.stage-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.5s ease;
}

.pipeline-stage.completed .stage-progress-fill {
  background: var(--success);
  width: 100% !important;
}

/* Stage agents */
.stage-agents {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.stage-agent-chip {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.stage-agent-chip.working {
  color: var(--text-primary);
}

.stage-agent-chip .agent-status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
}

.stage-agent-chip.working .agent-status-dot {
  background: var(--success);
  animation: blink 1.5s infinite;
}

.stage-agent-chip.idle .agent-status-dot {
  background: var(--text-muted);
}

.stage-agent-chip.error .agent-status-dot {
  background: var(--error);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Gate agent chip highlight */
.stage-agent-chip.gate-agent {
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.stage-agent-chip.gate-agent::after {
  content: 'GATE';
  font-size: 7px;
  font-weight: 700;
  color: var(--warning);
  letter-spacing: 0.3px;
}

/* Quality Gate */
.quality-gate {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-top: 8px;
  border-radius: 6px;
  background: var(--bg-tertiary);
  font-size: 11px;
}

.quality-gate .gate-icon {
  font-size: 12px;
}

.quality-gate .gate-label {
  color: var(--text-muted);
}

.quality-gate.passed .gate-label {
  color: var(--success);
}

.quality-gate.failed .gate-label {
  color: var(--error);
}

/* ── Input Bar ── */
.input-bar {
  grid-column: 1 / -1;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 12px;
  border-top: 1px solid var(--border-color);
}

.input-field {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

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

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

.send-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

.send-btn:hover {
  background: var(--accent-dim);
}

.send-btn:active {
  transform: scale(0.97);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── System Messages ── */
.system-message {
  text-align: center;
  padding: 4px 0;
  animation: messageIn 0.2s ease-out;
}

.system-message .system-text {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 2px 12px;
  border-radius: 10px;
  display: inline-block;
}

/* Phase change system messages */
.system-message.phase-change .system-text {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
  font-weight: 600;
  padding: 4px 16px;
}

/* Gate system messages */
.system-message.gate-passed .system-text {
  background: rgba(52, 211, 153, 0.1);
  color: var(--success);
}

.system-message.gate-failed .system-text {
  background: rgba(248, 113, 113, 0.1);
  color: var(--error);
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 40px;
  opacity: 0.3;
}

.empty-state .empty-text {
  font-size: 14px;
}

.empty-state .empty-hint {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.6;
}

/* ── Filter visibility ── */
.chat-message[data-filter-type="messages"].filtered,
.tool-card[data-filter-type="tools"].filtered,
.artifact-card[data-filter-type="artifacts"].filtered,
.system-message[data-filter-type="system"].filtered {
  display: none;
}

/* ── Pipeline Log Panel ── */
.log-panel {
  grid-column: 1 / -1;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  max-height: 240px;
  min-height: 36px;
  transition: max-height 0.2s ease;
  overflow: hidden;
}

.log-panel.collapsed {
  max-height: 36px;
}

.log-panel.collapsed .log-body {
  display: none;
}

.log-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  min-height: 28px;
}

.log-toggle-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: inherit;
}

.log-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.log-filters {
  display: flex;
  gap: 2px;
}

.log-filter-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: inherit;
}

.log-filter-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.log-filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.log-count-badge {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.log-ctrl-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 10px;
  border-radius: 4px;
  font-family: inherit;
}

.log-ctrl-btn:hover {
  background: var(--bg-hover);
}

.log-ctrl-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.log-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.5;
}

.log-line {
  display: flex;
  gap: 8px;
  padding: 1px 12px;
  white-space: nowrap;
}

.log-line:hover {
  background: var(--bg-hover);
}

.log-ts {
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 70px;
}

.log-level {
  flex-shrink: 0;
  font-weight: 600;
  min-width: 60px;
}

.log-source {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.log-msg {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-line.log-filtered {
  display: none;
}

/* ── Loading Spinner ── */
.ss-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.ss-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ssSpinnerRotate 0.7s linear infinite;
}

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

/* ── Responsive ── */
@media (max-width: 900px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-rows: 48px auto 1fr auto 240px 56px;
  }

  .pipeline-panel {
    grid-row: 5;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }

  .phase-timeline {
    display: none;
  }
}
