/* ═════════════════════════════════════════════════════════════════════
 * THE CHAMBER — Workflow Stage
 * ═════════════════════════════════════════════════════════════════════
 * When the user commissions a real task, the 3D robot fades away and the
 * Workflow Stage takes its place — full-size, theatrical, soundstage
 * palette (pure black bg, amber accents on Maestro's voice, cool
 * monochrome for status text).
 *
 * Visibility is controlled by body[data-mode]:
 *   body[data-mode="idle"]       (default) → .stage shows, .workflow-stage hidden
 *   body[data-mode="workflow"]             → .stage fades, .workflow-stage rises
 *
 * Phase A scope: structure + state-driven visibility + step / output
 * rendering. Tighter polish (animations, slot fills) comes later.
 * ═════════════════════════════════════════════════════════════════════ */

:root {
  --ws-amber:        #fbbf24;
  --ws-amber-dim:    rgba(251, 191, 36, 0.5);
  --ws-amber-faint:  rgba(251, 191, 36, 0.12);
  --ws-amber-edge:   rgba(251, 191, 36, 0.35);
  --ws-cyan:         #00d4ff;
  --ws-cyan-faint:   rgba(0, 212, 255, 0.1);
  --ws-cyan-edge:    rgba(0, 212, 255, 0.3);
  --ws-green:        #34d399;
  --ws-green-faint:  rgba(52, 211, 153, 0.12);
  --ws-green-edge:   rgba(52, 211, 153, 0.4);
  --ws-red:          #f87171;
  --ws-red-faint:    rgba(248, 113, 113, 0.1);
  --ws-red-edge:     rgba(248, 113, 113, 0.4);
  --ws-text-pri:     #e5e7eb;
  --ws-text-sec:     #9ca3af;
  --ws-text-mute:    #6b7280;
  --ws-surface:      rgba(5, 10, 20, 0.85);
  --ws-surface-2:    rgba(255, 255, 255, 0.03);
  --ws-border:       rgba(255, 255, 255, 0.07);
  --ws-border-soft:  rgba(255, 255, 255, 0.04);
}

/* ── Stage / Workflow-Stage mode toggle ─────────────────────────────── */
/* The Chamber's body is CSS Grid with grid-template-areas:
 *   "top" "stage" "dialogue" "address"
 * Both .stage AND .workflow-stage share the same `stage` grid cell;
 * display:none / display:flex swaps them. The 3D robot's render loop
 * naturally pauses when its canvas (.stage descendant) is gone from the
 * compositor — display:none on the section accomplishes this directly,
 * no JS timing needed.                                                  */
body[data-mode="workflow"] .stage {
  display: none;
}
body[data-mode="workflow"] .baton-trail {
  display: none;
}

/* Hide the EXISTING score-panel (the slide-in side panel that score.js
 * renders) while our workflow-stage owns the workflow viz. Otherwise both
 * UIs render the same plan — duplicate. Strictly visual, no JS change. */
body[data-mode="workflow"] .score-panel,
body[data-mode="workflow"] #score-panel {
  display: none !important;
}

/* When the inputs modal opens during a workflow, the chamber's default
 * backdrop is rgba(0,0,0,0.78) + blur(8px) — that blacks out the entire
 * workflow stage so the user can't see WHICH step is asking for inputs.
 * Soften the backdrop and dim the modal card slightly so the stage shows
 * through. The modal card still grabs visual focus via its glow + border. */
body[data-mode="workflow"] .inputs-modal[aria-hidden="false"] {
  background: rgba(0, 0, 0, 0.45) !important;
  backdrop-filter: blur(3px) !important;
}
body[data-mode="workflow"] .inputs-modal .im-card {
  box-shadow:
    0 0 0 1px var(--ws-amber-edge),
    0 24px 60px -12px rgba(0, 0, 0, 0.85),
    0 0 80px rgba(251, 191, 36, 0.18) !important;
}

/* Hide the chat dialogue + address bar entirely during workflow execution
 * so the workflow stage gets the full screen. Both panels reappear when
 * the user dismisses the workflow (Cancel / + New Workflow → idle mode). */
body[data-mode="workflow"] .dialogue,
body[data-mode="workflow"] .address {
  display: none !important;
}

/* Workflow-stage occupies the SAME grid cell as .stage so when one is
 * display:none the other claims the cell. Hidden by default; only flexes
 * in when body[data-mode="workflow"]. */
.workflow-stage {
  grid-area: stage;
  display: none;
  position: relative;
  min-height: 0;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 2rem 1.5rem;
  flex-direction: column;
  gap: 1rem;
  z-index: 4;
  overflow-y: auto;
  overflow-x: hidden;  /* belt-and-suspenders: no descendant can force horizontal scroll */
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--ws-amber-faint) transparent;
}
.workflow-stage::-webkit-scrollbar { width: 14px !important; height: 14px !important; }
.workflow-stage::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.25) !important; border-radius: 7px; }
.workflow-stage::-webkit-scrollbar-thumb {
  background: rgba(251, 191, 36, 0.75) !important;
  border-radius: 7px !important;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.workflow-stage::-webkit-scrollbar-thumb:hover { background: var(--ws-amber) !important; }
.workflow-stage * { min-width: 0; }  /* let flex/grid children shrink past content width */
body[data-mode="workflow"] .workflow-stage {
  display: flex;
  animation: ws-rise 0.55s cubic-bezier(0.25, 1, 0.45, 1) both;
}

@keyframes ws-rise {
  0%   { opacity: 0; transform: translateY(20px) scale(0.985); }
  100% { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── Header: task summary + action buttons ──────────────────────────── */
.ws-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--ws-border);
}

.ws-head-left { flex: 1 1 auto; min-width: 0; }

.ws-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ws-amber);
  opacity: 0.7;
  margin-bottom: 0.25rem;
}
.ws-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ws-text-pri);
  margin: 0 0 0.4rem 0;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ws-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ws-amber);
  padding: 0.22rem 0.6rem;
  background: var(--ws-amber-faint);
  border: 1px solid var(--ws-amber-edge);
  border-radius: 999px;
}
.ws-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ws-amber);
  box-shadow: 0 0 8px var(--ws-amber);
  animation: ws-pulse 1.8s ease-in-out infinite;
}
.ws-status.is-complete   { color: var(--ws-green); background: var(--ws-green-faint); border-color: var(--ws-green-edge); }
.ws-status.is-complete   .ws-status-dot { background: var(--ws-green); box-shadow: 0 0 8px var(--ws-green); animation: none; }
.ws-status.is-error      { color: var(--ws-red);   background: var(--ws-red-faint);   border-color: var(--ws-red-edge); }
.ws-status.is-error      .ws-status-dot { background: var(--ws-red);   box-shadow: 0 0 8px var(--ws-red);   animation: none; }
.ws-status.is-awaiting   { color: var(--ws-cyan);  background: var(--ws-cyan-faint);  border-color: var(--ws-cyan-edge); }
.ws-status.is-awaiting   .ws-status-dot { background: var(--ws-cyan);  box-shadow: 0 0 8px var(--ws-cyan); }

@keyframes ws-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.85); }
}

.ws-head-right {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.ws-action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
  border: 1px solid transparent;
  background: transparent;
}
.ws-action:hover    { transform: translateY(-1px); }
.ws-action:active   { transform: translateY(0); }

.ws-action-secondary {
  color: var(--ws-red);
  border-color: var(--ws-red-edge);
  background: var(--ws-red-faint);
}
.ws-action-secondary:hover {
  color: var(--ws-red);
  border-color: var(--ws-red);
  background: rgba(248, 113, 113, 0.18);
}

.ws-action-primary {
  color: var(--ws-amber);
  border-color: var(--ws-amber-edge);
  background: var(--ws-amber-faint);
}
.ws-action-primary:hover {
  background: rgba(251, 191, 36, 0.22);
  border-color: var(--ws-amber-dim);
}

/* ── Progress bar ───────────────────────────────────────────────────── */
.ws-progress {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.ws-progress-track {
  flex: 1 1 auto;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.ws-progress-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--ws-amber), #f59e0b);
  transition: width 0.6s cubic-bezier(0.25, 1, 0.45, 1);
  box-shadow: 0 0 8px var(--ws-amber-dim);
}
.ws-progress-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--ws-text-mute);
  white-space: nowrap;
}

/* ── Badges row (memory / council / critic) ─────────────────────────── */
.ws-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 0;
}
.ws-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  color: var(--ws-text-sec);
  background: var(--ws-surface-2);
  border: 1px solid var(--ws-border);
  border-radius: 999px;
  animation: ws-badge-in 0.4s ease both;
}
.ws-badge[hidden] { display: none; }
.ws-badge .ws-badge-icon { font-size: 0.95rem; line-height: 1; }

.ws-badge-memory  { color: #c4b5fd; border-color: rgba(196, 181, 253, 0.3); background: rgba(196, 181, 253, 0.06); }
.ws-badge-council { color: var(--ws-amber); border-color: var(--ws-amber-edge); background: var(--ws-amber-faint); }
.ws-badge-critic  { color: var(--ws-red);   border-color: var(--ws-red-edge);   background: var(--ws-red-faint); }

@keyframes ws-badge-in {
  0%   { opacity: 0; transform: translateY(-4px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ── Steps grid ─────────────────────────────────────────────────────── */
.ws-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.65rem;
}
.ws-step {
  position: relative;
  padding: 0.85rem 0.85rem 0.7rem;
  border-radius: 12px;
  background: var(--ws-surface-2);
  border: 1px solid var(--ws-border);
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.2s ease;
  cursor: default;
}
.ws-step.is-running  {
  border-color: var(--ws-amber-edge);
  background: var(--ws-amber-faint);
  box-shadow: 0 0 0 1px var(--ws-amber-edge), 0 4px 18px rgba(251, 191, 36, 0.12);
}
.ws-step.is-complete {
  border: 1.5px solid var(--ws-amber) !important;
  background: var(--ws-amber-faint) !important;
  box-shadow: 0 0 0 1px var(--ws-amber-edge), 0 4px 22px rgba(251, 191, 36, 0.22) !important;
}
.ws-step.is-error    {
  border-color: var(--ws-red-edge);
  background: var(--ws-red-faint);
}
.ws-step.is-awaiting {
  border-color: var(--ws-cyan-edge);
  background: var(--ws-cyan-faint);
}

.ws-step-number {
  position: absolute;
  top: -7px;
  left: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(107, 114, 128, 0.4);
  color: var(--ws-text-pri);
  border: 1px solid var(--ws-border);
}
.ws-step.is-running  .ws-step-number { background: var(--ws-amber); color: #1f1300; border-color: transparent; }
.ws-step.is-complete .ws-step-number { background: var(--ws-green); color: #03301f; border-color: transparent; }
.ws-step.is-error    .ws-step-number { background: var(--ws-red);   color: #2b0a0a; border-color: transparent; }

.ws-step-icon {
  text-align: center;
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 0.35rem;
}
.ws-step-spin {
  display: inline-block;
  animation: ws-spin 1.4s linear infinite;
}
@keyframes ws-spin { 100% { transform: rotate(360deg); } }

.ws-step-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ws-text-pri);
  text-align: center;
  margin: 0 0 0.15rem 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-step-tool {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--ws-text-mute);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Output pane (live stream) ──────────────────────────────────────── */
.ws-output-wrap {
  flex: 1 1 auto;
  min-height: 200px;
  border-radius: 14px;
  background: var(--ws-surface);
  border: 1px solid var(--ws-amber-faint);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ws-output-wrap.is-complete {
  border: 1.5px solid var(--ws-amber) !important;
  box-shadow: 0 0 0 1px var(--ws-amber-edge), 0 4px 26px rgba(251, 191, 36, 0.22) !important;
}
.ws-output-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.95rem;
  background: rgba(251, 191, 36, 0.04);
  border-bottom: 1px solid var(--ws-amber-faint);
  flex-shrink: 0;
}
.ws-output-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ws-amber);
  box-shadow: 0 0 6px var(--ws-amber);
  animation: ws-pulse 1.8s ease-in-out infinite;
  flex-shrink: 0;
}
.ws-output-wrap.is-complete .ws-output-dot { background: var(--ws-green); box-shadow: 0 0 6px var(--ws-green); animation: none; }
.ws-output-wrap.is-error    .ws-output-dot { background: var(--ws-red);   box-shadow: 0 0 6px var(--ws-red);   animation: none; }

.ws-output-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--ws-amber);
  letter-spacing: 0.05em;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-output-wrap.is-complete .ws-output-label { color: var(--ws-green); }
.ws-output-wrap.is-error    .ws-output-label { color: var(--ws-red); }

.ws-output-parallel {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--ws-cyan);
  padding: 0.18rem 0.55rem;
  background: var(--ws-cyan-faint);
  border: 1px solid var(--ws-cyan-edge);
  border-radius: 999px;
  flex-shrink: 0;
}
.ws-output-parallel[hidden] { display: none; }

.ws-send-email {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  padding: 0.4rem 0.85rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ws-cyan);
  background: var(--ws-cyan-faint);
  border: 1px solid var(--ws-cyan-edge);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}
.ws-send-email:hover {
  background: rgba(0, 212, 255, 0.18);
  border-color: rgba(0, 212, 255, 0.55);
}
.ws-send-email:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ws-send-email[hidden] { display: none; }

.ws-output {
  flex: 1 1 auto;
  padding: 1.1rem 1.4rem;
  overflow-y: auto;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ws-text-pri);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ws-output:empty::before {
  content: attr(data-placeholder);
  color: var(--ws-text-mute);
  font-style: italic;
}
/* Embedded SVG deliverables (slide decks, charts, diagrams) — render as
   centered figures so the visual artifact is the focal point, not raw text. */
.ws-output .ws-svg-figure {
  margin: 1.2rem auto;
  padding: 0;
  text-align: center;
  display: block;
  max-width: 100%;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--ws-amber-faint);
  overflow: hidden;
  line-height: 0;
}
.ws-output .ws-svg-figure svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}
/* Custom scrollbar (matches soundstage palette) */
.ws-output { scrollbar-width: auto !important; scrollbar-color: rgba(251, 191, 36, 0.85) rgba(0,0,0,0.25) !important; }
.ws-output::-webkit-scrollbar { width: 14px !important; height: 14px !important; }
.ws-output::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.25) !important; border-radius: 7px; }
.ws-output::-webkit-scrollbar-thumb {
  background: rgba(251, 191, 36, 0.85) !important;
  border-radius: 7px !important;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.ws-output::-webkit-scrollbar-thumb:hover { background: var(--ws-amber) !important; }

/* ═══════════════════════════════════════════════════════════════════════
 * MUTE BUTTON: visible "is-muted" feedback
 * ═══════════════════════════════════════════════════════════════════════
 * The original chamber.css only swaps SVG paths via aria-pressed — too
 * subtle once a text label was added. mute-button-enhance.js adds an
 * .is-muted class on toggle; these rules make the muted state obvious:
 *   • Label text reads "Muted" instead of "Sound" (set by JS)
 *   • Button border + label glow shift to red
 *   • Subtle strike-through on the speaker icon
 * Targets .ct-btn (the existing chamber button class) to inherit shape. */

.ct-btn.is-muted {
  border-color: var(--ws-red-edge) !important;
  background: var(--ws-red-faint) !important;
  color: var(--ws-red) !important;
}
.ct-btn.is-muted .ct-btn-label {
  color: var(--ws-red);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.ct-btn.is-muted svg {
  stroke: var(--ws-red);
  opacity: 0.85;
}

/* Calm green active-state for the unmuted SOUND button so users see it's
 * already ON and not something they need to "turn on" by clicking. */
.ct-btn.is-on {
  border-color: var(--ws-green-edge) !important;
  color: var(--ws-green) !important;
}
.ct-btn.is-on .ct-btn-label {
  color: var(--ws-green);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.ct-btn.is-on svg { stroke: var(--ws-green); }

/* ═══════════════════════════════════════════════════════════════════════
 * MIC BUTTON: visible "is-listening" state
 * ═══════════════════════════════════════════════════════════════════════
 * mic-button-enhance.js adds `.is-listening` to the mic button while STT
 * is active. These rules give an unmistakable red-pulse feedback so the
 * user knows recording is live (not just hoping when nothing happens).
 * Targets the existing #btn-mic / .adr-mic class (chamber.css owns shape). */

#btn-mic.is-listening,
.adr-mic.is-listening {
  background: rgba(248, 113, 113, 0.18) !important;
  border-color: var(--ws-red) !important;
  box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.15);
  animation: mic-pulse 1.2s ease-in-out infinite;
}
#btn-mic.is-listening svg,
.adr-mic.is-listening svg { stroke: var(--ws-red); }
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.45); }
  50%      { box-shadow: 0 0 0 10px rgba(248, 113, 113, 0); }
}

/* Transcribing: cyan spinner-like pulse while audio uploads to Whisper */
#btn-mic.is-transcribing,
.adr-mic.is-transcribing {
  background: rgba(0, 212, 255, 0.18) !important;
  border-color: var(--ws-cyan) !important;
  cursor: wait;
  animation: mic-transcribe-pulse 1.0s ease-in-out infinite;
}
#btn-mic.is-transcribing svg,
.adr-mic.is-transcribing svg { stroke: var(--ws-cyan); }
@keyframes mic-transcribe-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* Error: solid red so user sees that something broke. The JS auto-reverts
 * after 4s so the user can retry without page reload. Tooltip carries the
 * specific reason (permission denied, transcribe failed, network, etc.). */
#btn-mic.is-mic-error,
.adr-mic.is-mic-error {
  background: rgba(248, 113, 113, 0.32) !important;
  border-color: var(--ws-red) !important;
  color: #fff !important;
}
#btn-mic.is-mic-error svg,
.adr-mic.is-mic-error svg { stroke: #fff; }

/* ── Preparing hint (soft, shown after 8s of silence) ───────────────── */
.ws-preparing-hint {
  margin-bottom: 0.85rem;
  padding: 0.65rem 0.95rem;
  border-radius: 10px;
  background: var(--ws-amber-faint);
  border: 1px solid var(--ws-amber-edge);
  color: var(--ws-text-pri);
  font-size: 0.8rem;
  line-height: 1.45;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  word-wrap: break-word;
  animation: ws-badge-in 0.4s ease both;
}
.ws-preparing-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--ws-amber-edge);
  border-top-color: var(--ws-amber);
  animation: ws-spin 0.9s linear infinite;
  flex-shrink: 0;
}
.ws-preparing-hint em {
  color: var(--ws-text-sec);
  font-style: normal;
  font-size: 0.72rem;
}

/* ── Stalled banner (shown when stall watchdog fires) ───────────────── */
.ws-stalled-banner {
  margin-bottom: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid var(--ws-red-edge);
  color: var(--ws-text-pri);
  font-size: 0.82rem;
  line-height: 1.45;
}
.ws-stalled-banner strong {
  color: var(--ws-red);
  font-weight: 600;
}

/* ── Forge banner (shown while a specialist is being born) ──────────── */
.ws-forge-banner {
  margin-bottom: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--ws-text-pri);
  font-size: 0.82rem;
  line-height: 1.45;
}
.ws-forge-banner strong {
  color: var(--ws-amber);
  font-weight: 600;
}
.ws-forge-banner code {
  font-family: var(--ws-mono, ui-monospace, "SF Mono", Menlo, monospace);
  color: var(--ws-amber);
}

/* ── Streaming cursor (subtle blink during active output) ───────────── */
.ws-stream-cursor {
  display: inline-block;
  width: 0.5em;
  color: var(--ws-amber);
  animation: ws-blink 1.05s steps(2, start) infinite;
}
@keyframes ws-blink {
  to { visibility: hidden; }
}

/* ── Responsive (compact workflow on narrow viewports) ──────────────── */
@media (max-width: 720px) {
  .workflow-stage {
    padding: 0.85rem 0.75rem 1rem;
    gap: 0.6rem;
  }
  .ws-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    padding-bottom: 0.55rem;
  }
  .ws-eyebrow { font-size: 0.62rem; letter-spacing: 0.18em; }
  .ws-title {
    font-size: 1.05rem;
    -webkit-line-clamp: 3;
    line-height: 1.3;
  }
  .ws-status {
    font-size: 0.62rem;
    padding: 0.18rem 0.5rem;
  }
  .ws-head-right { width: 100%; justify-content: stretch; }
  .ws-action {
    flex: 1 1 auto;
    justify-content: center;
    padding: 0.45rem 0.7rem;
    font-size: 0.72rem;
  }
  .ws-progress { gap: 0.55rem; }
  .ws-progress-label { font-size: 0.6rem; }

  /* Badges: stack vertically so each is full-width and never overlaps
   * step nodes. Removes the cramped horizontal pile. */
  .ws-badges {
    flex-direction: column;
    gap: 0.35rem;
    align-items: stretch;
  }
  .ws-badge {
    width: 100%;
    padding: 0.35rem 0.6rem;
    font-size: 0.7rem;
    border-radius: 8px;
    /* Single line on mobile — the -webkit-line-clamp/-webkit-box combo was
     * unreliable inside inline-flex (clamped box still rendered taller than
     * its border, bleeding into the steps grid). One line + ellipsis is
     * predictable; the cap is enforced both here AND in JS (shorter gist). */
    min-width: 0;
  }
  .ws-badge .ws-badge-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
  }

  /* Step nodes: 1 column on very narrow, 2 columns on small mobile.
   * Always full-width strips so they never get covered by badges. */
  .ws-steps {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .ws-step {
    padding: 0.55rem 0.7rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
    text-align: left;
  }
  .ws-step-number {
    position: static;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }
  .ws-step-icon {
    margin-bottom: 0;
    font-size: 1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
  }
  .ws-step-name {
    font-size: 0.8rem;
    text-align: left;
    flex: 1 1 auto;
    min-width: 0;
  }
  .ws-step-tool {
    display: none;
  }

  /* Output pane: maintain min-height but trim padding */
  .ws-output-wrap   { min-height: 160px; }
  .ws-output-head   { padding: 0.45rem 0.7rem; }
  .ws-output-label  { font-size: 0.65rem; }
  .ws-output        {
    padding: 0.8rem 1rem;
    font-size: 0.92rem;
    /* Mobile Safari/Chrome hide overlay scrollbars by default even when
       content overflows. Force `scroll` (not `auto`) and explicitly opt
       into a custom thumb so the bar stays visible — otherwise the user
       can't tell the pane is scrollable. */
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(251, 191, 36, 0.7) transparent;
  }
  .ws-output::-webkit-scrollbar {
    -webkit-appearance: none;
    display: block;
    width: 10px;
    background: rgba(255, 255, 255, 0.04);
  }
  .ws-output::-webkit-scrollbar-thumb {
    background: rgba(251, 191, 36, 0.7);
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
  }
}

/* Two-column step nodes on small-but-not-tiny screens (e.g. tablets) */
@media (min-width: 540px) and (max-width: 720px) {
  .ws-steps { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════════════════════════════════════
 * AI-AGENT BIRTH OVERLAY — full-screen "specialist being born" theatre
 * Mirrors the Maestro panel's birth overlay (templates/partials/_maestro_panel.html
 * ≈line 1556). Self-contained: workflow-stage.js injects .ws-birth-overlay
 * into <body> when forge_proposed fires; removes on forge_complete (or
 * watchdog).
 * ═══════════════════════════════════════════════════════════════════════ */
@keyframes ws-birth-orbit  { 0% { transform: rotate(0deg) translateX(112px) rotate(0deg); opacity: 0.55; } 100% { transform: rotate(360deg) translateX(112px) rotate(-360deg); opacity: 0.55; } }
@keyframes ws-birth-pulse  { 0%, 100% { transform: scale(1); box-shadow: 0 0 50px rgba(251,191,36,0.55), inset 0 0 32px rgba(167,139,250,0.35); } 50% { transform: scale(1.06); box-shadow: 0 0 90px rgba(251,191,36,0.85), inset 0 0 50px rgba(167,139,250,0.55); } }
@keyframes ws-birth-rise   { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ws-birth-shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

.ws-birth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.ws-birth-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(6px);
}
.ws-birth-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at top, rgba(76,29,149,0.45) 0%, rgba(20,15,40,0.96) 55%, rgba(8,14,26,0.99) 100%);
  border: 1px solid rgba(167, 139, 250, 0.32);
  box-shadow: 0 30px 100px rgba(0,0,0,0.7), 0 0 80px rgba(251,191,36,0.12), inset 0 1px 0 rgba(255,255,255,0.06);
}
.ws-birth-rise { animation: ws-birth-rise 0.5s ease-out both; }
.ws-birth-accent {
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, transparent, #fbbf24, #a78bfa, #fbbf24, transparent);
  flex-shrink: 0;
}
.ws-birth-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #9ca3af;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  transition: color 0.15s ease;
  display: inline-flex;
}
.ws-birth-close:hover { color: #fbbf24; }
.ws-birth-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 28px 26px 26px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.ws-birth-orbwrap {
  position: relative;
  width: 220px;
  height: 220px;
  flex-shrink: 0;
}
.ws-birth-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  left: 50%;
  top: 50%;
  margin: -3px 0 0 -3px;
  animation: ws-birth-orbit 6s linear infinite;
}
.ws-birth-orb {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fde68a 0%, #fbbf24 35%, #a78bfa 75%, #4c1d95 100%);
  opacity: 0.35;
  filter: blur(2px);
  animation: ws-birth-pulse 2.4s ease-in-out infinite;
}
.ws-birth-photo {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(251, 191, 36, 0.55);
  box-shadow: 0 0 50px rgba(251,191,36,0.55), 0 0 90px rgba(167,139,250,0.35), inset 0 0 30px rgba(251,191,36,0.18);
}
.ws-birth-sparkle {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fde68a 0%, #fbbf24 35%, #a78bfa 75%, #4c1d95 100%);
  box-shadow: 0 0 60px rgba(251, 191, 36, 0.7);
  font-size: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 16px rgba(255, 255, 255, 0.7));
}
.ws-birth-status {
  width: 100%;
  margin: 20px 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(8, 14, 26, 0.55);
  border: 1px solid rgba(167, 139, 250, 0.35);
  backdrop-filter: blur(4px);
  box-shadow: 0 0 30px rgba(167, 139, 250, 0.08);
}
.ws-birth-status-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #a78bfa;
  margin-bottom: 10px;
}
.ws-birth-status-eyebrow.is-complete { color: #34d399; }
.ws-birth-phase {
  font-size: 0.9rem;
  font-weight: 500;
  color: #fbbf24;
  min-height: 1.6em;
  margin-bottom: 12px;
}
.ws-birth-progress {
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}
.ws-birth-progress-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background-image: linear-gradient(90deg, rgba(251,191,36,0.15) 0%, rgba(251,191,36,0.85) 50%, rgba(251,191,36,0.15) 100%);
  background-size: 200% 100%;
  animation: ws-birth-shimmer 1.6s linear infinite;
}
.ws-birth-progress-fill.is-complete {
  background: #34d399;
  animation: none;
}
.ws-birth-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
  line-height: 1.12;
  background: linear-gradient(90deg, #fbbf24 0%, #a78bfa 50%, #fbbf24 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}
.ws-birth-lore {
  font-size: 0.9rem;
  color: #e0e7ff;
  line-height: 1.55;
  margin: 0 0 4px;
}
.ws-birth-toolname {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.15;
  color: #fbbf24;
  text-shadow: 0 0 14px rgba(251,191,36,0.45), 0 0 30px rgba(167,139,250,0.25);
  margin: 8px 0 4px;
  word-break: break-word;
}
.ws-birth-qa {
  font-size: 10.5px;
  color: #6b7280;
  line-height: 1.5;
  max-width: 320px;
  margin: 14px auto 0;
}
.ws-birth-continue {
  margin-top: 18px;
  padding: 12px 22px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  color: #0c1628;
  background: linear-gradient(135deg, #fbbf24, #a78bfa);
  box-shadow: 0 8px 24px rgba(251, 191, 36, 0.25);
  font-family: inherit;
}
.ws-birth-continue:hover { filter: brightness(1.05); }

@media (max-width: 540px) {
  .ws-birth-overlay { padding: 0; }
  .ws-birth-card { max-width: none; max-height: 100vh; height: 100%; border-radius: 0; }
  .ws-birth-title { font-size: 26px; }
}

/* ── LLM Usage chip strip (master plan Chunk 7) ─────────────────────── */
/* Rendered above #ws-output during the live-streaming step. */
#ws-output-chips {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 16px 6px 16px;
  background: linear-gradient(180deg, rgba(2,8,16,0.96) 0%, rgba(2,8,16,0.92) 80%, rgba(2,8,16,0.0) 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#ws-output-chips[hidden] { display: none !important; }
#ws-output-chips .ws-chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  font-family: 'Space Mono', ui-monospace, monospace;
}
#ws-output-chips .ws-chip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: rgba(251, 191, 36, 0.05);
  border: 1px solid rgba(251, 191, 36, 0.22);
  border-radius: 7px;
  min-width: 0;
}
#ws-output-chips .ws-chip-label {
  font-size: 11px;
  letter-spacing: 0.07em;
  color: rgba(251, 191, 36, 0.75);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#ws-output-chips .ws-chip-value {
  font-size: 16px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.94);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#ws-output-chips .ws-chip:nth-child(1) .ws-chip-label { color: rgba(167, 139, 250, 0.75); }
#ws-output-chips .ws-chip:nth-child(2) .ws-chip-label { color: rgba(34, 211, 238, 0.75); }
#ws-output-chips .ws-chip:nth-child(3) .ws-chip-label { color: rgba(251, 191, 36, 0.75); }
#ws-output-chips .ws-chip:nth-child(4) .ws-chip-label { color: rgba(52, 211, 153, 0.75); }

/* Default desktop behaviour: show the full step name, hide the short one.
   The mobile media query below FLIPS this — full hidden, short visible.
   Order matters: this rule MUST come BEFORE the @media block so the
   media-query rule wins (same specificity, later source = later wins). */
.ws-step-name-full  { display: inline !important; }
.ws-step-name-short { display: none    !important; }

@media (max-width: 640px) {
  /* Mobile-only: all 4 chips in a single row to save vertical space. */
  #ws-output-chips { padding: 8px 12px 4px 12px; }
  #ws-output-chips .ws-chips { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  #ws-output-chips .ws-chip { padding: 6px 7px; gap: 2px; border-radius: 5px; }
  #ws-output-chips .ws-chip-label { font-size: 8px; letter-spacing: 0.04em; }
  #ws-output-chips .ws-chip-value { font-size: 12px; line-height: 1.15; }

  /* Mobile-only: workflow steps go from full-width stacked cards to a
     compact 3-per-row grid so the user can see more of the symphony at
     once and the response area gets more screen real estate. */
  .ws-steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
  }
  .ws-step {
    padding: 0.55rem 0.4rem 0.5rem;
    border-radius: 9px;
  }
  .ws-step-number {
    width: 18px;
    height: 18px;
    top: -6px;
    left: -6px;
    font-size: 0.6rem;
  }
  .ws-step-icon {
    font-size: 1rem;
    margin-bottom: 0.2rem;
  }
  .ws-step-name {
    font-size: 0.72rem;
    margin-bottom: 0;
  }
  .ws-step-tool { display: none; }  /* hide the tool name on mobile */
  /* Show only the first word of the step name (set by JS into
     .ws-step-name-short); hide the full name. */
  .ws-step-name-full  { display: none   !important; }
  .ws-step-name-short { display: inline !important; }
}
