/* ============================================================================
   Workspace Premium Layout
   ============================================================================ */

.twin-windows {
    display: flex;
    flex: 1;
    height: 0;        /* flex:1 + height:0 fills remaining space exactly */
    min-height: 0;
    background: var(--bg-deep);
    position: relative;
    overflow: hidden;
}

/* Draggable pane divider between left and right panels */
.resize-handle {
    width: 8px;
    cursor: col-resize;
    background: transparent;
    flex-shrink: 0;
    transition: background 0.2s;
    position: relative;
    z-index: 20;
}
.resize-handle:hover,
.resize-handle.active {
    background: rgba(80, 227, 194, 0.15);
}

.navbar,
.workspace-toolbar {
    flex-shrink: 0;
}

.workspace-page .app-footer {
    display: none;
}

.left-pane {
    width: 380px;
    display: flex;
    flex-direction: column;
    background: var(--bg-navbar);
    border-right: 1px solid var(--border-soft);
    position: relative;
    z-index: 10;
    overflow: hidden;
}

.workspace-toolbar {
    width: calc(100% - 12%);
    margin: 0.7rem auto 0.55rem;
    padding: 0.66rem 0.9rem;
    border-radius: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.toolbar-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-left: 1rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    min-width: 0;
}

.toolbar-pill {
    max-width: 220px;
    padding: 0.24rem 0.58rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-soft);
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
    transition: all 0.25s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Status Badge Styles */
.task-status-badge.status-executing {
    background: rgba(45, 140, 255, 0.15);
    color: #4dabf7;
    border-color: rgba(45, 140, 255, 0.4);
}

.task-status-badge.status-completed {
    background: rgba(76, 217, 100, 0.15);
    color: #4cd964;
    border-color: rgba(76, 217, 100, 0.4);
}

.task-status-badge.status-failed {
    background: rgba(255, 59, 48, 0.15);
    color: #ff3b30;
    border-color: rgba(255, 59, 48, 0.4);
}

.task-status-badge.status-paused {
    background: rgba(255, 204, 0, 0.15);
    color: #ffcc00;
    border-color: rgba(255, 204, 0, 0.4);
}

.task-status-badge.status-cancelled {
    background: rgba(255, 140, 0, 0.15);
    color: #ffb04d;
    border-color: rgba(255, 140, 0, 0.4);
}

.toolbar-pill:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(80, 227, 194, 0.3);
}

.budget-block {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 170px;
}

.budget-meter {
    width: 160px;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.budget-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, rgba(80, 227, 194, 0.9), rgba(45, 140, 255, 0.9));
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    border-radius: inherit;
}

.budget-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    animation: shimmer 2.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

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

.toolbar-btn {
    padding: 0.45rem 1rem;
    transition: all 0.25s;
}

.toolbar-btn:hover {
    transform: translateY(-1px);
}

.toolbar-btn-danger {
    border-color: rgba(255, 0, 124, 0.3);
    color: #ff007c;
}

.toolbar-btn-danger:hover {
    background: rgba(255, 0, 124, 0.12);
    border-color: rgba(255, 0, 124, 0.6);
    box-shadow: 0 0 15px rgba(255, 0, 124, 0.15);
}

@media (max-width: 1024px) {
    .workspace-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-meta {
        margin-left: 0;
    }

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

.task-description-header {
    padding: 0.4rem 0.8rem;
    border-bottom: 1px solid var(--border-soft);
    background: rgba(80, 227, 194, 0.015);
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.task-description-header:hover {
    background: rgba(80, 227, 194, 0.04);
}

.task-indicator {
    font-size: 0.55rem;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 0.15rem;
    letter-spacing: 0.5px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.task-indicator::after {
    content: '▾';
    font-size: 0.6rem;
    opacity: 0.5;
    transition: transform 0.2s;
}

.task-description-header.collapsed .task-indicator::after {
    transform: rotate(-90deg);
}

.task-objective {
    font-weight: 500;
    font-size: 0.78rem;
    color: var(--text-primary);
    line-height: 1.3;
    letter-spacing: 0.01em;
    max-height: 9.2em;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    transition: max-height 0.3s ease;
}

.task-description-header.collapsed .task-objective {
    max-height: 1.3em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}

.right-pane {
    flex: 1;
    min-width: 0;     /* prevent flex item from overflowing parent */
    min-height: 0;    /* allow flex children to shrink below content size */
    display: flex;
    flex-direction: column;
    background: #000;
    position: relative;
    overflow: hidden;
}

/* ============================================================================
   Command Center (Chat Area)
   ============================================================================ */

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    mask-image: linear-gradient(to bottom, transparent, black 12px, black calc(100% - 12px), transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 12px, black calc(100% - 12px), transparent);
    scroll-behavior: smooth;
}

.workspace-user-guide {
    margin: 0 0.8rem 0.85rem;
    padding: 0;
    border: 1px solid rgba(80, 227, 194, 0.14);
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(80, 227, 194, 0.075), rgba(88, 166, 255, 0.035)),
        rgba(255, 255, 255, 0.025);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.workspace-user-guide summary {
    list-style: none;
    cursor: pointer;
    padding: 0.62rem 0.85rem;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.workspace-user-guide summary::-webkit-details-marker {
    display: none;
}

.workspace-user-guide summary::after {
    content: " +";
    color: var(--text-muted);
}

.workspace-user-guide[open] summary::after {
    content: " -";
}

.workspace-user-guide-title {
    display: none;
    margin-bottom: 0.45rem;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.workspace-user-guide-grid {
    display: grid;
    gap: 0.35rem;
    font-size: 0.75rem;
    line-height: 1.45;
    padding: 0 0.85rem 0.78rem;
}

.workspace-user-guide-grid span {
    position: relative;
    padding-left: 0.86rem;
}

.workspace-user-guide-grid span::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 4px;
    height: 4px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(80, 227, 194, 0.65);
}

.workspace-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border-soft);
    background: linear-gradient(135deg, rgba(12, 18, 27, 0.95), rgba(8, 12, 18, 0.95));
}

.workspace-input-card {
    padding: 0.55rem;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.workspace-input-card:focus-within {
    border-color: var(--accent) !important;
    box-shadow: 0 0 16px rgba(80, 227, 194, 0.15);
}

.workspace-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    resize: none;
    min-height: 24px;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    line-height: 1.45;
}

.workspace-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.workspace-send {
    padding: 0.5rem 1.1rem;
    border-radius: 10px;
    transition: all 0.25s;
}

.workspace-send:hover {
    transform: scale(1.05);
}

.message {
    display: flex;
    gap: 0.5rem;
    max-width: 95%;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.agent {
    align-self: flex-start;
}

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

.message-avatar {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    border: 1px solid var(--border-soft);
    flex-shrink: 0;
}

.message-content {
    background: var(--bg-card);
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-soft);
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.45;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
}

.message.agent .message-content {
    border-bottom-left-radius: 4px;
    background: linear-gradient(160deg, rgba(26, 27, 38, 0.85) 0%, rgba(15, 17, 26, 0.85) 100%);
    border-top-color: rgba(80, 227, 194, 0.12);
}

.message.user .message-content {
    border-bottom-right-radius: 4px;
    background: linear-gradient(160deg, rgba(80, 227, 194, 0.12) 0%, rgba(26, 27, 38, 0.85) 100%);
    border-color: rgba(80, 227, 194, 0.15);
}

/* ============================================================================
   Execution Console (HUD Style)
   ============================================================================ */

.status-bar.hud-panel {
    background: rgba(8, 12, 18, 0.92);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(80, 227, 194, 0.08);
    padding: 0.6rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 100;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.03);
    position: relative;
    transition: padding 0.25s ease;
}

/* Collapsible status bar — starts collapsed, toggles via UI */
#status-bar,
.status-bar.hud-panel {
    display: flex;
    max-height: 48px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    cursor: pointer;
}

#status-bar.expanded,
.status-bar.hud-panel.expanded {
    max-height: 220px;
}

.status-bar.hud-panel.expanded {
    padding: 1rem 1.5rem;
    max-height: 220px;
}

.status-toggle-icon {
    margin-left: auto;
    font-size: 0.6rem;
    transition: transform 0.25s ease;
    color: var(--text-muted);
}

.status-bar.hud-panel.expanded .status-toggle-icon {
    transform: rotate(180deg);
}

/* Scanline overlay for HUD feel */
.status-bar.hud-panel::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.04) 2px,
            rgba(0, 0, 0, 0.04) 4px);
    pointer-events: none;
    opacity: 0.5;
}

.status-title {
    font-size: 0.75rem;
    /* text-transform: uppercase; */
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    transition: all 0.3s ease;
    min-width: 0;
    max-width: 100%;
}

.status-step.completed {
    color: var(--accent);
    background: rgba(80, 227, 194, 0.05);
}

.status-step.in-progress {
    color: var(--accent-secondary);
    background: rgba(45, 140, 255, 0.05);
    border-color: rgba(45, 140, 255, 0.2);
}

.status-step-icon {
    font-size: 0.7rem;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
}

.status-step.completed .status-step-icon {
    background: var(--accent);
    color: var(--bg-deep);
}

/* ============================================================================
   Screen Controls Bar (above noVNC / video panel)
   ============================================================================ */

.screen-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    height: 32px;
    background: rgba(10, 12, 20, 0.82);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.screen-ctrl-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255,255,255,0.75);
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1;
}
.screen-ctrl-btn:hover {
    background: rgba(255,255,255,0.16);
    color: #fff;
}
.screen-ctrl-danger {
    color: rgba(255, 110, 110, 0.85);
    border-color: rgba(255,100,100,0.25);
}
.screen-ctrl-danger:hover {
    background: rgba(200, 40, 40, 0.22);
    color: #ff7b7b;
    border-color: rgba(255,100,100,0.45);
}

/* ============================================================================
   Screen Preview Section
   ============================================================================ */

.screen-container {
    flex: 1;
    height: 0;        /* flex:1+height:0 fills remaining column space exactly */
    min-height: 0;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.surface-tabs {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 90;
    display: flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    background: rgba(7, 11, 16, 0.76);
    box-shadow: 0 10px 30px rgba(0,0,0,0.28);
    backdrop-filter: blur(14px);
}

.surface-tab {
    height: 28px;
    padding: 0 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: rgba(226, 235, 244, 0.68);
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0;
    cursor: pointer;
}

.surface-tab:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.surface-tab.active {
    color: #071016;
    background: var(--accent);
}

/* Content Viewer */
.content-viewer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0d1117;
    z-index: 50;
    display: flex;
    flex-direction: column;
    padding: 58px 1.5rem 1.5rem;
    overflow-y: auto;
    border-bottom: 1px solid var(--border-soft);
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

.content-indicator {
    font-size: 0.6rem;
    color: var(--accent);
    font-weight: 700;
    letter-spacing: 1px;
    /* text-transform: uppercase; */
    opacity: 0.8;
}

.btn-icon-copy {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon-copy:hover {
    color: var(--accent);
    background: rgba(80, 227, 194, 0.1);
    border-color: rgba(80, 227, 194, 0.3);
}

.btn-icon-copy.copied {
    color: var(--accent);
    background: rgba(80, 227, 194, 0.15);
}

.content-body {
    font-size: 0.9rem;
    line-height: 1.55;
    color: #e6edf3;
    white-space: normal;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.process-feed {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(100%, 860px);
}

.process-item {
    padding: 12px 14px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    background: rgba(255,255,255,0.045);
}

.process-item summary {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(235, 244, 250, 0.92);
    cursor: pointer;
    list-style: none;
}

.process-item summary::-webkit-details-marker {
    display: none;
}

.process-kind {
    flex: 0 0 auto;
    min-width: 64px;
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
}

.process-title {
    overflow: hidden;
    font-size: 0.86rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.process-time {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.process-detail {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: rgba(226, 235, 244, 0.82);
    font-size: 0.82rem;
    line-height: 1.58;
}

.content-body h1,
.content-body h2,
.content-body h3 {
    color: #fff;
    margin-top: 2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 0.5rem;
}

.content-body p {
    margin-bottom: 1.2rem;
}

.content-body code {
    background: rgba(80, 227, 194, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
}

/* Artifact sections in right panel */
.artifact-section {
    margin-bottom: 1rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.artifact-step-header {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border-soft);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.artifact-step-header.artifact-error {
    background: rgba(255,80,80,0.08);
    color: #ff6b6b;
}

.artifact-step-content {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-primary);
    max-height: 400px;
    overflow-y: auto;
}

.artifact-step-content p {
    margin-bottom: 0.6rem;
}

.artifact-error-text {
    color: #ff6b6b;
    font-size: 0.82rem;
    font-style: italic;
}

.screen-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* iframe fills the container absolutely — object-fit has no effect on iframes */
.screen-frame {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border: 0;
    pointer-events: auto;
    z-index: 15;
}

.screen-container.live-mode #content-viewer,
.screen-container.live-mode #screen-loading,
.screen-container.live-mode #screen-video {
    display: none !important;
    pointer-events: none !important;
}

.screen-container.artifact-mode #screen-frame,
.screen-container.artifact-mode #screen-loading,
.screen-container.artifact-mode #screen-video,
.screen-container.artifact-mode #content-viewer {
    display: none !important;
    pointer-events: none !important;
}

.screen-container.process-mode #screen-frame,
.screen-container.process-mode #screen-loading,
.screen-container.process-mode #screen-video,
.screen-container.process-mode #artifact-viewer {
    display: none !important;
    pointer-events: none !important;
}

.screen-container.pending-mode #content-viewer,
.screen-container.pending-mode #screen-video,
.screen-container.pending-mode #screen-frame {
    display: none !important;
    pointer-events: none !important;
}

#screen-loading {
    pointer-events: none;
    z-index: 10;
}

#screen-loading {
    pointer-events: none;
}

.screen-loading-copy {
    display: block;
    max-width: 360px;
    margin: 0 auto;
}

.screen-loading-hint {
    display: block;
    margin-top: 0.65rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
    letter-spacing: 0;
}

.surface-tab.surface-tab-disabled {
    opacity: 0.46;
    cursor: not-allowed;
}

/* ============================================================================
   Result Message Styles (Left Panel - Compact)
   ============================================================================ */

.result-message .message-content {
    max-width: 100%;
}

.result-header {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.3rem;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.result-body {
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--text-secondary);
    max-height: 4.2em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    white-space: pre-wrap;
    word-break: break-word;
    cursor: pointer;
    transition: max-height 0.3s ease;
    position: relative;
}

.result-body::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1.2em;
    background: linear-gradient(to bottom, transparent, var(--bg-card));
    pointer-events: none;
}

.result-body.expanded {
    max-height: 20em;
    -webkit-line-clamp: unset;
}

.result-body.expanded::after {
    display: none;
}

.result-body.is-error {
    color: #ff6b6b;
    border-left: 2px solid #ff6b6b;
    padding-left: 0.5rem;
}

/* Step summary in HUD panel */
.step-summary {
    font-size: 0.65rem;
    color: var(--text-muted);
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.15rem;
}

.status-step.failed .status-step-icon {
    background: #ff3b30;
    color: #fff;
}

.status-step.failed {
    color: #ff6b6b;
    background: rgba(255, 59, 48, 0.05);
}

/* Left panel vertical layout */
.status-steps {
    display: flex;
    gap: 0.5rem;
    flex-direction: column;
    overflow-y: auto;
    flex: 1;
}

.status-step .status-text {
    font-size: 0.72rem;
    line-height: 1.3;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════════════
   ReAct Protocol UI — streaming bubbles, action/observe/reflect
   ═══════════════════════════════════════════════════════════ */

/* Execution mode badge */
.toolbar-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    margin-left: 6px;
}

/* Thinking / streaming bubble */
.react-thinking { opacity: 0.92; }

.react-thinking-content {
    background: rgba(80,227,194,0.07) !important;
    border-left: 2px solid rgba(80,227,194,0.5) !important;
}

.react-thinking-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.react-thinking-label { flex: 1; }

.react-thinking-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(80,227,194,0.3);
    border-top-color: #50e3c2;
    border-radius: 50%;
    animation: react-spin 0.7s linear infinite;
}

@keyframes react-spin { to { transform: rotate(360deg); } }

.react-stream-text {
    font-family: 'SF Mono', monospace;
    font-size: 0.78rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
    color: var(--text-primary);
    line-height: 1.5;
}

.react-thought-done .react-thinking-content {
    border-left-color: var(--border-color) !important;
    background: none !important;
}

/* Action card */
.react-action-content {
    background: rgba(64,156,255,0.06) !important;
    border-left: 2px solid rgba(64,156,255,0.4) !important;
}

.react-action-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.react-step-badge {
    background: rgba(64,156,255,0.15);
    color: #409cff;
    border: 1px solid rgba(64,156,255,0.3);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 0.7rem;
    font-weight: 700;
}

.react-skill-badge {
    background: rgba(80,227,194,0.1);
    color: #50e3c2;
    border: 1px solid rgba(80,227,194,0.3);
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 0.72rem;
    font-family: 'SF Mono', monospace;
}

.react-thought-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 5px;
    font-style: italic;
    white-space: pre-wrap;
}

/* Observe */
.react-observe-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.react-observe-text {
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Reflect */
.react-reflect-content {
    background: rgba(255,204,0,0.05) !important;
    border-left: 2px solid rgba(255,204,0,0.3) !important;
}

.react-reflect-decision {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255,204,0,0.12);
    color: #ffcc00;
    border-radius: 8px;
    padding: 1px 7px;
}

.react-reflect-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-style: italic;
    white-space: pre-wrap;
}

/* Done */
.react-done-summary {
    font-size: 0.85rem;
    margin-top: 4px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Artifact Viewer ─────────────────────────────────────── */
.artifact-viewer {
    position: absolute;
    top: 50px;
    left: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    max-height: calc(100% - 50px);
    background: rgba(8, 12, 18, 0.96);
    z-index: 60;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    backdrop-filter: blur(16px);
    overflow: hidden;
    transition: opacity 0.2s, transform 0.2s;
}

.screen-container.live-mode .artifact-viewer:not(.fullscreen) {
    top: auto;
    left: auto;
    right: 14px;
    bottom: 48px;
    width: min(360px, calc(100% - 28px));
    height: min(260px, 42%);
    border: 1px solid rgba(80, 227, 194, 0.18);
    border-radius: 12px;
    box-shadow: 0 18px 55px rgba(0,0,0,0.45);
}

.artifact-viewer.fullscreen {
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; max-width: 100%; max-height: 100%;
    border-radius: 0;
    border: none;
}

.artifact-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.72rem 0.9rem 0.72rem 1rem;
    min-height: 50px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(135deg, rgba(80, 227, 194, 0.08), rgba(88, 166, 255, 0.06), rgba(255,255,255,0.02));
}

.artifact-title {
    font-size: 0.82rem;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 150px);
}

.artifact-actions {
    display: flex;
    gap: 6px;
}

.btn-artifact {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.btn-artifact:hover {
    color: var(--accent);
    background: rgba(255,255,255,0.1);
    border-color: var(--accent);
}

.artifact-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 1rem;
    position: relative;
}

.artifact-doc-shell {
    width: 100%;
    min-height: 100%;
    padding: 1.35rem 1.45rem 1.6rem;
    border-radius: 12px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.075), rgba(255,255,255,0.025)),
        rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-primary);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.artifact-doc-kicker {
    display: inline-flex;
    align-items: center;
    margin-bottom: 0.85rem;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    background: rgba(80, 227, 194, 0.1);
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.artifact-doc-shell h1 {
    margin: 0 0 1rem;
    color: #f8fbff;
    font-size: clamp(1.15rem, 2vw, 1.55rem);
    line-height: 1.25;
    letter-spacing: 0;
}

.artifact-doc-content {
    color: rgba(232, 240, 248, 0.9);
    font-size: 0.9rem;
    line-height: 1.72;
}

.artifact-doc-content h1,
.artifact-doc-content h2,
.artifact-doc-content h3 {
    margin: 1.15rem 0 0.55rem;
    color: #ffffff;
    line-height: 1.3;
    letter-spacing: 0;
}

.artifact-doc-content h1 {
    font-size: 1.25rem;
}

.artifact-doc-content h2 {
    font-size: 1.05rem;
    color: #dffcf5;
}

.artifact-doc-content h3 {
    font-size: 0.98rem;
}

.artifact-doc-content p {
    margin: 0.55rem 0;
}

.artifact-doc-content code {
    padding: 0.12rem 0.34rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.08);
    color: #9eeedc;
}

.artifact-doc-loading {
    min-height: 260px;
}

.artifact-doc-title {
    margin: 0.9rem 0 1.2rem;
    font-size: 1.2rem;
    font-weight: 700;
}

.artifact-doc-skeleton {
    height: 12px;
    margin: 0.8rem 0;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.14), rgba(255,255,255,0.06));
}

.artifact-doc-skeleton.short {
    width: 68%;
}

.artifact-file-shell {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: min(100%, 420px);
    padding: 1rem;
    border-radius: 14px;
    background: rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.09);
}

.artifact-file-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(80, 227, 194, 0.12);
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.artifact-file-meta {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.artifact-file-meta strong {
    overflow: hidden;
    color: var(--text-primary);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.artifact-file-meta span {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.artifact-open-link {
    flex-shrink: 0;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
}

.artifact-body img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

.artifact-body video {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

.artifact-body audio {
    width: 90%;
    max-width: 480px;
}

.artifact-gallery {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.5rem;
    flex-shrink: 0;
    border-top: 1px solid var(--border-soft);
}

.artifact-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.4;
    cursor: pointer;
    transition: all 0.2s;
}

.artifact-dot.active {
    opacity: 1;
    background: var(--accent);
    transform: scale(1.3);
}

/* Collapsed artifact badge — floating button to re-open */
.artifact-badge {
    position: absolute;
    bottom: 56px;
    right: 12px;
    z-index: 58;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(13,17,23,0.92);
    border: 1px solid var(--accent);
    border-radius: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    backdrop-filter: blur(6px);
    transition: transform 0.15s, box-shadow 0.15s;
    user-select: none;
}
.artifact-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
.artifact-badge-icon {
    font-size: 1.1rem;
}
.artifact-badge-count {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
}

/* Chat artifact card */
.artifact-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    margin: 6px 0;
    cursor: pointer;
    transition: all 0.2s;
}

.artifact-card:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--accent);
}

.artifact-card-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(255,255,255,0.06);
}

.artifact-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    background: rgba(255,255,255,0.06);
}

.artifact-card-info {
    flex: 1;
    overflow: hidden;
}

.artifact-card-title {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.artifact-card-type {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.artifact-card-view {
    font-size: 0.65rem;
    color: var(--accent);
    opacity: 0.7;
}

/* =========================================
   Workspace Design System Bridges
   ========================================= */
.workspace-page .workspace-toolbar {
    background: linear-gradient(135deg, rgba(80, 227, 194, 0.08), rgba(45, 140, 255, 0.08), rgba(255, 255, 255, 0.04));
    border-color: rgba(80, 227, 194, 0.16);
}

.workspace-toolbar-context {
    display: flex;
    align-items: center;
    gap: 0.78rem;
    min-width: 0;
}

.workspace-toolbar-stage {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.workspace-back-btn {
    padding: 0.42rem 0.78rem !important;
    white-space: nowrap;
}

.workspace-page .toolbar-meta {
    gap: 0.45rem;
    margin-left: 0;
}

.workspace-page .toolbar-pill {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

.workspace-page .task-description-header {
    background: linear-gradient(180deg, rgba(80, 227, 194, 0.05), rgba(255, 255, 255, 0.02));
}

.workspace-page .status-bar {
    background: linear-gradient(180deg, rgba(8, 12, 18, 0.9), rgba(8, 12, 18, 0.98));
}

@media (max-width: 1024px) {
    .workspace-toolbar {
        width: calc(100% - 32px);
    }

    .workspace-toolbar-context {
        flex-wrap: wrap;
    }

    .twin-windows {
        flex-direction: column;
    }

    .left-pane {
        width: 100%;
        max-height: 45%;
        border-right: none;
        border-bottom: 1px solid var(--border-soft);
    }

    .resize-handle {
        display: none;
    }

    .right-pane {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .left-pane {
        max-height: 40%;
    }

    .workspace-toolbar {
        width: calc(100% - 20px);
        margin: 0.65rem auto;
        padding: 0.65rem 0.72rem;
        gap: 0.7rem;
        border-radius: 16px;
    }

    .workspace-toolbar-context {
        gap: 0.55rem;
    }

    .workspace-toolbar-stage .toolbar-title {
        font-size: 0.95rem;
        line-height: 1.2;
    }

    .workspace-page .toolbar-meta {
        gap: 0.35rem;
    }

    .toolbar-pill {
        max-width: 100%;
        font-size: 0.66rem;
    }

    #sandbox-id {
        max-width: 150px;
    }

    #task-time {
        max-width: 190px;
    }

    .toolbar-actions {
        width: 100%;
    }

    .toolbar-actions .toolbar-btn {
        flex: 1;
        justify-content: center;
    }
}

/* =========================================
   Workspace Framed Shell
   ========================================= */
.workspace-page .twin-windows {
    width: calc(100% - 12%);
    margin: 0 auto 0.42rem;
    gap: 0.65rem;
    padding: 0;
    background: transparent;
    overflow: hidden;
}

.workspace-page .left-pane,
.workspace-page .right-pane {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.26);
}

.workspace-page .left-pane {
    width: 400px;
    min-width: 340px;
    max-width: 500px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, rgba(12, 18, 27, 0.96), rgba(8, 12, 18, 0.96));
}

.workspace-page .right-pane {
    min-width: 0;
    padding: 0.6rem;
    background:
        linear-gradient(180deg, rgba(18, 24, 33, 0.96), rgba(6, 9, 14, 0.98)),
        #05070a;
}

.workspace-page .resize-handle {
    width: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    position: relative;
    left: auto;
    top: auto;
    bottom: auto;
    align-self: stretch;
    margin: 0.4rem 0;
}

.workspace-page .resize-handle:hover,
.workspace-page .resize-handle.active {
    background: rgba(80, 227, 194, 0.24);
}

.workspace-page .task-description-header {
    margin: 0.75rem 0.75rem 0;
    padding: 0.8rem 0.9rem;
    border: 1px solid rgba(80, 227, 194, 0.12);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(80, 227, 194, 0.07), rgba(255, 255, 255, 0.025));
}

.workspace-page .task-indicator {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.workspace-page .task-objective {
    font-size: 0.84rem;
    line-height: 1.45;
}

.workspace-page .chat-area {
    padding: 0.95rem 0.95rem 0.8rem;
}

.workspace-page .workspace-input-area {
    padding: 0.85rem 0.95rem 0.95rem;
}

.workspace-page .screen-container {
    margin: 0;
    flex: 1 1 auto;
    height: 0;
    min-height: 0;
    border: 10px solid #111823;
    border-radius: 16px;
    background: #020406;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.055),
        0 0 0 1px rgba(80, 227, 194, 0.08),
        0 28px 70px rgba(0, 0, 0, 0.42);
}

.workspace-page .screen-frame,
.workspace-page .screen-video {
    border-radius: 7px;
}

.workspace-page .status-bar.hud-panel {
    margin-top: 0.32rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.28rem 0.72rem;
}

.workspace-page #status-bar,
.workspace-page .status-bar.hud-panel {
    flex: 0 0 24px !important;
    min-height: 0 !important;
    height: 24px !important;
    max-height: 24px !important;
    overflow: hidden !important;
}

.workspace-page #status-bar.expanded,
.workspace-page .status-bar.hud-panel.expanded,
.workspace-page .status-bar.hud-panel.expanded {
    flex-basis: 88px !important;
    height: 88px !important;
    min-height: 0 !important;
    max-height: 88px !important;
    padding: 0.34rem 0.72rem !important;
}

.workspace-page .status-title {
    min-height: 16px;
    font-size: 0.62rem;
    letter-spacing: 0.06em;
}

.workspace-page .status-steps {
    max-height: 54px;
    overflow-y: auto;
}

@media (max-width: 1024px) {
    .workspace-page .twin-windows {
        width: calc(100% - 32px);
        gap: 0.75rem;
    }

    .workspace-page .left-pane {
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .workspace-page .right-pane {
        min-height: 0;
    }
}

@media (max-width: 768px) {
    .workspace-page .twin-windows {
        width: calc(100% - 20px);
        margin-bottom: 0.65rem;
        gap: 0.6rem;
    }

    .workspace-page .left-pane,
    .workspace-page .right-pane {
        border-radius: 14px;
    }

    .workspace-page .right-pane {
        padding: 0.52rem;
    }

    .workspace-page .task-description-header {
        margin: 0.6rem 0.6rem 0;
        padding: 0.68rem 0.72rem;
    }

    .workspace-page .chat-area {
        padding: 0.75rem 0.72rem 0.65rem;
    }

    .workspace-page .workspace-input-area {
        padding: 0.65rem 0.72rem 0.75rem;
    }
}
