/* Terminal Section - Simple Fixed Layout */
#terminal {
    /* Normal section, no special positioning */
}

/* workbench_0110: durable notes and complete artifact lifecycle */
.ai-notes-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, .72fr);
    gap: 1rem;
}

.ai-note-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: .75rem;
    width: 100%;
    padding: .8rem;
    border: 1px solid #e2e8f0;
    border-radius: .75rem;
    background: #fff;
}

.ai-note-card:hover,
.ai-note-card.selected {
    border-color: #0f9f8f;
    box-shadow: 0 0 0 3px rgba(15, 159, 143, .1);
}

.ai-note-card strong,
.ai-note-card small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-note-card strong { color: #1e293b; font-size: .8rem; }
.ai-note-card small { margin-top: .25rem; color: #64748b; font-size: .68rem; }
.ai-note-card em {
    padding: .2rem .4rem;
    border-radius: 999px;
    color: #0f766e;
    background: #e6fffa;
    font-size: .58rem;
    font-style: normal;
    text-transform: uppercase;
}

.artifact-card-remove,
.artifact-remove-button { color: #b42318 !important; }

@media (max-width: 900px) {
    .ai-notes-workspace { grid-template-columns: 1fr; }
    .ai-note-card { grid-template-columns: auto minmax(0, 1fr); }
    .ai-note-card em { display: none; }
}

/* Only show terminal when it's the active section */
#terminal.hidden {
    display: none !important;
}

/* Fixed-size container that defines the terminal display region */
.terminal-fixed-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 136px);
    overflow: hidden; /* CRITICAL: Hide any overflow */
}

/* Terminal Frame - fits exactly to container */
.terminal-frame {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    background-color: #2a2a3c;
    border: 1px solid #3a3a4c;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3), 0 6px 6px rgba(0, 0, 0, 0.2);
}

/* Terminal title bar - fixed height */
.terminal-titlebar {
    background: linear-gradient(to bottom, #3a3a4c, #333342);
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    border-bottom: 1px solid #444;
    user-select: none;
}

.terminal-title {
    color: #ccc;
    font-size: 12px;
    font-weight: 600;
}

.terminal-controls {
    display: flex;
    gap: 6px;
}

.terminal-control {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

/* Terminal body - fills remaining space */
.terminal-body {
    flex: 1;
    background-color: #1e1e2e;
    padding: 8px;
    overflow: hidden; /* CRITICAL: Hide overflow */
    position: relative;
}

.remote-desktop-shell {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.15), transparent 28%),
        radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.12), transparent 26%),
        linear-gradient(160deg, #0f172a, #111827 45%, #1f2937);
    border-radius: 14px;
    padding: 12px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.remote-desktop-section {
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
    box-sizing: border-box;
}

.remote-desktop-section > .flex.items-center.justify-between.mb-4.bg-gray-100.rounded-md.p-3.gap-4.flex-wrap {
    flex: 0 0 auto;
    margin-bottom: 0;
}

.remote-desktop-canvas-wrap {
    min-height: 0;
    height: 100%;
    flex: 1 1 auto;
    display: grid;
    place-items: center;
    overflow: hidden;
    position: relative;
    padding: 12px;
    box-sizing: border-box;
    border-radius: 10px;
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.6), rgba(15, 23, 42, 0.92)),
        repeating-linear-gradient(45deg, rgba(148, 163, 184, 0.04) 0, rgba(148, 163, 184, 0.04) 10px, transparent 10px, transparent 20px);
    outline: none;
}

.remote-desktop-canvas-wrap:fullscreen {
    height: 100vh;
    padding: 18px;
    border-radius: 0;
}

.remote-desktop-canvas-wrap:focus {
    box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.55);
}

.remote-desktop-canvas-wrap.capturing {
    box-shadow: inset 0 0 0 2px rgba(14, 165, 233, 0.9), 0 0 0 1px rgba(14, 165, 233, 0.35);
}

.remote-desktop-stage {
    position: relative;
    width: 960px;
    height: 540px;
    flex: none;
    overflow: hidden;
}

.remote-desktop-canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 6px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
    background: #020617;
}

.remote-desktop-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.78rem;
}

.desktop-stream-stats {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    background: rgba(15, 23, 42, 0.08);
    color: #334155;
    font-size: 0.75rem;
    font-weight: 600;
}

.desktop-clipboard-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    background: rgba(14, 116, 144, 0.08);
    color: #155e75;
    font-size: 0.72rem;
    font-weight: 600;
    font-family: Consolas, "Courier New", monospace;
}

.desktop-clipboard-status[data-state="warning"] {
    background: rgba(217, 119, 6, 0.12);
    color: #92400e;
}

.desktop-clipboard-status[data-state="error"] {
    background: rgba(220, 38, 38, 0.12);
    color: #991b1b;
}

.desktop-clipboard-status[data-state="ok"] {
    background: rgba(22, 163, 74, 0.12);
    color: #166534;
}

.desktop-clipboard-fetch {
    border: 1px solid rgba(14, 116, 144, 0.28);
    border-radius: 9999px;
    padding: 0.22rem 0.7rem;
    background: rgba(255, 255, 255, 0.92);
    color: #0f766e;
    font-size: 0.72rem;
    font-weight: 700;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.desktop-clipboard-fetch:hover {
    background: rgba(14, 116, 144, 0.08);
    border-color: rgba(14, 116, 144, 0.48);
}

.desktop-clipboard-download {
    border: 1px solid rgba(37, 99, 235, 0.28);
    border-radius: 9999px;
    padding: 0.22rem 0.7rem;
    background: rgba(255, 255, 255, 0.92);
    color: #1d4ed8;
    font-size: 0.72rem;
    font-weight: 700;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.desktop-clipboard-download:hover {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.48);
}

.desktop-stats-sep {
    color: #94a3b8;
}

.desktop-remote-cursor {
    position: absolute;
    left: 0;
    top: 0;
    width: 18px;
    height: 24px;
    pointer-events: none;
    z-index: 20;
    transform-origin: top left;
}

.desktop-remote-cursor.hidden {
    display: none;
}

.desktop-remote-cursor-arrow {
    position: relative;
    width: 0;
    height: 0;
    border-top: 18px solid #ffffff;
    border-right: 12px solid transparent;
    filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.8));
}

.desktop-remote-cursor-arrow::after {
    content: '';
    position: absolute;
    left: -10px;
    top: -18px;
    width: 0;
    height: 0;
    border-top: 18px solid rgba(15, 23, 42, 0.95);
    border-right: 12px solid transparent;
    transform: translate(1px, 1px);
    z-index: -1;
}

.desktop-remote-cursor.pressing {
    transform: scale(0.92);
}

.desktop-recorder-toolbar-button {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.25rem 0.55rem;
    border: 1px solid rgba(79, 70, 229, 0.2);
    border-radius: 0.5rem;
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.8rem;
    font-weight: 700;
}

.desktop-recorder-toolbar-button:hover {
    background: #e0e7ff;
}

.desktop-recorder-toolbar-button .desktop-recording-state-chip {
    padding: 0.2rem 0.48rem;
    font-size: 0.62rem;
}

.desktop-recorder-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(5px);
}

.desktop-recorder-modal.hidden {
    display: none;
}

.desktop-recorder-dialog {
    width: min(920px, 100%);
    max-height: min(760px, calc(100vh - 3rem));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.36);
}

.desktop-recorder-close {
    width: 2.25rem;
    height: 2.25rem;
    flex: none;
    border: 0;
    border-radius: 0.7rem;
    background: #eef2f7;
    color: #475569;
}

.desktop-recorder-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.desktop-recorder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
}

.desktop-recorder-toggle {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    min-width: 0;
    background: transparent;
    color: #0f172a;
    text-align: left;
}

.desktop-recorder-toggle-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, 0.08);
    color: #1d4ed8;
    flex: none;
}

.desktop-recorder-toggle-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.desktop-recorder-toggle-title {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.desktop-recorder-toggle-summary {
    font-size: 0.78rem;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.desktop-recorder-toggle[aria-expanded="true"] .desktop-recorder-toggle-icon i {
    transform: rotate(90deg);
}

.desktop-recorder-toggle-icon i {
    transition: transform 140ms ease;
}

.desktop-recording-state-chip,
.desktop-recording-live-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    padding: 0.33rem 0.8rem;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.desktop-recording-state-chip[data-state="idle"],
.desktop-recording-live-pill[data-state="idle"] {
    background: rgba(148, 163, 184, 0.16);
    color: #475569;
}

.desktop-recording-state-chip[data-state="selecting"],
.desktop-recording-live-pill[data-state="selecting"] {
    background: rgba(14, 165, 233, 0.14);
    color: #0369a1;
}

.desktop-recording-state-chip[data-state="recording"],
.desktop-recording-live-pill[data-state="recording"] {
    background: rgba(220, 38, 38, 0.14);
    color: #b91c1c;
}

.desktop-recording-state-chip[data-state="saving"],
.desktop-recording-live-pill[data-state="saving"] {
    background: rgba(217, 119, 6, 0.14);
    color: #b45309;
}

.desktop-recording-state-chip[data-state="error"],
.desktop-recording-live-pill[data-state="error"] {
    background: rgba(127, 29, 29, 0.14);
    color: #991b1b;
}

.desktop-recorder-body {
    border-top: 1px solid rgba(148, 163, 184, 0.14);
    padding: 1rem;
    overflow: auto;
}

.desktop-recorder-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem;
}

.desktop-recorder-card {
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(255, 255, 255, 0.88);
    padding: 0.95rem 1rem;
}

.desktop-recorder-card-wide {
    grid-column: auto;
}

.desktop-recorder-card-title {
    font-size: 0.78rem;
    font-weight: 800;
    color: #334155;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.7rem;
}

.desktop-recorder-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.desktop-recorder-selection-row,
.desktop-recorder-action-row,
.desktop-recorder-link-row,
.desktop-recorder-live-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.desktop-recorder-secondary-btn,
.desktop-recorder-primary-btn,
.desktop-recorder-stop-btn,
.desktop-recorder-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border-radius: 9999px;
    padding: 0.52rem 0.95rem;
    font-size: 0.8rem;
    font-weight: 700;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
}

.desktop-recorder-secondary-btn {
    border: 1px solid rgba(59, 130, 246, 0.2);
    background: rgba(255, 255, 255, 0.94);
    color: #1d4ed8;
}

.desktop-recorder-secondary-btn:hover {
    background: rgba(219, 234, 254, 0.62);
}

.desktop-recorder-primary-btn {
    border: 1px solid rgba(21, 128, 61, 0.16);
    background: linear-gradient(180deg, #16a34a, #15803d);
    color: #f8fafc;
}

.desktop-recorder-primary-btn:hover {
    background: linear-gradient(180deg, #22c55e, #15803d);
}

.desktop-recorder-stop-btn {
    border: 1px solid rgba(220, 38, 38, 0.16);
    background: linear-gradient(180deg, #ef4444, #dc2626);
    color: #f8fafc;
}

.desktop-recorder-stop-btn:hover {
    background: linear-gradient(180deg, #f87171, #dc2626);
}

.desktop-recorder-link {
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(255, 255, 255, 0.95);
    color: #0f172a;
    text-decoration: none;
}

.desktop-recorder-link:hover {
    background: rgba(241, 245, 249, 0.95);
}

.desktop-recorder-secondary-btn:disabled,
.desktop-recorder-primary-btn:disabled,
.desktop-recorder-stop-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.desktop-recorder-checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.82rem;
    color: #0f172a;
}

.desktop-recorder-checkbox-row input {
    width: 0.95rem;
    height: 0.95rem;
}

.desktop-recording-note {
    font-size: 0.78rem;
    line-height: 1.45;
    color: #475569;
}

.desktop-recording-folder-note code,
.desktop-recording-output-path {
    font-family: Consolas, "Courier New", monospace;
}

.desktop-recording-output {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.desktop-recording-output-path {
    font-size: 0.82rem;
    color: #0f172a;
    word-break: break-all;
}

.desktop-recording-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 16;
}

.desktop-recording-overlay.armed {
    pointer-events: auto;
    cursor: crosshair;
    background: rgba(15, 23, 42, 0.12);
}

.desktop-recording-selection-box {
    position: absolute;
    border: 2px solid rgba(14, 165, 233, 0.95);
    background: rgba(14, 165, 233, 0.12);
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.2);
    border-radius: 12px;
    overflow: hidden;
}

.desktop-recording-selection-box.preview {
    box-shadow: none;
    background: rgba(14, 165, 233, 0.08);
}

.desktop-recording-selection-label {
    position: absolute;
    left: 0.55rem;
    top: 0.55rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 9999px;
    padding: 0.2rem 0.55rem;
    background: rgba(15, 23, 42, 0.84);
    color: #f8fafc;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* xterm.js container - fits exactly to terminal-body */
#xterm-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Let xterm.js calculate its own size within the container */
.xterm {
    width: 100%;
    height: 100%;
}

.xterm-viewport {
    overflow-y: auto;
    overflow-x: hidden;
}

.xterm-screen {
    /* Let xterm.js manage this */
}

/* Handle scrollbars consistently */
.xterm .xterm-viewport::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.xterm .xterm-viewport::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.xterm .xterm-viewport::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.xterm .xterm-viewport::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Status indicator animations */
@keyframes blink {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.status-connecting {
  animation: blink 1.5s infinite;
}

/* File Explorer */
.file-explorer-container {
  background-color: var(--card-background);
  border-radius: 10px;
  box-shadow: var(--shadow);
  height: calc(100vh - 6rem);
  display: flex;
  flex-direction: column;
}

/* File Explorer Button Styling */
.file-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: none;
    cursor: pointer;
    margin-right: 6px;
    transition: background-color 0.2s;
}

.file-action-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.file-action-btn:last-child {
    margin-right: 0;
}

/* File Explorer Table */
#file-explorer table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    table-layout: fixed;
}

#file-explorer table th,
#file-explorer table td {
    padding: 0.2rem 0.8rem;
}

/* File Explorer column widths */
#file-explorer table th:nth-child(1),
#file-explorer table td:nth-child(1) {
    width: 40%;
}

#file-explorer table th:nth-child(2),
#file-explorer table td:nth-child(2) {
    width: 10%;
}

#file-explorer table th:nth-child(3),
#file-explorer table td:nth-child(3) {
    width: 12%;
}

#file-explorer table th:nth-child(4),
#file-explorer table td:nth-child(4) {
    width: 20%;
}

#file-explorer table th:nth-child(5),
#file-explorer table td:nth-child(5) {
    width: 18%;
}

#file-explorer .file-name {
    display: flex;
    align-items: center;
    overflow: hidden;
}

#file-explorer .file-name span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Multi-select styling */
.multi-select-toolbar {
    background-color: #f0f9ff;
    padding: 8px 16px;
    border-radius: 4px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.multi-select-toolbar.hidden {
    display: none;
}

.file-checkbox {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.bulk-action-btn {
    padding: 6px 12px;
    border-radius: 4px;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    margin-left: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.bulk-action-btn i {
    margin-right: 6px;
}

.bulk-action-btn.btn-danger {
    background-color: #fee2e2;
    border-color: #fecaca;
    color: #b91c1c;
}

.bulk-action-btn.btn-danger:hover {
    background-color: #fecaca;
}

/* Responsive Design */
@media (max-width: 992px) {
  .dashboard-row {
    flex-direction: column;
  }
  
  .process-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .remote-desktop-section {
    height: auto;
    min-height: 100vh;
  }

  .desktop-recorder-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .desktop-recorder-card-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .desktop-recorder-modal {
    padding: 0;
  }

  .desktop-recorder-dialog {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .desktop-recorder-grid {
    grid-template-columns: 1fr;
  }

  .desktop-recorder-card-wide {
    grid-column: auto;
  }
}

/* Notification styles */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background-color: white;
    color: #333;
    border-left: 4px solid #4CAF50;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-radius: 4px;
    z-index: 9999;
    display: flex;
    align-items: center;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification.error {
    border-left-color: #F44336;
}

.notification i {
    margin-right: 10px;
    font-size: 18px;
    color: #4CAF50;
}

.notification.error i {
    color: #F44336;
}

/* Modal form styling */
.modal-content input[type="text"],
.modal-content input[type="password"],
.modal-content input[type="email"],
.modal-content input[type="number"],
#modal-content input[type="text"],
#modal-content input[type="password"],
#modal-content input[type="email"],
#modal-content input[type="number"],
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    margin-top: 6px;
}

/* Form group proper spacing */
.form-group {
    margin-bottom: 16px;
    width: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

/* Sidebar collapse/expand */
.sidebar {
    transition: width 0.3s ease, transform 0.3s ease;
}

.sidebar.collapsed {
    width: 64px !important;
}

.sidebar.collapsed .sidebar-brand-text {
    display: none;
}

.sidebar.collapsed .min-h-16 {
    justify-content: center;
    padding: 1rem;
}

.sidebar.collapsed .min-h-16 .flex.items-start {
    justify-content: center;
}

.sidebar.collapsed .min-h-16 i {
    margin-right: 0;
}

.sidebar.collapsed nav ul li {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    margin-left: 0.25rem;
    margin-right: 0.25rem;
}

.sidebar.collapsed nav ul li span {
    display: none;
}

.sidebar.collapsed nav ul li i {
    margin-right: 0;
}

.sidebar.collapsed #editor-tabs-container {
    display: none;
}

.sidebar.collapsed .sidebar-toggle span {
    display: none;
}

.main-content {
    transition: margin-left 0.3s ease;
}

.main-content.sidebar-collapsed {
    margin-left: 64px !important;
}

.mobile-sidebar-toggle,
.mobile-sidebar-backdrop {
    display: none;
}

/* AI Operations full-height adaptive layout */
#ai-operations:not(.hidden) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-sizing: border-box;
}

.ai-ops-content {
    flex: 1;
    min-height: 0;
}

.ai-activity-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(20rem, 0.95fr);
    gap: 1rem;
}

.artifact-workspace {
    display: grid;
    grid-template-columns: 20rem minmax(0, 1fr);
    gap: 1rem;
}

.artifact-library,
.artifact-viewer {
    border: 1px solid #e2e8f0;
}

.artifact-contract summary {
    list-style: none;
}

.artifact-contract summary::-webkit-details-marker {
    display: none;
}

.artifact-app-icon {
    display: inline-grid;
    width: 2.75rem;
    height: 2.75rem;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid #c7d2fe;
    border-radius: 0.9rem;
    background: linear-gradient(145deg, #eef2ff, #ffffff);
    color: #4f46e5;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.12);
    font-size: 1rem;
}

.artifact-app-icon-large {
    width: 4rem;
    height: 4rem;
    border-radius: 1.15rem;
    font-size: 1.45rem;
}

.artifact-card {
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 0.9rem;
    background: #ffffff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.artifact-card:hover {
    border-color: #a5b4fc;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

.artifact-card.selected {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.13);
}

.artifact-card-main {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem;
    text-align: left;
}

.artifact-card-copy {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.artifact-card-title,
.artifact-card-description,
.artifact-card-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.artifact-card-title {
    color: #0f172a;
    font-size: 0.875rem;
    font-weight: 700;
}

.artifact-card-description {
    margin-top: 0.15rem;
    color: #64748b;
    font-size: 0.72rem;
}

.artifact-card-meta {
    margin-top: 0.2rem;
    color: #94a3b8;
    font-size: 0.64rem;
}

.artifact-status {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 0.18rem 0.45rem;
    border: 1px solid transparent;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: capitalize;
}

.artifact-status-active {
    border-color: #a7f3d0;
    background: #ecfdf5;
    color: #047857;
}

.artifact-status-stopped {
    border-color: #e2e8f0;
    background: #f8fafc;
    color: #64748b;
}

.artifact-status-error {
    border-color: #fecaca;
    background: #fff1f2;
    color: #be123c;
}

.artifact-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
    padding: 0 0.75rem 0.7rem;
}

.artifact-card-actions button,
.artifact-card-actions a {
    display: inline-flex;
    min-height: 1.8rem;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    border-radius: 0.5rem;
    background: #f1f5f9;
    padding: 0.35rem 0.55rem;
    color: #475569;
    font-size: 0.68rem;
}

.artifact-card-actions button:hover:not(:disabled),
.artifact-card-actions a:hover {
    background: #e0e7ff;
    color: #4338ca;
}

.artifact-card-actions .artifact-card-stop {
    color: #be123c;
}

.artifact-card-actions button:disabled {
    cursor: default;
    opacity: 0.4;
}

.artifact-control-button {
    display: inline-grid;
    width: 2.25rem;
    height: 2.25rem;
    place-items: center;
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    background: #ffffff;
    color: #475569;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.artifact-control-button:hover:not(:disabled) {
    border-color: #c7d2fe;
    background: #eef2ff;
    color: #4338ca;
}

.artifact-control-button:disabled {
    cursor: default;
    opacity: 0.4;
}

.artifact-stop-button {
    color: #be123c;
}

.artifact-stage iframe {
    min-height: 100%;
}

.artifact-modal {
    position: fixed;
    inset: 0;
    z-index: 2147483100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5vh 2vw;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(7px);
}

.artifact-modal.hidden {
    display: none;
}

.artifact-modal-card {
    display: flex;
    width: min(96vw, 1440px);
    height: min(94vh, 960px);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 1.1rem;
    background: #ffffff;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.42);
}

.artifact-modal-header {
    display: flex;
    min-height: 4.25rem;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.65rem 0.9rem;
    background: linear-gradient(90deg, #ffffff, #f8fafc);
}

body.artifact-modal-open {
    overflow: hidden;
}

.vh-artifact-generated-prompt {
    position: fixed;
    right: 22px;
    bottom: 88px;
    z-index: 2147483001;
    display: flex;
    width: min(360px, calc(100vw - 32px));
    align-items: center;
    gap: 0.75rem;
    border: 1px solid #c7d2fe;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.98);
    padding: 0.75rem;
    text-align: left;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(14px);
    animation: vh-artifact-prompt-in 0.24s ease-out;
}

.vh-artifact-prompt-copy {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.vh-artifact-prompt-copy strong {
    color: #4338ca;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

.vh-artifact-prompt-copy span {
    overflow: hidden;
    margin-top: 0.15rem;
    color: #0f172a;
    font-size: 0.9rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vh-artifact-prompt-arrow {
    color: #818cf8;
    font-size: 0.75rem;
}

@keyframes vh-artifact-prompt-in {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1024px) {
    .ai-activity-grid,
    .artifact-workspace {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .ai-activity-grid > section {
        min-height: 32rem;
    }

    .artifact-library {
        max-height: 24rem;
    }

    .artifact-viewer {
        min-height: 62vh;
    }
}

/* Deploy & Test full-height adaptive layout */
#remote-deploy:not(.hidden) {
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

/* Deploy & Test: live module reorder — insertion hint (does not shift layout) */
.deploy-mod-drop-before {
    box-shadow: inset 0 3px 0 0 rgb(99 102 241);
}
.deploy-mod-drop-after {
    box-shadow: inset 0 -3px 0 0 rgb(99 102 241);
}

.deploy-content {
    flex: 1;
    min-height: 0;
}

.deploy-tab {
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deploy-tab:not(.active) {
    background: transparent;
    border-color: transparent;
    color: #6b7280;
}

.deploy-tab:not(.active):hover {
    background: #e5e7eb;
}

.deploy-panel {
    display: none;
}

.deploy-panel.active {
    display: block;
}

.deploy-tab-close {
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    border-radius: 3px;
}

.deploy-tab-close:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* "Preserved" state: the server-side SSH session for this channel has been killed
   (via Stop Procedure with "Close tabs after Stop" unchecked) but the tab + its
   xterm buffer are kept around so the user can scroll through the output. The
   dashed border + stop icon prefix make it obvious at a glance that the tab is
   frozen; the user can close it with the "×" button when they're done reviewing. */
.deploy-tab.deploy-tab-preserved {
    opacity: 0.75;
    border-style: dashed;
}
.deploy-tab.deploy-tab-preserved span.truncate::before {
    content: '\23F9\00A0';
    color: #6b7280;
    font-size: 11px;
}

#deploy-fb-list > div.bg-blue-100 {
    background-color: #dbeafe;
}

#deploy-file-browser-modal .bg-black {
    background-color: rgba(0, 0, 0, 0.4);
}

/* Help modal prose: keeps the in-page markdown render readable without pulling in
   @tailwindcss/typography. Selectors are scoped to .deploy-help-prose so they
   can't leak into the main UI. */
.deploy-help-prose {
    line-height: 1.65;
    color: #1f2937;
    word-wrap: break-word;
}
.deploy-help-prose h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 1rem 0;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #e5e7eb;
    color: #111827;
}
.deploy-help-prose h2 {
    font-size: 1.175rem;
    font-weight: 600;
    margin: 1.5rem 0 0.6rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #f3f4f6;
    color: #111827;
}
.deploy-help-prose h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1.25rem 0 0.5rem 0;
    color: #1f2937;
}
.deploy-help-prose h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 1rem 0 0.4rem 0;
    color: #374151;
}
.deploy-help-prose p {
    margin: 0.55rem 0;
}
.deploy-help-prose ul,
.deploy-help-prose ol {
    margin: 0.55rem 0;
    padding-left: 1.5rem;
}
.deploy-help-prose ul { list-style: disc; }
.deploy-help-prose ol { list-style: decimal; }
.deploy-help-prose ul ul,
.deploy-help-prose ol ul {
    list-style: circle;
    margin: 0.25rem 0;
}
.deploy-help-prose li {
    margin: 0.15rem 0;
}
.deploy-help-prose li > p { margin: 0.2rem 0; }
.deploy-help-prose strong {
    font-weight: 600;
    color: #111827;
}
.deploy-help-prose em { font-style: italic; }
.deploy-help-prose code {
    background: #f3f4f6;
    color: #be185d;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-family: "Fira Code", "Courier New", monospace;
    font-size: 0.88em;
}
.deploy-help-prose pre {
    background: #1f2937;
    color: #f3f4f6;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.75rem 0;
    font-family: "Fira Code", "Courier New", monospace;
    font-size: 0.82rem;
    line-height: 1.55;
}
.deploy-help-prose pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}
.deploy-help-prose a {
    color: #2563eb;
    text-decoration: none;
}
.deploy-help-prose a:hover { text-decoration: underline; }
.deploy-help-prose hr {
    border: 0;
    border-top: 1px solid #e5e7eb;
    margin: 1.5rem 0;
}
.deploy-help-prose blockquote {
    border-left: 3px solid #d1d5db;
    padding: 0.1rem 0.75rem;
    color: #4b5563;
    margin: 0.75rem 0;
    background: #f9fafb;
    border-radius: 0 4px 4px 0;
}
.deploy-help-prose table {
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.9em;
}
.deploy-help-prose th,
.deploy-help-prose td {
    border: 1px solid #e5e7eb;
    padding: 0.4rem 0.75rem;
    text-align: left;
}
.deploy-help-prose th {
    background: #f9fafb;
    font-weight: 600;
}

.image-viewer {
    user-select: none;
}

.image-viewer-stage {
    position: relative;
    display: flex;
    height: min(62vh, 720px);
    min-height: 280px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0.75rem;
    outline: none;
    background: #0f172a;
    touch-action: none;
    overscroll-behavior: contain;
}

.image-viewer-stage:focus-visible {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.45);
}

.image-viewer-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
    transform-origin: center center;
    transition: transform 180ms ease, opacity 150ms ease;
    will-change: transform;
}

.image-viewer-image.is-gesturing {
    transition: none;
}

.image-viewer-image.is-loading {
    opacity: 0;
}

.image-viewer-status {
    position: absolute;
    inset: 50% auto auto 50%;
    z-index: 2;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background: rgba(15, 23, 42, 0.78);
    color: #e2e8f0;
    font-size: 0.875rem;
    transform: translate(-50%, -50%);
}

.image-viewer-status.image-viewer-error {
    color: #fecaca;
}

.image-viewer-nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    display: inline-flex;
    width: 2.75rem;
    height: 2.75rem;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 9999px;
    background: rgba(15, 23, 42, 0.72);
    color: #ffffff;
    transform: translateY(-50%);
    transition: background-color 150ms ease, opacity 150ms ease;
    touch-action: manipulation;
}

.image-viewer-nav:hover:not(:disabled) {
    background: rgba(37, 99, 235, 0.9);
}

.image-viewer-nav:disabled {
    cursor: default;
    opacity: 0.24;
}

.image-viewer-previous {
    left: 0.75rem;
}

.image-viewer-next {
    right: 0.75rem;
}

.image-viewer-details {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.75rem;
    color: #334155;
    font-size: 0.875rem;
}

.image-viewer-name {
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-viewer-counter {
    flex: 0 0 auto;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}

.image-viewer-hint {
    margin-top: 0.35rem;
    color: #64748b;
    font-size: 0.75rem;
    text-align: center;
}

@media (max-width: 768px) {
    .main-content,
    .main-content.sidebar-collapsed {
        width: 100%;
        margin-left: 0 !important;
    }

    .main-content > .section {
        padding-top: 4.5rem !important;
    }

    .sidebar,
    .sidebar.collapsed {
        width: min(82vw, 280px) !important;
        z-index: 40 !important;
    }

    .sidebar:not(.collapsed) {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        pointer-events: none;
    }

    .mobile-sidebar-toggle {
        position: fixed;
        top: 0.75rem;
        left: 0.75rem;
        z-index: 50;
        display: inline-flex;
        width: 2.75rem;
        height: 2.75rem;
        align-items: center;
        justify-content: center;
        border: 1px solid #dbeafe;
        border-radius: 0.75rem;
        background: #ffffff;
        color: #2563eb;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
        transition: left 0.3s ease, background-color 0.2s ease, color 0.2s ease;
    }

    .mobile-sidebar-toggle.sidebar-open {
        left: calc(min(82vw, 280px) + 0.75rem);
        border-color: rgba(255, 255, 255, 0.28);
        background: #1e293b;
        color: #ffffff;
    }

    .mobile-sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 30;
        display: block;
        border: 0;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .mobile-sidebar-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }

    body.mobile-sidebar-open {
        overflow: hidden;
    }

    [role="tablist"][aria-label="AI Operations views"] {
        flex-shrink: 0;
        overflow-x: auto;
        padding-bottom: 0.25rem;
    }

    .ai-ops-tab {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .artifact-workspace,
    .ai-activity-grid {
        gap: 0.75rem;
    }

    .artifact-viewer-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .artifact-view-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .artifact-viewer {
        min-height: 70vh;
    }

    .artifact-modal {
        padding: 0;
    }

    .artifact-modal-card {
        width: 100vw;
        height: 100dvh;
        border: 0;
        border-radius: 0;
    }

    .vh-artifact-generated-prompt {
        right: 12px;
        bottom: 78px;
        width: calc(100vw - 24px);
    }

    .deploy-toolbar {
        align-items: flex-start;
        gap: 0.75rem;
    }

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

    .deploy-content {
        flex-direction: column;
        overflow-y: auto;
    }

    .deploy-content > .w-80 {
        width: 100%;
        max-height: none !important;
        overflow-y: visible;
    }

    .deploy-content > .flex-1 {
        flex: 0 0 24rem;
        min-height: 24rem;
    }

    .image-viewer-stage {
        height: min(58vh, 520px);
        min-height: 250px;
        border-radius: 0.5rem;
    }

    .image-viewer-nav {
        width: 2.5rem;
        height: 2.5rem;
    }

    .image-viewer-previous {
        left: 0.5rem;
    }

    .image-viewer-next {
        right: 0.5rem;
    }

    .image-viewer-hint {
        font-size: 0.7rem;
    }
}
