/* Workflow Mode — matches app tokens */

/* Hide chat header chrome in workflow editor/gallery. Play mode shows the bar
   (workflow-play-header-bar) so Gallery/Run/etc. live where chat actions usually are. */
.main-header.workflow-mode-header:not(.workflow-play-header-bar) {
    display: none;
}

.left-sidebar.collapsed ~ .main-content .main-header.workflow-mode-header:not(.workflow-play-header-bar) {
    display: flex !important;
    min-height: 38px;
    padding: 2px 16px;
}

.left-sidebar.collapsed ~ .main-content .main-header.workflow-mode-header:not(.workflow-play-header-bar) .model-selector-header,
.left-sidebar.collapsed ~ .main-content .main-header.workflow-mode-header:not(.workflow-play-header-bar) .main-header-icons {
    display: none !important;
}

.main-header.workflow-mode-header.workflow-play-header-bar {
    display: flex !important;
}

.main-header.workflow-play-header-bar .main-header-left {
    flex: 1;
    min-width: 0;
}

.main-header.workflow-play-header-bar .model-selector-header {
    display: none !important;
}

.workflow-play-header-title {
    display: none;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    margin: 0 8px;
}

.main-header.workflow-play-header-bar .workflow-play-header-title:not([hidden]) {
    display: inline-flex;
}

.workflow-play-header-title h2 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(100%, 520px);
}

.main-header.workflow-play-header-bar .main-header-icons-scroll > :not(#workflowPlayHeaderActions),
.main-header.workflow-play-header-bar .main-header-icons-pinned {
    display: none !important;
}

.workflow-play-header-actions {
    display: none;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    margin-left: auto;
}

.main-header.workflow-play-header-bar .workflow-play-header-actions {
    display: inline-flex;
}

.main-header.workflow-play-header-bar .workflow-play-header-actions[hidden] {
    display: none !important;
}

.main-header.workflow-play-header-bar .workflow-play-header-actions .workflow-toolbar-btn {
    min-height: 30px;
}

.workflow-container {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: var(--bg-main);
    color: var(--text-primary);
}

.workflow-editor-header {
    flex: none;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-panel);
}

.workflow-title-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 14px 4px;
    min-width: 0;
}

.workflow-name-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    width: 100%;
}

.workflow-desc-row {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
}

.workflow-name-display {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 600;
    font-family: inherit;
    padding: 2px 4px;
    margin: 0;
    border-radius: 6px;
    cursor: text;
    text-align: center;
    min-width: 0;
    max-width: min(100%, 520px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.workflow-name-display:hover:not(:disabled) {
    background: var(--bg-hover, rgba(15, 23, 42, 0.05));
}

.workflow-name-display:disabled {
    cursor: default;
    opacity: 0.85;
}

.workflow-name-input {
    border: 1px solid var(--blue-accent);
    border-radius: 6px;
    padding: 2px 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.3;
    text-align: center;
    flex: 0 1 420px;
    min-width: 160px;
    max-width: 520px;
    width: min(100%, 420px);
    outline: none;
    box-shadow: 0 0 0 2px rgba(3, 105, 161, 0.15);
}

.workflow-name-row.is-editing .workflow-name-display {
    display: none;
}

.workflow-name-row.is-editing .workflow-name-input {
    display: block;
}

.workflow-name-input[hidden] {
    display: none !important;
}

.workflow-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 14px 8px;
    flex-wrap: nowrap;
}

.workflow-toolbar-start,
.workflow-toolbar-end {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    flex-wrap: wrap;
}

.workflow-toolbar-start {
    flex: 1 1 auto;
    justify-content: flex-start;
}

.workflow-toolbar-end {
    flex: 0 0 auto;
    margin-left: auto;
    justify-content: flex-end;
}

.workflow-toolbar-btn {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 7px;
    padding: 5px 9px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    flex: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.workflow-toolbar-icon-btn {
    padding: 6px;
    min-width: 30px;
    min-height: 30px;
    justify-content: center;
}

.workflow-toolbar-btn svg {
    flex: none;
    opacity: 0.85;
}

.workflow-toolbar-btn:hover {
    background: var(--bg-hover, rgba(15, 23, 42, 0.05));
    color: var(--text-primary);
    border-color: transparent;
}

.workflow-toolbar-btn:hover svg {
    opacity: 1;
}

.workflow-toolbar-btn.workflow-run-btn {
    color: var(--blue-accent);
}

.workflow-toolbar-btn.workflow-run-btn:hover {
    background: rgba(3, 105, 161, 0.1);
    color: var(--blue-accent);
}

.workflow-toolbar-btn.primary {
    background: rgba(3, 105, 161, 0.1);
    color: var(--blue-accent);
    border-color: transparent;
}

.workflow-toolbar-btn.primary:hover {
    background: rgba(3, 105, 161, 0.16);
    color: var(--blue-accent);
}

.workflow-toolbar-btn.danger {
    background: transparent;
    color: var(--status-danger-fg);
    border-color: transparent;
}

.workflow-toolbar-btn.danger:hover {
    background: var(--status-danger-bg);
    color: var(--status-danger-fg);
}

.workflow-body {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
}

/* Shown only below the drawer breakpoint (inspector). */
.workflow-drawer-toggle {
    display: none;
}

.workflow-drawer-scrim {
    display: none;
}

.workflow-canvas-wrap {
    flex: 1;
    /* Never let the inspector squeeze the canvas away on narrow screens. */
    min-width: 240px;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 1px 1px, var(--border-color) 1px, transparent 0) 0 0 / 20px 20px;
}

.workflow-canvas-surface {
    position: absolute;
    inset: 0;
    transform-origin: 0 0;
}

.workflow-edges {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.workflow-edge-group {
    pointer-events: stroke;
}

.workflow-edge-stroke {
    fill: none;
    stroke: var(--blue-accent);
    stroke-width: 2;
    pointer-events: none;
}

.workflow-edge-hit {
    fill: none;
    stroke: transparent;
    stroke-width: 14;
    pointer-events: stroke;
    cursor: pointer;
}

.workflow-edge-group:hover .workflow-edge-stroke,
.workflow-edge-hit.selected + .workflow-edge-stroke {
    stroke-width: 2.5;
    stroke: #1d4ed8;
}

.workflow-edge-delete {
    display: none;
    pointer-events: all;
    cursor: pointer;
}

.workflow-edge-group:hover .workflow-edge-delete,
.workflow-edge-hit.selected ~ .workflow-edge-delete {
    display: block;
}

.workflow-edge-delete circle {
    fill: #fff;
    stroke: var(--status-danger-fg, #b91c1c);
    stroke-width: 1.5;
}

.workflow-edge-delete text {
    fill: var(--status-danger-fg, #b91c1c);
    font-size: 12px;
    font-weight: 700;
    pointer-events: none;
    user-select: none;
}

.workflow-edges path.workflow-edge-temp {
    fill: none;
    stroke: var(--blue-accent);
    stroke-width: 2;
    stroke-dasharray: 4 4;
    opacity: 0.7;
    pointer-events: none;
}

.workflow-zoom-controls {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 5;
    display: flex;
    gap: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.workflow-pointer-tools {
    display: flex;
    gap: 4px;
    padding-right: 4px;
    margin-right: 2px;
    border-right: 1px solid var(--border-color);
}

.workflow-pointer-tools[hidden] {
    display: none;
}

.workflow-zoom-controls button {
    min-width: 32px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
}

.workflow-zoom-controls button:hover {
    background: var(--bg-input);
}

.workflow-zoom-controls button.is-active {
    background: var(--bg-input);
    color: var(--blue-accent);
}

.workflow-zoom-controls button svg {
    display: block;
    margin: 0 auto;
}

.workflow-nodes-layer {
    pointer-events: none;
}

.workflow-node {
    position: absolute;
    width: 200px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    cursor: grab;
    user-select: none;
    pointer-events: auto;
}

.workflow-node.selected {
    border-color: var(--blue-accent);
    box-shadow: 0 0 0 2px rgba(3, 105, 161, 0.15);
}

.workflow-marquee {
    position: absolute;
    z-index: 8;
    pointer-events: none;
    border: 1px solid var(--blue-accent);
    background: rgba(3, 105, 161, 0.12);
    border-radius: 2px;
}

.workflow-canvas-wrap.is-pan-tool {
    cursor: grab;
}

.workflow-canvas-wrap.is-space-pan,
.workflow-canvas-wrap.is-space-pan .workflow-node {
    cursor: grab;
}

.workflow-canvas-wrap.is-panning,
.workflow-canvas-wrap.is-panning .workflow-node {
    cursor: grabbing;
}

.workflow-node.running {
    border-color: var(--gemini-blue);
}

.workflow-node.stream_taken_over {
    border-color: var(--border-color);
    opacity: 0.72;
}

.workflow-node.completed {
    border-color: var(--status-success-fg);
}

.workflow-node.failed {
    border-color: var(--status-danger-fg);
}

.workflow-node.skipped {
    opacity: 0.55;
}

.workflow-node-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 4px 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 600;
}

.workflow-node-title-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    flex: 1;
}

.workflow-node-title {
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workflow-hosting-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 11px;
    height: 11px;
    color: color-mix(in srgb, var(--text-secondary) 45%, transparent);
}

.workflow-hosting-icon svg {
    width: 11px;
    height: 11px;
    display: block;
}

.workflow-node-type {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.workflow-node-status {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--bg-input);
    color: var(--text-secondary);
}

.workflow-node-status.is-running { background: #e0f2fe; color: #0369a1; }
.workflow-node-status.is-stream_taken_over { background: var(--bg-input); color: var(--text-secondary); }
.workflow-node-status.is-completed { background: var(--status-success-bg); color: var(--status-success-fg); }
.workflow-node-status.is-failed,
.workflow-node-status.is-cancelled { background: var(--status-danger-bg); color: var(--status-danger-fg); }
.workflow-node-status.is-paused { background: #fef3c7; color: #92400e; }
.workflow-node-status.is-skipped { background: var(--bg-input); color: var(--text-secondary); }

.workflow-node-subtitle {
    padding: 8px 10px 10px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workflow-node-body {
    padding: 8px 10px 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.workflow-port.missing {
    color: var(--status-danger-fg, #b91c1c);
    font-weight: 600;
}

.workflow-port.missing .workflow-port-dot {
    box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.35);
}

.workflow-ports {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
}

.workflow-port-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.workflow-port {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
}

.workflow-port.out {
    flex-direction: row-reverse;
}

.workflow-port-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--blue-accent);
    background: var(--bg-panel);
    cursor: crosshair;
}

.workflow-port-dot.text { border-color: #0369a1; }
.workflow-port-dot.image { border-color: #7c3aed; }
.workflow-port-dot.document,
.workflow-port-dot.documents { border-color: #059669; }
.workflow-port-dot.audio { border-color: #d97706; }

.workflow-node-context-menu {
    position: fixed;
    z-index: 10000;
    min-width: 140px;
    padding: 4px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-panel);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.workflow-node-context-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
}

.workflow-node-context-item:hover {
    background: var(--bg-hover);
}

.workflow-node-context-item.is-danger {
    color: var(--status-danger-fg);
}

.workflow-node-context-item.is-danger:hover {
    background: var(--status-danger-bg);
}

.workflow-side {
    width: 420px;
    flex: none;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-color);
    background: var(--bg-panel);
    padding: 12px;
    overflow: hidden;
    font-size: 0.85rem;
    box-sizing: border-box;
}

.workflow-side-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.workflow-side-footer {
    flex: none;
    display: flex;
    justify-content: center;
    padding-top: 16px;
    margin-top: auto;
}

.workflow-side[hidden] {
    display: none !important;
}

.workflow-inspector-resize {
    display: none;
    width: 6px;
    margin-left: -3px;
    margin-right: -3px;
    flex: none;
    align-self: stretch;
    cursor: col-resize;
    position: relative;
    z-index: 5;
    background: transparent;
    touch-action: none;
}

.workflow-inspector-resize:not([hidden]) {
    display: block;
}

.workflow-inspector-resize::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    transform: translateX(-50%);
    background: transparent;
}

.workflow-inspector-resize:hover,
body.resizing-workflow-inspector .workflow-inspector-resize {
    background: rgba(148, 163, 184, 0.12);
}

.workflow-inspector-resize:hover::after,
body.resizing-workflow-inspector .workflow-inspector-resize::after {
    background: #94a3b8;
}

body.resizing-workflow-inspector {
    cursor: col-resize;
    user-select: none;
}

body.resizing-workflow-inspector .workflow-side {
    transition: none;
}

.workflow-side h3 {
    margin: 0 0 10px;
    font-size: 0.95rem;
}

.workflow-hint,
.workflow-edge-editor-copy {
    margin: 0 0 10px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Match settings-panel breathing room (.setting-item / .setting-label). */
.workflow-side label {
    display: block;
    margin: 16px 0 8px;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.workflow-side input:not([type="checkbox"]),
.workflow-side select,
.workflow-side textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    box-sizing: border-box;
}

.workflow-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 16px 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.workflow-tools-list .workflow-toggle-row {
    margin: 8px 0;
}

.workflow-toggle-switch.toggle-switch {
    width: 32px;
    height: 18px;
    border-radius: 9px;
    flex-shrink: 0;
}

.workflow-toggle-switch.toggle-switch::after {
    width: 14px;
    height: 14px;
    top: 1px;
    left: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.workflow-toggle-switch.toggle-switch.active::after {
    transform: translateX(12px);
}

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

.workflow-run-log {
    margin-top: 12px;
    max-height: 220px;
    overflow-y: auto;
    background: var(--bg-hover);
    border-radius: 8px;
    padding: 8px;
    font-size: 0.75rem;
    white-space: pre-wrap;
}

.workflow-status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.workflow-status-pill.creating,
.workflow-status-pill.running { background: #e0f2fe; color: #0369a1; }
.workflow-status-pill.completed { background: var(--status-success-bg); color: var(--status-success-fg); }
.workflow-status-pill.failed,
.workflow-status-pill.interrupted,
.workflow-status-pill.cancelled { background: var(--status-danger-bg); color: var(--status-danger-fg); }
.workflow-status-pill.skipped,
.workflow-status-pill.stream_taken_over { background: var(--bg-input); color: var(--text-secondary); }

.workflow-gallery {
    padding: 24px;
    overflow-y: auto;
    background-color: var(--bg-main);
    flex: 1;
}

.workflow-gallery-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    position: relative;
}

.workflow-gallery-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-align: center;
}

.workflow-gallery-subtitle {
    margin: 0 0 24px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.workflow-gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #999;
}

/* Reuse Custom AI card chrome; keep a light pointer affordance */
.workflow-card.custom-ai-card {
    cursor: pointer;
}

.workflow-card .custom-ai-card-content {
    gap: 12px;
}

.workflow-card-ports {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    margin-top: 2px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.workflow-card-ports .workflow-port-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.workflow-card-ports .workflow-port-col:last-child {
    align-items: flex-end;
}

.workflow-card-ports .workflow-port {
    font-size: 0.75rem;
    color: var(--text-secondary);
    pointer-events: none;
}

.workflow-card-port-empty {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Ask-question pause overlay (Phase 7) */
.workflow-ask-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 45;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: auto;
}

.workflow-side {
    position: relative;
}

.workflow-ask-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.workflow-ask-card h3 {
    margin: 0 0 6px;
    font-size: 1rem;
}

.workflow-ask-hint {
    margin: 0 0 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.workflow-ask-block {
    margin-bottom: 12px;
}

.workflow-ask-q {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.workflow-ask-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.workflow-ask-option {
    text-align: left;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 0.85rem;
}

.workflow-ask-option.selected,
.workflow-ask-option:hover {
    border-color: var(--blue-accent);
    background: #e0f2fe;
}

.workflow-ask-other {
    margin-top: 8px;
}

.workflow-ask-other input {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.workflow-ask-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

.workflow-node.paused {
    outline: 2px solid #f59e0b;
}

.workflow-status-pill.paused {
    background: #fef3c7;
    color: #92400e;
}

.workflow-status-pill.stopped,
.workflow-status-pill.stopping {
    background: #e0e7ff;
    color: #3730a3;
}

.workflow-stopping-banner {
    margin: 8px 12px 0;
    padding: 8px 12px;
    border-radius: 8px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 13px;
}

.workflow-play-stage-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    /* Match .workflow-input-payload-meta horizontal inset so Done lines up with Output. */
    padding-right: 14px;
}

.workflow-play-stage-head-start {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.workflow-play-stage-title-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.workflow-play-stage-title-group .workflow-hosting-icon {
    width: 12px;
    height: 12px;
}

.workflow-play-stage-title-group .workflow-hosting-icon svg {
    width: 12px;
    height: 12px;
}

.workflow-play-stage-head-start h4 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Play dashboard: Done is a quiet label, not a green pill. */
.workflow-play-stage-head .workflow-node-status.is-completed {
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-secondary, #64748b);
    font-weight: 700;
}

.workflow-play-rerun-btn {
    margin: 0;
    padding: 2px 4px;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.2;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.workflow-play-rerun-btn:hover {
    color: var(--text-primary, #0f172a);
    background: color-mix(in srgb, var(--text-secondary) 12%, transparent);
}

.workflow-pass-warn {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 12px;
}

.workflow-help {
    margin: 6px 0 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary);
    opacity: 0.95;
}

.workflow-condition-outcomes {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--text-secondary) 8%, transparent);
    font-size: 12px;
    color: var(--text-secondary);
}

.workflow-condition-outcomes-title {
    font-weight: 600;
    color: var(--text-primary, #0f172a);
    margin-bottom: 6px;
}

.workflow-condition-outcomes ul,
.workflow-condition-checklist {
    margin: 0;
    padding-left: 1.1rem;
}

.workflow-condition-outcomes li + li,
.workflow-condition-checklist li + li {
    margin-top: 4px;
}

.workflow-condition-routes {
    display: grid;
    gap: 6px;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--text-secondary) 8%, transparent);
}

.workflow-condition-route {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 12px;
    line-height: 1.35;
    color: var(--text-secondary);
}

.workflow-condition-route-name {
    flex: 0 0 auto;
    min-width: 4.75rem;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
}

.workflow-condition-route-desc {
    flex: 1 1 auto;
}

.workflow-condition-checklist {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    list-style: none;
    padding-left: 0;
}

.workflow-condition-checklist .is-done {
    color: #166534;
}

.workflow-condition-preview {
    margin: 12px 0 0;
    padding: 8px 10px;
    border-radius: 8px;
    background: color-mix(in srgb, #2563eb 8%, transparent);
    color: var(--text-primary, #0f172a);
    font-size: 12px;
    line-height: 1.45;
}

.workflow-condition-sample-result {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.workflow-condition-sample-result.is-yes {
    color: #166534;
    font-weight: 600;
}

.workflow-condition-sample-result.is-no {
    color: #9a3412;
    font-weight: 600;
}

.workflow-pass-warn p {
    margin: 0 0 6px;
}

.workflow-pass-warn p:last-child {
    margin-bottom: 0;
}

.workflow-run-cost {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Narrow screens: inspector becomes a drawer over the canvas. */
@media (max-width: 960px) {
    .workflow-drawer-toggle {
        display: inline-flex;
    }

    .workflow-side {
        position: absolute;
        top: 0;
        bottom: 0;
        right: 0;
        z-index: 30;
        box-shadow: 0 0 24px rgba(15, 23, 42, 0.18);
        transition: transform 0.2s ease;
        transform: translateX(100%);
    }

    .workflow-inspector-resize {
        position: absolute;
        top: 0;
        bottom: 0;
        z-index: 31;
    }

    .workflow-body.inspector-open .workflow-side {
        transform: translateX(0);
    }

    .workflow-body.inspector-open .workflow-inspector-resize:not([hidden]) {
        /* Sit on the open drawer's left edge. */
        right: var(--workflow-inspector-width, 420px);
    }

    .workflow-body.inspector-open .workflow-drawer-scrim {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 25;
        background: rgba(15, 23, 42, 0.25);
    }

    .workflow-toolbar {
        flex-wrap: wrap;
    }

    .workflow-toolbar-end {
        margin-left: auto;
    }

    .workflow-name-input {
        max-width: none;
        width: min(100%, 360px);
    }

    .workflow-desc-edit {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .workflow-side {
        width: min(420px, 85vw);
    }
}

/* Add Module modal */
.modal-content.workflow-modules-modal-content {
    max-width: 720px;
}

.workflow-module-group {
    margin-bottom: 22px;
}

.workflow-module-group:last-child {
    margin-bottom: 0;
}

.workflow-module-group-title {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.workflow-module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.workflow-module-tile {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-panel);
    color: var(--text-primary);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.workflow-module-tile:hover {
    border-color: var(--blue-accent);
    background: var(--bg-hover);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

.workflow-module-tile:active {
    background: var(--bg-button);
}

.workflow-module-tile-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-button);
    color: var(--blue-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.workflow-module-tile-icon svg {
    width: 18px;
    height: 18px;
}

.workflow-module-tile-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.workflow-module-tile-label {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

.workflow-module-tile-blurb {
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    color: var(--text-secondary);
}

#workflowModulesBtn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.workflow-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%) translateY(12px);
    z-index: 10000;
    max-width: min(420px, 90vw);
    padding: 10px 14px;
    border-radius: 10px;
    background: #0f172a;
    color: #fff;
    font-size: 0.85rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
}

.workflow-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.workflow-toast.is-error { background: #991b1b; }
.workflow-toast.is-warn { background: #92400e; }

.workflow-dirty-dot {
    display: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    margin-left: 4px;
    flex: none;
}

.workflow-dirty-dot.is-dirty {
    display: inline-block;
}

.workflow-toolbar-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.workflow-connection-hint {
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translateX(-50%);
    z-index: 6;
    max-width: min(420px, 90%);
    padding: 8px 12px;
    border-radius: 8px;
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fdba74;
    font-size: 0.8rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
    pointer-events: none;
}

.workflow-media-preview {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.workflow-media-preview audio,
.workflow-media-preview img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.workflow-media-preview a {
    font-size: 0.75rem;
    color: var(--blue-accent);
}

.workflow-agent-event {
    margin-top: 4px;
    padding: 4px 6px;
    border-left: 3px solid #93c5fd;
    background: #f0f9ff;
    font-size: 0.72rem;
    color: #075985;
    white-space: pre-wrap;
}

.workflow-tools-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.workflow-meta-row,
.workflow-desc-edit {
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    min-width: 0;
    max-width: min(100%, 720px);
    width: min(100%, 720px);
    justify-content: center;
}

.workflow-desc-display {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: inherit;
    padding: 2px 4px;
    margin: 0;
    border-radius: 6px;
    cursor: text;
    text-align: center;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    white-space: pre-line;
    line-height: 1.4;
    max-height: calc(1.4em * 2);
}

.workflow-desc-display:not(.is-placeholder) {
    color: var(--text-primary);
}

.workflow-desc-display.is-placeholder {
    font-style: italic;
    opacity: 0.75;
}

.workflow-desc-display:hover:not(:disabled) {
    background: var(--bg-hover, rgba(15, 23, 42, 0.05));
}

.workflow-desc-display:disabled {
    cursor: default;
}

.workflow-desc-input {
    border: 1px solid var(--blue-accent);
    border-radius: 6px;
    padding: 6px 10px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    text-align: center;
    width: 100%;
    min-width: 240px;
    min-height: calc(1.4em * 2 + 14px);
    resize: vertical;
    outline: none;
    box-shadow: 0 0 0 2px rgba(3, 105, 161, 0.12);
    line-height: 1.4;
}

.workflow-desc-edit.is-editing .workflow-desc-display {
    display: none;
}

.workflow-desc-edit.is-editing .workflow-desc-input {
    display: block;
}

.workflow-desc-input[hidden] {
    display: none !important;
}

.workflow-toolbar-end .workflow-toolbar-icon-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.workflow-readonly-banner {
    margin: 0 12px 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 0.8rem;
}

/* Gallery cards: don't inherit Custom AI tall min-height */
.workflow-card.custom-ai-card {
    min-height: 0;
}

.workflow-card .custom-ai-card-content {
    gap: 6px;
}

.workflow-card .custom-ai-title {
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    word-break: break-word;
}

.workflow-canvas-host {
    flex: 1;
    min-width: 240px;
    min-height: 0;
    display: flex;
    position: relative;
}

.workflow-canvas-host > .workflow-canvas-wrap {
    flex: 1;
    width: 100%;
    height: 100%;
    min-width: 0;
}

.workflow-canvas-empty-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.workflow-canvas-empty-hint[hidden] {
    display: none !important;
}

.workflow-play-extract-pre {
    margin: 0;
    white-space: pre-wrap;
    overflow: auto;
    max-height: 28rem;
    font-size: 0.85em;
}

.workflow-canvas-wrap.is-play-detail .workflow-node {
    min-width: 140px;
}

/* Play mode shell — Run panel is a flex sibling of .main-content (like settings). */
.workflow-play-view {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: var(--bg-main);
}

.workflow-play-primary {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.workflow-play-dashboard-head {
    display: none;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex: none;
    grid-template-columns: 1fr auto 1fr;
}

.workflow-play-dashboard-head:not([hidden]) {
    display: grid;
}

.workflow-play-dashboard-head h3 {
    margin: 0;
    font-size: 1rem;
    grid-column: 2;
    justify-self: center;
    text-align: center;
}

.workflow-play-dashboard-head-end {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: none;
    grid-column: 3;
    justify-self: end;
}

.workflow-play-draft-badge {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fff7ed;
    color: #9a3412;
    flex: none;
}

.workflow-play-toolbar {
    justify-content: space-between;
}

.workflow-play-cost {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.workflow-play-body {
    flex: 1;
    min-height: 0;
    display: flex;
    position: relative;
}

.workflow-play-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: auto;
    padding: 16px 18px 24px;
}

/* Pre-run Play: canvas fills the body; ask form (if any) sits above it. */
.workflow-play-body.is-pre-run .workflow-play-main {
    padding: 0;
    overflow: hidden;
}

.workflow-play-body.is-pre-run .workflow-play-ask-wrap {
    padding: 12px 18px 0;
    margin-bottom: 0;
}

.workflow-canvas-host-play-inline {
    flex: 1;
    min-height: 0;
    position: relative;
    display: none;
}

.workflow-play-body.is-pre-run .workflow-canvas-host-play-inline {
    display: block;
}

.workflow-canvas-host-play-inline .workflow-canvas-wrap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.workflow-play-ask-wrap {
    flex: none;
    margin-bottom: 12px;
}

.workflow-play-ask {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--bg-panel);
}

.workflow-play-ask h3 {
    margin: 0 0 4px;
    font-size: 0.95rem;
}

.workflow-play-ask-hint {
    margin: 0 0 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.workflow-play-ask-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.workflow-play-ask-field textarea {
    font: inherit;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--bg-input);
    color: var(--text-primary);
    resize: vertical;
}

.workflow-play-ask-file {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.workflow-play-ask-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.workflow-play-ask-file-btn {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.workflow-play-ask-field:hover .workflow-play-ask-file-btn,
.workflow-play-ask-file:focus-within .workflow-play-ask-file-btn {
    border-color: var(--blue-accent, #0369a1);
    color: var(--blue-accent, #0369a1);
    background: rgba(3, 105, 161, 0.08);
}

.workflow-play-ask-file-name {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.workflow-play-viewer {
    flex: 1;
    min-height: 0;
}

.workflow-live-view-moved {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 14px;
    padding: 12px 14px;
    border: none;
    border-radius: 10px;
    background: color-mix(in srgb, #64748b 8%, var(--bg-panel));
    color: var(--text-primary);
}

.workflow-live-view-moved[hidden] {
    display: none;
}

.workflow-live-view-moved strong {
    display: block;
    font-size: 0.9rem;
}

.workflow-live-view-moved p {
    margin: 3px 0 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.35;
}

.workflow-live-view-moved-btn {
    flex: none;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--blue-accent, #0369a1);
    padding: 7px 10px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.workflow-live-view-moved-btn:hover:not(:disabled) {
    background: rgba(3, 105, 161, 0.08);
}

.workflow-live-view-moved-btn:disabled {
    cursor: wait;
    opacity: 0.7;
}

.workflow-play-viewer-empty,
.workflow-play-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.workflow-play-viewer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.workflow-play-viewer-head h3 {
    margin: 0;
    font-size: 1rem;
}

.workflow-play-viewer-title-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    max-width: 100%;
}

.workflow-play-viewer-title-group h3 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workflow-play-viewer-title-group .workflow-hosting-icon {
    width: 12px;
    height: 12px;
}

.workflow-play-viewer-title-group .workflow-hosting-icon svg {
    width: 12px;
    height: 12px;
}

.workflow-play-viewer-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.workflow-play-viewer-body.is-input {
    max-width: 720px;
}

.workflow-input-payload {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-panel);
    overflow: hidden;
}

/* Glow when an ask-at-play Input still needs a value for this run. */
.workflow-input-payload.is-awaiting-input,
.workflow-play-stage.is-awaiting-input .workflow-input-payload {
    border-color: color-mix(in srgb, var(--blue-accent, #0369a1) 60%, var(--border-color));
    box-shadow:
        0 0 0 2px color-mix(in srgb, var(--blue-accent, #0369a1) 28%, transparent),
        0 0 18px color-mix(in srgb, var(--blue-accent, #0369a1) 38%, transparent);
    animation: workflow-ask-glow 1.8s ease-in-out infinite;
}

@keyframes workflow-ask-glow {
    0%, 100% {
        box-shadow:
            0 0 0 2px color-mix(in srgb, var(--blue-accent, #0369a1) 22%, transparent),
            0 0 12px color-mix(in srgb, var(--blue-accent, #0369a1) 28%, transparent);
    }
    50% {
        box-shadow:
            0 0 0 3px color-mix(in srgb, var(--blue-accent, #0369a1) 35%, transparent),
            0 0 24px color-mix(in srgb, var(--blue-accent, #0369a1) 48%, transparent);
    }
}

/* Glow when a local STT/TTS/parser/LLM service is offline. */
.workflow-input-payload.is-service-unavailable,
.workflow-play-stage.is-service-unavailable .workflow-input-payload {
    border-color: color-mix(in srgb, var(--status-danger-fg, #b91c1c) 55%, var(--border-color));
    box-shadow:
        0 0 0 2px color-mix(in srgb, var(--status-danger-fg, #b91c1c) 24%, transparent),
        0 0 18px color-mix(in srgb, var(--status-danger-fg, #b91c1c) 32%, transparent);
    animation: workflow-service-unavailable-glow 1.8s ease-in-out infinite;
}

.workflow-input-payload-state.is-unavailable {
    color: var(--status-danger-fg, #b91c1c);
    font-weight: 600;
}

@keyframes workflow-service-unavailable-glow {
    0%, 100% {
        box-shadow:
            0 0 0 2px color-mix(in srgb, var(--status-danger-fg, #b91c1c) 18%, transparent),
            0 0 12px color-mix(in srgb, var(--status-danger-fg, #b91c1c) 24%, transparent);
    }
    50% {
        box-shadow:
            0 0 0 3px color-mix(in srgb, var(--status-danger-fg, #b91c1c) 32%, transparent),
            0 0 24px color-mix(in srgb, var(--status-danger-fg, #b91c1c) 42%, transparent);
    }
}

.workflow-input-ask-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.85rem;
}

.workflow-input-ask-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.workflow-input-ask-field textarea {
    font: inherit;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    background: var(--bg-input);
    color: var(--text-primary);
    resize: vertical;
    width: 100%;
    box-sizing: border-box;
}

.workflow-input-ask-field:hover .workflow-play-ask-file-btn,
.workflow-input-ask-field .workflow-play-ask-file:focus-within .workflow-play-ask-file-btn {
    border-color: var(--blue-accent, #0369a1);
    color: var(--blue-accent, #0369a1);
    background: rgba(3, 105, 161, 0.08);
}

.workflow-input-payload-meta {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--bg-input) 65%, var(--bg-panel));
}

.workflow-input-payload-meta-start {
    justify-self: start;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.workflow-input-payload-meta-center {
    justify-self: center;
    text-align: center;
}

.workflow-input-payload-meta-end {
    justify-self: end;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
}

.workflow-input-payload-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-transform: none;
    color: #0f172a;
    background: #e2e8f0;
}

.workflow-input-payload-badge.is-ready {
    background: var(--status-success-bg);
    color: var(--status-success-fg);
}

.workflow-input-payload-badge.is-muted {
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-color);
}

.workflow-input-payload-state {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.workflow-input-payload-body {
    padding: 14px 18px 14px 20px;
    overflow-x: auto;
}

.workflow-play-stage-chat {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.workflow-play-stage-speaker {
    display: flex;
    align-items: center;
    justify-content: center;
}

.workflow-play-stage-speaker-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.workflow-play-stage-chat .message-text {
    /* Match chat markdown; keep list markers inside the card. */
    overflow-wrap: break-word;
}

.workflow-play-stage-chat .message-text ol,
.workflow-play-stage-chat .message-text ul {
    list-style-position: outside;
    padding-left: 1.5em;
    margin-left: 0.15em;
}

.workflow-play-stage-chat .message-text li > p {
    display: inline;
    margin: 0;
}

.workflow-play-stage-chat .message-text li > p + p {
    display: block;
    margin-top: 0.45em;
}

.workflow-input-payload-text {
    white-space: pre-wrap;
    line-height: 1.55;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.workflow-input-payload-empty {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.45;
}

.workflow-input-payload-media {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.workflow-input-payload-media img {
    display: block;
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    border-radius: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
}

.workflow-input-payload-media audio {
    width: 100%;
}

.workflow-input-payload-file {
    display: flex;
    align-items: center;
    gap: 12px;
}

.workflow-input-payload-file-icon {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background:
        linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
    position: relative;
}

.workflow-input-payload-file-icon::after {
    content: '';
    position: absolute;
    inset: 10px 12px 10px 12px;
    border: 2px solid rgba(15, 23, 42, 0.45);
    border-radius: 2px;
}

.workflow-input-payload-file-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.workflow-input-payload-file-meta strong,
.workflow-input-payload-file-name {
    font-size: 0.9rem;
    color: var(--text-primary);
    word-break: break-word;
}

.workflow-input-payload-file-meta span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.workflow-input-payload-file a {
    flex: none;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--blue-accent, #0369a1);
    text-decoration: none;
}

.workflow-input-payload-file a:hover {
    text-decoration: underline;
}

.workflow-input-payload-pending {
    flex: none;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.workflow-play-message {
    max-width: 720px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
}

.workflow-play-message-content {
    white-space: normal;
    line-height: 1.5;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.workflow-play-viewer-body.is-chat {
    max-width: 820px;
}

.workflow-play-chat {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    /* Breathing room after the last bubble when scrolled to the end. */
    padding-bottom: 48px;
}

.workflow-play-chat .message-wrapper {
    max-width: 85%;
}

.workflow-play-chat .message-wrapper.agent-tool-call-row,
.workflow-play-chat .message-wrapper.agent-thinking-row {
    max-width: 100%;
}

.workflow-play-chat .message-content {
    max-width: 100%;
}

.workflow-play-warning {
    margin: 0 0 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: color-mix(in srgb, #f59e0b 12%, transparent);
    color: #92400e;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

.workflow-export-actions {
    margin-top: 12px;
}

.workflow-export-status {
    margin: 0 0 8px;
    font-size: 13px;
    opacity: 0.75;
}

.workflow-chat-settings {
    margin-top: 8px;
}

.workflow-chat-settings .setting-item {
    margin-bottom: 12px;
}

.workflow-chat-settings .setting-label {
    margin-bottom: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.workflow-side .workflow-chat-settings input[type="range"] {
    border: none;
    padding: 0;
    background: transparent;
    border-radius: 0;
}

.workflow-side .workflow-chat-settings .value-box {
    width: 64px;
    flex: none;
}

.workflow-side .workflow-chat-settings select {
    margin-top: 0;
}

.workflow-play-media {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
    max-width: 720px;
}

.workflow-play-media-img {
    max-width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.workflow-play-media-audio {
    width: 100%;
}

/* Sibling of .main-content in .app-container — mirrors .right-sidebar layout. */
.workflow-play-status-panel {
    width: 280px;
    flex-shrink: 0;
    order: 5;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-panel);
    padding: 10px 10px 16px;
    overflow: hidden;
    border-radius: 12px;
    margin: 8px;
    margin-left: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: width 0.3s ease, margin 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    box-sizing: border-box;
}

.workflow-play-status-panel.is-collapsed {
    width: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
}

.workflow-play-status-panel[hidden] {
    display: none !important;
}

#workflowPlayPanelBtn.is-active,
#workflowPlayDashboardBtn.is-active {
    background: color-mix(in srgb, var(--blue-accent, #0369a1) 12%, var(--bg-panel));
    border-color: color-mix(in srgb, var(--blue-accent, #0369a1) 35%, var(--border-color));
    color: var(--blue-accent, #0369a1);
}

/* Same section divider pattern as chat settings (.setting-group). */
.workflow-play-status-section {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.workflow-play-status-section-label {
    margin: 12px 2px 2px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.workflow-play-status-views {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.workflow-play-view-row {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
}

.workflow-play-view-row .workflow-play-status-label {
    font-weight: 700;
}

.workflow-play-dashboard-row .workflow-play-status-label {
    font-weight: 700;
}

.workflow-play-flow-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    opacity: 0.7;
    line-height: 0;
    pointer-events: none;
}

.workflow-play-flow-arrow svg {
    display: block;
}

.workflow-play-status-list .workflow-play-flow-arrow {
    margin: 0;
    padding: 2px 0;
}

.workflow-play-dashboard .workflow-play-flow-arrow {
    margin: -4px 0;
    padding: 2px 0;
}

.workflow-play-dashboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 820px;
    padding-bottom: 48px;
}

.workflow-play-stage {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.workflow-play-stage.is-collapsible:not(.is-expanded) {
    cursor: pointer;
}

.workflow-play-stage.is-collapsible:not(.is-expanded) .workflow-input-payload-body {
    /* Match roughly one Input card body (~few rows), like agent doc previews. */
    max-height: 9em;
    overflow: hidden;
    position: relative;
}

.workflow-play-stage.is-collapsible:not(.is-expanded) .workflow-input-payload-body::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2.2em;
    background: linear-gradient(to bottom, transparent, var(--bg-panel, #ffffff));
    pointer-events: none;
}

.workflow-play-stage.is-collapsible:not(.is-expanded) .workflow-input-payload-body pre,
.workflow-play-stage.is-collapsible:not(.is-expanded) .workflow-input-payload-body .code-container {
    max-height: 4.5em;
    overflow: hidden;
}

.workflow-play-stage-collapse-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 2px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    line-height: 0;
    flex-shrink: 0;
}

.workflow-play-stage-collapse-btn:hover {
    color: var(--text-primary, #0f172a);
    background: color-mix(in srgb, var(--text-secondary) 12%, transparent);
}

.workflow-play-stage.is-focused .workflow-input-payload {
    border-color: color-mix(in srgb, var(--blue-accent, #0369a1) 45%, var(--border-color));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--blue-accent, #0369a1) 20%, transparent);
}

.workflow-play-stage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.workflow-play-stage-head h4 {
    margin: 0;
    font-size: 0.95rem;
}

.workflow-play-stage-output {
    /* Markdown final answers inside stage cards (non-chat nodes) */
    white-space: normal;
    overflow-wrap: break-word;
}

.workflow-play-stage-output ul,
.workflow-play-stage-output ol,
.workflow-play-stage-output.message-text ul,
.workflow-play-stage-output.message-text ol {
    margin: 0.5em 0 1em;
    padding-left: 1.5em;
    list-style-position: outside;
}

.workflow-play-stage-output li {
    margin-bottom: 0.55em;
    line-height: 1.55;
}

.workflow-play-stage-output li > p {
    display: inline;
    margin: 0;
}

.workflow-play-stage-output li > p + p {
    display: block;
    margin-top: 0.45em;
}

.workflow-play-stage-output ul ul,
.workflow-play-stage-output ol ul,
.workflow-play-stage-output ul ol,
.workflow-play-stage-output ol ol {
    margin-top: 0.4em;
    margin-bottom: 0.4em;
    padding-left: 1.4em;
}

.workflow-play-stage-output p:first-child {
    margin-top: 0;
}

.workflow-play-stage-output p:last-child {
    margin-bottom: 0;
}

.workflow-play-status-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.workflow-play-status-head h3 {
    margin: 0;
    font-size: 0.9rem;
    flex: 1;
}

.workflow-play-status-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.workflow-play-status-head .settings-close-btn {
    flex: none;
}

/* Author `display: flex` overrides the HTML [hidden] UA rule, so hide explicitly. */
.workflow-play-status-list[hidden] {
    display: none;
}

.workflow-play-status-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.workflow-play-status-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 2px 8px;
    text-align: left;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-main);
    color: inherit;
    padding: 8px 10px;
    cursor: pointer;
    font: inherit;
}

.workflow-play-status-row .workflow-node-status {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
}

.workflow-play-status-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    font-size: 0.85rem;
    font-weight: 600;
}

.workflow-play-status-label-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workflow-play-status-type {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.workflow-play-status-row.is-active {
    border-color: var(--blue-accent, #0369a1);
    box-shadow: 0 0 0 1px rgba(3, 105, 161, 0.2);
}

.workflow-play-status-row.is-focused {
    background: var(--bg-hover, rgba(15, 23, 42, 0.04));
}

.workflow-play-view-row.is-focused,
.workflow-play-dashboard-row.is-focused {
    background: color-mix(in srgb, var(--blue-accent, #0369a1) 12%, var(--bg-panel));
    border-color: color-mix(in srgb, var(--blue-accent, #0369a1) 35%, var(--border-color));
}

.workflow-canvas-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 40;
    background: rgba(15, 23, 42, 0.35);
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.workflow-container {
    position: relative;
}

.workflow-canvas-overlay.is-open {
    display: flex;
}

.workflow-canvas-overlay-card {
    width: min(960px, 100%);
    height: min(640px, 100%);
    background: var(--bg-main);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.workflow-canvas-overlay-bar {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-panel);
    font-size: 0.85rem;
    font-weight: 600;
}

.workflow-canvas-host-play {
    flex: 1;
    min-height: 0;
}

.workflow-canvas-host-play .workflow-canvas-wrap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

@media (max-width: 960px) {
    .workflow-play-status-panel:not(.is-collapsed) {
        width: 220px;
    }

    .workflow-live-view-moved {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .workflow-play-status-panel:not(.is-collapsed):not([hidden]) {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 1000;
        width: min(100%, 320px);
        max-width: 100%;
        margin: 0;
        padding: 14px;
        opacity: 1;
        border-radius: 0;
        box-shadow: -8px 0 24px rgba(15, 23, 42, 0.12);
    }

    .workflow-live-view-moved {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Compact edit header on wider screens */
@media (min-width: 1100px) {
    .workflow-editor-header {
        display: grid;
        grid-template-columns: minmax(180px, 1fr) auto;
        align-items: center;
        gap: 4px 12px;
        padding-right: 8px;
    }

    .workflow-title-block {
        align-items: flex-start;
        padding: 8px 14px 8px;
    }

    .workflow-name-row,
    .workflow-desc-row {
        justify-content: flex-start;
    }

    .workflow-name-display,
    .workflow-name-input,
    .workflow-desc-display,
    .workflow-desc-input {
        text-align: left;
    }

    .workflow-toolbar {
        padding-top: 8px;
    }
}

/* Denser modules modal tiles */
.workflow-module-tile-blurb {
    font-size: 0.72rem;
    line-height: 1.25;
}

.workflow-module-group-title {
    margin-bottom: 6px;
}

.workflow-module-grid {
    gap: 6px;
}

.history-item-workflow-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    background: rgba(3, 105, 161, 0.12);
    color: #0369a1;
    vertical-align: middle;
}
