/**
 * Agent Builder Inline Styles
 * Extracted from agent_builder.html for better cacheability and maintainability.
 * Contains: base styles, mobile/responsive styles, modals, connections panel,
 * workflow toolbar, notifications, and component overrides.
 */

:root {
    --header-height: 56px;
    --footer-height: env(safe-area-inset-bottom, 0px);
    --peek-height: 20vh;
    --peek-collapsed: 60px;
    --touch-target-min: 48px;
    --button-padding: 12px 20px;
    --font-size-base: 16px;
    --font-size-small: 14px;
    --font-size-large: 18px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --transition-fast: 150ms ease-out;
}

* {
    -webkit-tap-highlight-color: transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1f2937;
}

::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

.typing-indicator span {
    animation: blink 1.4s infinite;
    animation-fill-mode: both;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0% {
        opacity: 0.2;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: 0.2;
    }
}

/* ============================================
   BASE STYLES (Desktop-first now for sanity)
   ============================================ */

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.mobile-header {
    height: var(--header-height);
    background: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-inline: var(--spacing-md);
    flex-shrink: 0;
    z-index: 100;
}

.mobile-main {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    min-height: 0;
}

.page {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.page-chat {
    flex: 0 0 400px;
    min-width: 350px;
    max-width: 500px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.page-viz {
    flex: 1;
    min-width: 0;
}

.page-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--spacing-md);
    min-height: 0;
}

.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: var(--spacing-md);
    background: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

/* Two-Button Architecture: Input container with stacked layout */
.chat-input-area .input-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* Textarea: Full width */
.chat-input-area .prompt-input {
    width: 100%;
    min-height: 60px;
    padding: 12px;
    background: rgba(17, 24, 39, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #e5e7eb;
    font-size: var(--font-size-base);
    resize: vertical;
    transition: border-color 0.2s ease;
}

.chat-input-area .prompt-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.chat-input-area .prompt-input::placeholder {
    color: #6b7280;
}

/* Button row: Below textarea, right-aligned */
.chat-input-area .button-row {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Legacy support for old class names */
.chat-input-area .input-row {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.chat-input-area .input-row textarea {
    width: 100%;
}

.chat-input-area .send-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Conversation indicator - shows when there's an active workflow */
.conversation-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #93c5fd;
    padding: 4px 10px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 12px;
    width: fit-content;
}

.conversation-indicator.hidden {
    display: none;
}

.conversation-indicator .indicator-dot {
    width: 6px;
    height: 6px;
    background: #60A5FA;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ============================================
   DOCUMENT ATTACHMENT STYLES
   ============================================ */

/* Attachment button */
.attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #9CA3AF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.attach-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    color: #3b82f6;
}

.attach-btn:active {
    transform: scale(0.95);
}

.attach-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

.hidden-file-input {
    display: none;
}

/* Input row with attachment button */
.input-row-with-attach {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.input-row-with-attach .prompt-input {
    flex: 1;
}

/* Attached files display */
.attached-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

.attached-files.hidden {
    display: none;
}

.attached-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 16px;
    font-size: 12px;
    color: #93C5FD;
}

.attached-file .file-icon {
    font-size: 14px;
}

.attached-file .file-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attached-file .remove-file {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #9CA3AF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    transition: all 0.2s;
}

.attached-file .remove-file:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #FCA5A5;
}

.attached-file.uploading {
    opacity: 0.6;
}

.attached-file.error {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #FCA5A5;
}

/* Loading dots animation - uses opacity/transform instead of content */
.loading-dots {
    display: inline-flex;
    gap: 2px;
    margin-left: 4px;
}

.loading-dots .dot {
    animation: dot-fade 1.4s infinite ease-in-out both;
}

.loading-dots .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots .dot:nth-child(2) {
    animation-delay: -0.16s;
}

.loading-dots .dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes dot-fade {
    0%, 80%, 100% {
        opacity: 0.3;
    }
    40% {
        opacity: 1;
    }
}

/* Drop overlay for drag and drop */
.drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(59, 130, 246, 0.1);
    border: 2px dashed #3b82f6;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

.drop-overlay.active {
    display: flex;
}

.drop-overlay-text {
    font-size: 16px;
    color: #3b82f6;
    font-weight: 500;
}

.chat-input-area textarea {
    flex: 1;
    min-height: var(--touch-target-min);
    max-height: 120px;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: var(--font-size-base);
    resize: none;
    line-height: 1.4;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.send-button {
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform var(--transition-fast), background var(--transition-fast);
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

.send-button:active {
    transform: scale(0.95);
    background: #2563eb;
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Page switcher - hidden on desktop by default */
.page-switcher {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--peek-collapsed);
    padding-bottom: var(--safe-bottom);
    background: rgba(17, 24, 39, 0.98);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    align-items: center;
    justify-content: space-around;
    z-index: 100;
}

.switcher-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--spacing-sm) var(--spacing-lg);
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
    cursor: pointer;
    transition: color var(--transition-fast);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    outline: none;
}

.switcher-btn:focus {
    outline: none;
}

.switcher-btn.active {
    color: #3b82f6;
}

/* ============================================
   MORE MENU (Mobile Navigation)
   ============================================ */
.more-menu {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
}

.more-menu.open {
    display: block;
}

.more-menu-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.more-menu-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(17, 24, 39, 0.98);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    padding-bottom: calc(var(--safe-bottom, 0px) + 16px);
    transform: translateY(100%);
    animation: slide-up 0.25s ease-out forwards;
}

@keyframes slide-up {
    to {
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Respect users' prefers-reduced-motion setting */
@media (prefers-reduced-motion: reduce) {
    .more-menu-backdrop {
        animation: none;
        backdrop-filter: none;
    }

    .more-menu-content {
        animation: none;
        transform: translateY(0);
    }

    .more-menu-close {
        transition: none;
    }
}

.more-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    font-size: 16px;
}

.more-menu-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 24px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    transition: color 0.15s;
}

.more-menu-close:hover {
    color: white;
}

.more-menu-nav {
    padding: 8px 0;
}

.more-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.15s;
}

.more-menu-item:hover,
.more-menu-item:focus {
    background: rgba(255, 255, 255, 0.05);
}

.more-menu-item:active {
    background: rgba(255, 255, 255, 0.1);
}

.more-menu-item svg {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    color: #3b82f6;
}

.more-menu-item-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.more-menu-item-title {
    font-weight: 500;
    font-size: 15px;
}

.more-menu-item-desc {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

/* Hide more menu on desktop */
@media (min-width: 769px) {
    .more-menu {
        display: none !important;
    }
}

/* ============================================
   MOBILE STYLES
   ============================================ */

@media (max-width: 768px) {
    body[data-device="mobile"] {
        height: 100dvh;
        position: fixed;
        width: 100%;
    }

    body[data-device="mobile"] .mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        padding-top: var(--safe-top);
    }

    body[data-device="mobile"] .mobile-main {
        position: fixed;
        top: calc(var(--header-height) + var(--safe-top));
        left: 0;
        right: 0;
        bottom: calc(var(--peek-collapsed) + var(--safe-bottom));
        flex-direction: row;
        scroll-snap-type: x mandatory;
        overflow-x: auto;
        scroll-behavior: smooth;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    body[data-device="mobile"] .mobile-main::-webkit-scrollbar {
        display: none;
    }

    body[data-device="mobile"] .page {
        flex: 0 0 100%;
        width: 100%;
        scroll-snap-align: start;
        scroll-snap-stop: always;
    }

    body[data-device="mobile"] .page-chat {
        flex: 0 0 100%;
        max-width: none;
        min-width: auto;
        border-right: none;
    }

    body[data-device="mobile"] .page-switcher {
        display: flex;
    }

    .switcher-btn {
        padding: 12px 32px;
        min-height: 56px;
    }
}

/* Mobile Landscape */
@media (max-width: 768px) and (orientation: landscape) {
    body[data-device="mobile"][data-orientation="landscape"] .mobile-main {
        flex-direction: row;
        scroll-snap-type: none;
        overflow-x: hidden;
        bottom: var(--safe-bottom);
    }

    body[data-device="mobile"][data-orientation="landscape"] .page {
        flex: 1 1 50%;
        scroll-snap-align: none;
    }

    body[data-device="mobile"][data-orientation="landscape"] .page-chat {
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }

    body[data-device="mobile"][data-orientation="landscape"] .page-switcher {
        display: none;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .page-chat {
        flex: 0 0 40%;
        max-width: none;
    }

    .page-viz {
        flex: 0 0 60%;
    }
}

/* Message styles */
.message {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    min-height: var(--touch-target-min);
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.message-content {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 16px;
    max-width: 85%;
    font-size: var(--font-size-base);
    line-height: 1.5;
    word-wrap: break-word;
}

.message-user {
    flex-direction: row-reverse;
}

.message-user .message-content {
    background: #3b82f6;
    color: white;
    border-bottom-right-radius: 4px;
}

.message-ai .message-content {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border-bottom-left-radius: 4px;
}

.message-error .message-content {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
    border-bottom-left-radius: 4px;
}

.swiping {
    user-select: none;
    -webkit-user-select: none;
}

button {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

/* ============================================
   MODE SELECTOR STYLES
   ============================================ */
.mode-selector {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: rgba(31, 41, 55, 0.8);
    border-radius: 12px;
    margin: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mode-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(0, 0, 0, 0.2);
    min-width: 0;
}

.mode-option:hover {
    border-color: #3b82f6;
    transform: translateY(-1px);
}

.mode-option.active {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
}

.mode-option.premium::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #f59e0b, #eab308, #f59e0b);
    border-radius: 10px 10px 0 0;
}

.mode-option.premium {
    position: relative;
    overflow: hidden;
}

.mode-option.premium.active {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
}

.mode-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.mode-name {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 2px;
    white-space: nowrap;
}

.mode-tagline {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    line-height: 1.2;
}

/* ============================================
   SERVICE SELECTION MODAL STYLES
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: #1f2937;
    border-radius: 16px;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.modal-close:hover {
    color: white;
}

.modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: flex-end;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.service-selection-group {
    margin-bottom: 20px;
}

.service-selection-group h4 {
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.selection-prompt {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 12px;
}

.service-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.service-option {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(0, 0, 0, 0.2);
}

.service-option:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.service-option.selected {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.2);
}

.service-option.not-connected {
    opacity: 0.6;
}

.service-option .service-icon {
    font-size: 20px;
    margin-right: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.service-option .service-icon img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.service-option .service-info {
    flex: 1;
    min-width: 0;
}

.service-option .service-name {
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.service-option .service-desc {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.service-option .service-status {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-left: 8px;
}

.service-option .service-status.connected {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.service-option .service-status.connect {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.tier-badge {
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
    text-transform: uppercase;
}

.tier-badge.basic {
    background: rgba(156, 163, 175, 0.3);
    color: #9ca3af;
}

.tier-badge.professional {
    background: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}

.tier-badge.enterprise {
    background: rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

@media (max-width: 768px) {
    .mode-selector {
        margin: 4px 8px;
        padding: 8px;
        gap: 6px;
    }

    .mode-option {
        padding: 8px 4px;
    }

    .mode-icon {
        font-size: 18px;
    }

    .mode-name {
        font-size: 11px;
    }

    .mode-tagline {
        font-size: 9px;
    }

    .service-options {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   X6 WORKFLOW EDITOR STYLES
   ============================================ */
#workflow-container {
    width: 100%;
    height: 100%;
    background: #111827;
    position: relative;
    touch-action: none;
    overscroll-behavior: contain;
}

#workflow-minimap {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 150px;
    height: 100px;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 4px;
    z-index: 10;
}

/* Bottom-centered, matching the authoritative positioning in
   node-drawer.css (which uses !important overrides). Keeping both files
   agreed on the anchor means a stale copy of either file can't produce
   the half-applied layout (left:50% + right:16px squeezing the bar)
   seen on cached mobile clients. Spacing/sizing (gap, max-width,
   padding, background) is owned by node-drawer.css alone — this file
   loads later, so any value repeated here would silently override
   node-drawer's responsive variants. */
.workflow-toolbar {
    position: absolute;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    z-index: 60;
    /* Higher than governor-pane (z-index: 50) */
}

.workflow-toolbar button {
    padding: 8px 12px;
    background: #374151;
    border: 1px solid #4b5563;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.workflow-toolbar button:hover {
    background: #4b5563;
}

.toolbar-divider {
    width: 1px;
    align-self: stretch;
    background: rgba(156, 163, 175, 0.35);
}

.toolbar-overflow-wrapper {
    position: relative;
    display: inline-flex;
}

/* Opens upward: node-drawer.css anchors .workflow-toolbar to the bottom
   of the canvas (its !important overrides win over the top/right above)
   at every viewport width. Capped height so short landscape viewports
   scroll the menu instead of clipping it at the canvas top. */
.toolbar-overflow-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    min-width: 190px;
    max-height: min(60vh, 320px);
    overflow-y: auto;
    padding: 4px;
    background: #1f2937;
    border: 1px solid #4b5563;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    z-index: 70;
}

.toolbar-overflow-menu.open {
    display: block;
}

.workflow-toolbar .toolbar-overflow-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    white-space: nowrap;
    /* Beats .lock-btn.unlocked's dark-on-light colours, which would be
       unreadable on the dark menu background */
    color: #f9fafb;
}

.workflow-toolbar .toolbar-overflow-menu button:hover {
    background: #374151;
}

/* Restore the lock button's state colours, which the generic menu-button
   rule above would otherwise override (it has higher specificity than
   .lock-btn.locked / .lock-btn.unlocked). Unlocked keeps its original
   dark-on-amber pairing for contrast. */
.workflow-toolbar .toolbar-overflow-menu button.lock-btn.locked {
    background: #374151;
    color: #9CA3AF;
}

.workflow-toolbar .toolbar-overflow-menu button.lock-btn.locked:hover {
    background: #4b5563;
}

.workflow-toolbar .toolbar-overflow-menu button.lock-btn.unlocked {
    background: #F59E0B;
    color: #1F2937;
}

.workflow-toolbar .toolbar-overflow-menu button.lock-btn.unlocked:hover {
    background: #D97706;
}

/* Missing Connections Warning Banner */
.missing-connections-banner {
    position: absolute;
    top: 56px;
    left: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 6px;
    z-index: 59;
    font-size: 13px;
    color: #fbbf24;
}

.missing-connections-banner.hidden {
    display: none;
}

.missing-connections-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.missing-connections-text {
    flex: 1;
    color: #fde68a;
    line-height: 1.3;
}

.missing-connections-btn {
    padding: 4px 10px;
    background: rgba(245, 158, 11, 0.25);
    border: 1px solid rgba(245, 158, 11, 0.5);
    border-radius: 4px;
    color: #fbbf24;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.2s;
}

.missing-connections-btn:hover {
    background: rgba(245, 158, 11, 0.4);
}

.missing-connections-dismiss {
    background: none;
    border: none;
    color: #fbbf24;
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.missing-connections-dismiss:hover {
    opacity: 1;
}

/* ---------------------------------------------------------------
 * Ship 5: Layered-discovery chip + partial-support banner
 * Spec §4.5 (Virtual Run integration). Chip / banner render only
 * when `layered_discovery` metadata is attached to the plan dict,
 * which only happens on layered-mode workflow generations.
 *
 * Round-1 fix: single positioned container, no per-element `top`
 * offsets. The banner and chip-row participate in normal flow with
 * margin-top spacing, so when the banner text wraps onto multiple
 * lines the chip row doesn't overlap. The `.hidden` rule controls
 * visibility only — never positioning.
 * --------------------------------------------------------------- */

.layered-discovery-surface {
    position: absolute;
    top: 56px;
    left: 16px;
    right: 16px;
    z-index: 58;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none; /* let workflow editor catch background clicks */
}

.layered-discovery-surface > * { pointer-events: auto; }

.layered-partial-support-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 6px;
    font-size: 13px;
    color: #fde68a;
    line-height: 1.3;
}

.layered-partial-support-banner.hidden { display: none; }

.layered-banner-icon { font-size: 16px; flex-shrink: 0; }
.layered-banner-text { flex: 1; }

.layered-banner-dismiss {
    background: none;
    border: none;
    color: #fbbf24;
    cursor: pointer;
    font-size: 18px;
    padding: 0 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.layered-banner-dismiss:hover { opacity: 1; }

.layered-toolkit-chip-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
}

.layered-toolkit-chip-row.hidden { display: none; }

.layered-toolkit-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(59, 130, 246, 0.45);
    border-radius: 999px;
    color: #93c5fd;
    font-size: 13px;
}

.layered-toolkit-chip-label {
    opacity: 0.75;
    font-size: 12px;
}

.layered-toolkit-chip-name {
    font-weight: 600;
    color: #bfdbfe;
}

.layered-toolkit-chip-source {
    opacity: 0.65;
    font-size: 11px;
    font-style: italic;
}

.layered-toolkit-chip-change {
    margin-left: 6px;
    padding: 2px 10px;
    background: rgba(59, 130, 246, 0.25);
    border: 1px solid rgba(59, 130, 246, 0.55);
    border-radius: 999px;
    color: #dbeafe;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: background 0.2s;
}
.layered-toolkit-chip-change:hover { background: rgba(59, 130, 246, 0.4); }

.layered-toolkit-chip-warning {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(245, 158, 11, 0.18);
    border: 1px solid rgba(245, 158, 11, 0.45);
    border-radius: 999px;
    color: #fde68a;
    font-size: 12px;
}

.layered-toolkit-chip-warning.hidden { display: none; }
.layered-toolkit-chip-warning-icon { flex-shrink: 0; }

.workflow-zoom-level {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    padding: 8px 10px;
    border-radius: 4px;
    background: rgba(17, 24, 39, 0.9);
    border: 1px solid #4b5563;
    color: #d1d5db;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.workflow-zoom-level:disabled,
.workflow-zoom-level:disabled:hover {
    cursor: default;
    opacity: 0.7;
    background: rgba(17, 24, 39, 0.9);
    box-shadow: none;
    transform: none;
    color: #d1d5db;
}

/* Lock Button Styles */
.lock-btn {
    min-width: 44px;
    font-size: 18px;
    transition: all 0.2s ease;
}

.lock-btn.locked {
    background: #374151;
    color: #9CA3AF;
}

.lock-btn.unlocked {
    background: #F59E0B;
    color: #1F2937;
}

.lock-btn.unlocked:hover {
    background: #D97706;
}

/* Lock button pulse animation - subtle reminder when clicking nodes while locked */
@keyframes lock-reminder-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
    50% {
        box-shadow: 0 0 12px 4px rgba(59, 130, 246, 0.6);
    }
}

.lock-btn.pulse-reminder {
    animation: lock-reminder-pulse 0.5s ease-in-out 3;
}

/* Visual indicator on canvas when unlocked */
#workflow-container.unlocked {
    outline: 2px dashed #F59E0B;
    outline-offset: -2px;
}

/* Enrichment Indicator (Skeleton-First Workflow) */
.enrichment-indicator {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #1E3A5F;
    border: 1px solid #3B82F6;
    border-radius: 20px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #93C5FD;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.enrichment-indicator .spinner {
    animation: enrichment-spin 1s linear infinite;
}

@keyframes enrichment-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Notification Container */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: notification-slide-in 0.3s ease;
}

.notification button {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.notification button:hover {
    color: white;
}

.notification-success {
    background: #065F46;
    border: 1px solid #10B981;
}

.notification-warning {
    background: #92400E;
    border: 1px solid #F59E0B;
}

.notification-error {
    background: #991B1B;
    border: 1px solid #EF4444;
}

.notification-info {
    background: #1E3A5F;
    border: 1px solid #3B82F6;
}

@keyframes notification-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   ENHANCED NOTIFICATION STYLES (Phase 2)
   Retrying type, countdown bar, action buttons
   ============================================ */

/* Retrying notification - amber */
.notification-retrying {
    background: #78350f;
    border: 1px solid #f59e0b;
}

/* Internal structure for enhanced notifications */
.notification-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
}

.notification-icon {
    font-size: 16px;
    line-height: 1.2;
    flex-shrink: 0;
}

.notification-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.notification-message {
    font-weight: 500;
}

.notification-details {
    font-size: 12px;
    opacity: 0.8;
}

/* Spinning arrow for retrying */
.notification-spinner {
    display: inline-block;
    animation: notification-spin 1s linear infinite;
}

@keyframes notification-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Action button in notification */
.notification-action-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
    flex-shrink: 0;
}

.notification-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Close button styling */
.notification-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    margin-left: 8px;
}

.notification-close:hover {
    color: white;
}

/* Countdown bar - uses scaleX for GPU acceleration */
.notification-countdown-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 0 0 8px 8px;
    transform-origin: left;
    will-change: transform;
    animation: countdown-deplete linear forwards;
}

@keyframes countdown-deplete {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* Make notification position relative for countdown bar */
.notification {
    position: relative;
    overflow: hidden;
}

/* Notification variants with action buttons */
.notification-error .notification-action-btn {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.5);
}

.notification-error .notification-action-btn:hover {
    background: rgba(239, 68, 68, 0.5);
}

.notification-warning .notification-action-btn {
    background: rgba(245, 158, 11, 0.3);
    border-color: rgba(245, 158, 11, 0.5);
}

.notification-warning .notification-action-btn:hover {
    background: rgba(245, 158, 11, 0.5);
}

.notification-retrying .notification-action-btn {
    background: rgba(245, 158, 11, 0.3);
    border-color: rgba(245, 158, 11, 0.5);
}

.notification-retrying .notification-action-btn:hover {
    background: rgba(245, 158, 11, 0.5);
}

/* ============================================
   ACTION BUTTON CONTAINERS (chat messages)
   Flexbox wrap to prevent overflow/truncation
   ============================================ */
.action-buttons-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
    max-width: 100%;
}

.action-buttons-wrap button {
    flex: 1 1 calc(33.333% - 8px);
    /* 3 columns with gap */
    min-width: 100px;
    max-width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

/* On narrow screens, 2 columns */
@media (max-width: 500px) {
    .action-buttons-wrap button {
        flex: 1 1 calc(50% - 4px);
        min-width: 90px;
    }
}

/* On very narrow screens, stack vertically */
@media (max-width: 300px) {
    .action-buttons-wrap button {
        flex: 1 1 100%;
    }
}

/* Detail panel parameters */
.detail-params {
    background: #111827;
    border-radius: 6px;
    padding: 12px;
}

.param-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
}

.param-key {
    color: #9ca3af;
}

.param-value {
    color: #fff;
    word-break: break-all;
}

.status-success {
    color: #22c55e;
}

.status-warning {
    color: #f59e0b;
}

.status-error {
    color: #EF4444;
}

/* Toast notifications */
@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    15% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    85% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

.toast-notification {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 8px;
    padding: 8px 0;
    min-width: 150px;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.context-menu .menu-item {
    padding: 10px 16px;
    cursor: pointer;
    color: #fff;
    font-size: 14px;
    transition: background 0.15s;
}

.context-menu .menu-item:hover {
    background: #374151;
}

.context-menu .menu-item.danger {
    color: #f87171;
}

.context-menu .menu-item.danger:hover {
    background: #7f1d1d;
}

/* X6 overrides for dark theme */
.x6-graph-svg {
    background: transparent !important;
}

.x6-widget-selection-box {
    border-color: #3b82f6 !important;
}

.x6-widget-selection-inner {
    background-color: rgba(59, 130, 246, 0.1) !important;
}

@media (max-width: 768px) {
    /* Toolbar positioning handled by node-drawer.css - only size buttons here */

    /* Mobile touch targets - minimum 44px for accessibility */
    .workflow-toolbar button {
        min-width: 44px;
        min-height: 44px;
        padding: 8px 12px;
        font-size: 12px;
    }

    .workflow-zoom-level {
        min-height: 44px;
    }

    /* Pinch-zoom covers +/− on touch screens; keep the bar to one row */
    .workflow-toolbar .toolbar-zoom-btn {
        display: none;
    }

    /* Match node-drawer.css's mobile anchor (this file loads later, so
       the base rule above would otherwise win with 24px) */
    .workflow-toolbar {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    /* The viz page-title row duplicates the active tab label; collapse it
       to a floating Run button so the canvas gets the full height */
    .viz-header {
        position: absolute;
        top: 8px;
        right: 8px;
        z-index: 20;
        padding: 0;
        border-bottom: 0;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .viz-header h2 {
        display: none;
    }

    /* Ensure action buttons are tappable on mobile */
    .action-buttons-wrap button {
        min-height: 48px;
        font-size: 16px;
        /* Prevents iOS zoom on focus */
        touch-action: manipulation;
    }

    /* CRITICAL: Hide minimap on mobile (too small) but KEEP diagram visible */
    #workflow-minimap {
        display: none !important;
    }

    /* Ensure workflow container fills available space on mobile */
    #workflow-container {
        width: 100% !important;
        height: 100% !important;
    }

    /* Ensure page-viz takes full height on mobile */
    .page-viz .page-content {
        height: 100%;
    }

    #visualizer-container {
        /* The viz-header row is absolutely positioned on mobile, so the
           canvas takes the full page height */
        height: 100%;
    }
}

/* Even smaller screens - phones in portrait */
@media (max-width: 480px) {
    /* Toolbar positioning handled by node-drawer.css - only size buttons here */

    .workflow-toolbar button {
        min-width: 44px;
        min-height: 44px;
        padding: 6px 10px;
        font-size: 11px;
    }

    /* Zoom feedback is visible on the canvas itself; the indicator chip
       doesn't earn its width on a phone */
    .workflow-toolbar #workflow-zoom-level {
        display: none;
    }

    /* Phone portrait: give the project selector the brand title's space */
    .mobile-header h1 {
        display: none;
    }

    /* Match node-drawer.css's phone anchor (parity, see ≤768px block) */
    .workflow-toolbar {
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
}

/* Notification animations */
@keyframes slide-in-right {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.workflow-notification {
    animation: slide-in-right 0.3s ease;
}

/* Enhanced X6 node hover effects */
.x6-node:hover {
    filter: brightness(1.1);
}

/* Ensure proper z-index for hover action buttons */
.x6-graph-svg {
    overflow: visible !important;
}

/* ============================================
   CONNECTIONS PANEL STYLES
   ============================================ */
.connections-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: #1F2937;
    border-left: 1px solid #374151;
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.connections-panel.open {
    right: 0;
}

.connections-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #374151;
    background: #111827;
    flex-shrink: 0;
}

.connections-panel .panel-header h2 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.connections-panel .close-btn {
    background: transparent;
    border: none;
    color: #9CA3AF;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: color 0.2s;
}

.connections-panel .close-btn:hover {
    color: white;
}

.connections-panel .panel-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.connections-panel .refresh-btn {
    background: transparent;
    border: none;
    color: #9CA3AF;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    transition: color 0.2s, transform 0.3s;
}

.connections-panel .refresh-btn:hover {
    color: white;
    transform: rotate(180deg);
}

.connections-panel .panel-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

/* Search input */
.connections-search {
    padding: 12px 16px;
    border-bottom: 1px solid #374151;
    background: #111827;
    display: flex;
    align-items: center;
    gap: 12px;
}

.connections-search .search-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #374151;
    background: #1F2937;
    color: #F9FAFB;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.connections-search .search-input:focus {
    border-color: #6366F1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.connections-search .search-input::placeholder {
    color: #6B7280;
}

.connections-search .search-count {
    font-size: 12px;
    color: #9CA3AF;
    white-space: nowrap;
}

/* Show more button */
.show-more-btn {
    width: calc(100% - 16px);
    margin: 8px;
    padding: 10px 12px;
    background: transparent;
    border: 1px dashed #374151;
    border-radius: 8px;
    color: #9CA3AF;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.show-more-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: #6366F1;
    color: #818CF8;
}

/* Connection sections */
.connection-section {
    border-bottom: 1px solid #374151;
}

.section-header {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    background: #111827;
    cursor: pointer;
    gap: 10px;
    user-select: none;
    transition: background 0.2s;
}

.section-header:hover {
    background: #1a2332;
}

.section-icon {
    font-size: 16px;
}

.section-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    color: #E5E7EB;
}

.section-count {
    background: #374151;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    color: #9CA3AF;
}

.section-chevron {
    color: #6B7280;
    transition: transform 0.2s;
    font-size: 12px;
}

.section-header.collapsed .section-chevron {
    transform: rotate(-90deg);
}

.section-content {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-content.collapsed {
    display: none;
}

/* Integration cards */
.integration-card {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-radius: 10px;
    gap: 12px;
    transition: background 0.2s;
    background: rgba(0, 0, 0, 0.2);
}

.integration-card:hover {
    background: rgba(255, 255, 255, 0.05);
}

.integration-card.connected {
    background: rgba(16, 185, 129, 0.1);
}

.integration-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    flex-shrink: 0;
}

.integration-icon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    padding: 2px;
    box-sizing: content-box;
}

.integration-icon .icon-emoji-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.integration-info {
    flex: 1;
    min-width: 0;
}

.integration-name {
    font-weight: 600;
    font-size: 14px;
    color: #F9FAFB;
    margin-bottom: 2px;
}

.integration-meta {
    font-size: 11px;
    color: #9CA3AF;
    display: flex;
    gap: 8px;
    align-items: center;
}

.integration-meta .auth-badge {
    background: rgba(99, 102, 241, 0.2);
    color: #818CF8;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
}

.integration-action {
    flex-shrink: 0;
}

.integration-action .btn-connect {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.integration-action .btn-connect.primary {
    background: #3B82F6;
    color: white;
}

.integration-action .btn-connect.primary:hover {
    background: #2563EB;
}

.integration-action .btn-connect.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #9CA3AF;
}

.integration-action .btn-connect.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.integration-action .btn-connect.danger {
    background: rgba(239, 68, 68, 0.2);
    color: #F87171;
}

.integration-action .btn-connect.danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

.integration-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #10B981;
    margin-right: 8px;
}

.integration-status .status-dot {
    width: 6px;
    height: 6px;
    background: #10B981;
    border-radius: 50%;
}

.integration-status.platform {
    color: #8B5CF6;
}

.integration-status.platform .status-dot {
    background: #8B5CF6;
}

.platform-badge {
    font-size: 10px;
    color: #8B5CF6;
    background: rgba(139, 92, 246, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

/* Credit display in header — now an <a> link */
.credit-display {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    color: #e5e7eb;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.credit-display:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: #e5e7eb;
}

.credit-display .demo-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    margin-right: 8px;
}

.credit-display .balance-amount {
    font-weight: 600;
}

.loading-credits {
    color: #9ca3af;
    font-size: 12px;
}

/* Header connections button */
.header-connections-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    color: #93c5fd;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.header-connections-btn:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.5);
}

.connections-badge {
    background: #10B981;
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.connections-badge.empty {
    background: #6B7280;
}

/* API Key Modal */
.apikey-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.apikey-modal.hidden {
    display: none;
}

.apikey-modal .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.apikey-modal .modal-content {
    position: relative;
    background: #1F2937;
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 420px;
    border: 1px solid #374151;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.apikey-modal h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.apikey-modal .apikey-input {
    width: 100%;
    padding: 12px 14px;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-family: monospace;
    margin-bottom: 8px;
}

.apikey-modal .apikey-input:focus {
    outline: none;
    border-color: #3B82F6;
}

.apikey-modal .modal-help {
    font-size: 12px;
    color: #9CA3AF;
    margin-bottom: 20px;
}

.apikey-modal .modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Connections overlay backdrop */
.connections-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.connections-backdrop.open {
    opacity: 1;
    visibility: visible;
}

/* Mobile responsive connections */
@media (max-width: 768px) {
    .connections-panel {
        width: 100%;
        right: -100%;
        height: auto;
        bottom: calc(var(--peek-collapsed) + var(--safe-bottom));
    }

    .connections-backdrop {
        bottom: calc(var(--peek-collapsed) + var(--safe-bottom));
    }

    /* Let left side shrink so balance stays visible.
       Do NOT use overflow:hidden here — it clips the
       project-selector dropdown which is absolutely positioned. */
    .mobile-header > div:first-child {
        flex: 1 1 0;
        min-width: 0;
    }

    /* Prevent right side (balance, connections) from being pushed off-screen */
    .mobile-header > div:last-child {
        flex-shrink: 0;
        gap: 8px;
    }

    /* Subtraction over shrinking: a header that relies on shrinking-to-fit
       ends up with chips painting over each other. Hide the low-priority
       items instead of compressing everything. */
    #pipeline-status,
    .mobile-header .new-workflow-btn {
        display: none;
    }

    /* The track colour (green/grey) already conveys Enabled/Disabled */
    .mobile-header .workflow-enabled-toggle {
        padding: 6px 8px;
        gap: 0;
    }

    .mobile-header .toggle-label {
        display: none;
    }

    /* Save status: icon-only on mobile */
    .mobile-header .save-status {
        font-size: 0;
        padding: 2px 6px;
    }

    .mobile-header .save-status::after {
        font-size: 13px;
        line-height: 1.2;
    }

    .mobile-header .status-saved::after {
        content: '✓';
    }

    .mobile-header .status-saving::after {
        content: '…';
    }

    .mobile-header .status-unsaved::after {
        content: '●';
    }

    .mobile-header .status-draft::after {
        content: '◌';
    }

    .mobile-header h1 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #project-selector-btn {
        max-width: min(120px, 25vw);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .credit-display {
        padding: 4px 8px;
        font-size: 12px;
        white-space: nowrap;
    }

    .credit-display .demo-badge {
        padding: 1px 4px;
        font-size: 8px;
        margin-right: 4px;
    }

    .header-connections-btn {
        padding: 6px 8px;
        font-size: 12px;
    }

    .header-connections-btn .btn-text {
        display: none;
    }

    /* Mobile bottom nav - third tab */
    .page-switcher {
        justify-content: space-around;
    }

    .switcher-btn {
        flex: 1;
        max-width: 33.333%;
    }
}

/* Empty state for sections */
.section-empty {
    padding: 20px;
    text-align: center;
    color: #6B7280;
    font-size: 13px;
}

/* ============================================
   ENHANCEMENT / GOVERNOR PANE STYLES
   ============================================ */

/* Governor Pane Container */
#governor-pane {
    width: 320px;
    min-width: 280px;
    max-width: 400px;
    height: 100%;
    background: #1a1a2e;
    border-left: 1px solid #2d2d44;
    display: flex;
    flex-direction: column;
    color: #e5e7eb;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#governor-pane.hidden {
    display: none;
}

.governor-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.governor-header {
    padding: 16px;
    border-bottom: 1px solid #2d2d44;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.governor-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.status-badge {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: capitalize;
    font-weight: 500;
}

.enhancement-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 16px;
    background: #16162a;
    flex-shrink: 0;
}

.enhancement-summary .stat {
    text-align: center;
}

.enhancement-summary .number {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.enhancement-summary .label {
    font-size: 10px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.enhancement-checklist {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
    scrollbar-color: #4b5563 transparent;
}

.enhancement-checklist h4 {
    margin: 0 0 12px;
    font-size: 12px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: #16162a;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.checklist-item:hover {
    background: #1e1e38;
}

.checklist-item.selected {
    background: #1e1e38;
    border-color: #3b82f6;
}

/* Custom checkbox */
.checkbox-wrapper {
    position: relative;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.checkbox-wrapper input {
    opacity: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    cursor: pointer;
    margin: 0;
}

.checkbox-wrapper .checkmark {
    position: absolute;
    top: 0;
    left: 0;
    width: 18px;
    height: 18px;
    background: #2d2d44;
    border-radius: 4px;
    border: 1px solid #4b5563;
    transition: all 0.2s;
}

.checkbox-wrapper input:checked+.checkmark {
    background: #3b82f6;
    border-color: #3b82f6;
}

.checkbox-wrapper input:checked+.checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.plan-content {
    flex: 1;
    min-width: 0;
}

.plan-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.risk-indicator {
    font-size: 12px;
    line-height: 1;
}

.plan-description {
    font-size: 13px;
    color: #e5e7eb;
    line-height: 1.4;
}

.plan-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: #9ca3af;
}

.plan-meta .impact {
    color: #22c55e;
}

.expand-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: #2d2d44;
    color: #9ca3af;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.expand-btn:hover {
    background: #3b82f6;
    color: #fff;
}

.no-plans {
    color: #9ca3af;
    font-size: 13px;
    text-align: center;
    padding: 24px;
}

/* Chain of Thought */
.chain-of-thought {
    padding: 16px;
    background: #16162a;
    border-top: 1px solid #2d2d44;
    flex-shrink: 0;
    max-height: 200px;
    overflow-y: auto;
}

.cot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.cot-header h4 {
    margin: 0;
    font-size: 13px;
    color: #fff;
    font-weight: 500;
}

.close-cot-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-cot-btn:hover {
    background: #2d2d44;
    color: #fff;
}

.cot-content p {
    margin: 0;
    font-size: 13px;
    color: #d1d5db;
    line-height: 1.6;
}

.cot-meta {
    display: flex;
    gap: 16px;
    font-size: 11px;
    margin-top: 12px;
}

.enhancement-type {
    color: #9ca3af;
    text-transform: capitalize;
}

.risk-level {
    font-weight: 500;
    text-transform: capitalize;
}

/* Governor Actions */
.governor-actions {
    padding: 16px;
    border-top: 1px solid #2d2d44;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.governor-actions .btn-primary {
    flex: 1;
    padding: 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.governor-actions .btn-primary:hover:not(:disabled) {
    background: #2563eb;
}

.governor-actions .btn-primary:disabled,
.governor-actions .btn-primary.disabled {
    background: #4b5563;
    cursor: not-allowed;
    opacity: 0.7;
}

.governor-actions .btn-secondary {
    padding: 12px 16px;
    background: transparent;
    color: #9ca3af;
    border: 1px solid #4b5563;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.governor-actions .btn-secondary:hover {
    background: #2d2d44;
    color: #e5e7eb;
    border-color: #6b7280;
}

/* Verification Status */
.verification-status {
    padding: 12px 16px;
    font-size: 13px;
    flex-shrink: 0;
}

.verification-status.success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.verification-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Loading State */
.governor-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    gap: 24px;
}

.governor-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #2d2d44;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: governor-spin 1s linear infinite;
}

@keyframes governor-spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-steps {
    text-align: center;
}

.loading-steps p {
    margin: 8px 0;
    font-size: 13px;
    color: #6b7280;
    transition: all 0.3s;
}

.loading-steps p.active {
    color: #e5e7eb;
    font-weight: 500;
}

/* Empty State */
.governor-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.governor-empty h3 {
    margin: 0 0 12px;
    font-size: 16px;
    color: #fff;
}

.governor-empty p {
    margin: 0;
    font-size: 13px;
    color: #9ca3af;
    max-width: 240px;
    line-height: 1.5;
}

/* Diff Badges */
.diff-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: white;
    z-index: 100;
    pointer-events: none;
    animation: badge-pop 0.3s ease;
}

@keyframes badge-pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    70% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.plan-highlighted {
    animation: pulse-highlight 1.5s ease infinite;
}

@keyframes pulse-highlight {

    0%,
    100% {
        filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
    }

    50% {
        filter: drop-shadow(0 0 16px rgba(59, 130, 246, 0.8));
    }
}

/* Enhance Button */
.enhance-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.enhance-btn:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.enhance-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.enhance-btn .icon {
    font-size: 14px;
}

/* Enhance Mode Dropdown */
.enhance-mode-wrapper {
    position: relative;
}

.enhance-mode-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #1a1a2e;
    border: 1px solid #2d2d44;
    border-radius: 8px;
    overflow: hidden;
    z-index: 100;
    min-width: 200px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.enhance-mode-dropdown.hidden {
    display: none;
}

.enhance-mode-option {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.enhance-mode-option:hover {
    background: #2d2d44;
}

.enhance-mode-option .mode-name {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 4px;
}

.enhance-mode-option .mode-desc {
    font-size: 11px;
    color: #9ca3af;
}

/* Mobile responsive */
@media (max-width: 768px) {
    #governor-pane {
        position: fixed;
        width: 100%;
        max-width: none;
        z-index: 1000;
        transform: translateX(100%);
    }

    #governor-pane:not(.hidden) {
        transform: translateX(0);
    }
}

/* =====================================================================
   PROGRESSIVE PRIMARY ACTION BUTTON & AUTONOMY TOGGLE
   ===================================================================== */

/* Post-simulation controls row */
.cmd-group.post-sim {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

#simulate-again-btn.btn-sm {
    font-size: 13px;
    padding: 6px 14px;
}

/* Loading state for primary button */
.workflow-btn.btn-loading {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Autonomy toggle switch */
.autonomy-toggle-wrapper {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.autonomy-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.autonomy-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.2s;
    white-space: nowrap;
}

.autonomy-label.active {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.autonomy-switch {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.autonomy-checkbox {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.autonomy-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    transition: background 0.3s;
}

.autonomy-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.autonomy-checkbox:checked + .autonomy-slider {
    background: #f59e0b;
}

.autonomy-checkbox:checked + .autonomy-slider::before {
    transform: translateX(16px);
}

.autonomy-checkbox:focus-visible + .autonomy-slider {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}
