/* Chat messages */
.msg-user {
    display: flex;
    justify-content: flex-end;
}
.msg-user .msg-bubble {
    background: #2563eb;
    color: white;
    border-radius: 1rem 1rem 0.25rem 1rem;
    max-width: 70%;
    padding: 0.75rem 1rem;
    word-break: break-word;
}
.msg-assistant {
    display: flex;
    justify-content: flex-start;
}
.msg-assistant .msg-bubble {
    background: #334155;
    color: #e2e8f0;
    border-radius: 1rem 1rem 1rem 0.25rem;
    max-width: 80%;
    padding: 0.75rem 1rem;
    word-break: break-word;
    line-height: 1.6;
}

/* Markdown in messages */
.msg-bubble p { margin-bottom: 0.5em; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble code {
    background: rgba(0,0,0,0.3);
    padding: 0.125em 0.375em;
    border-radius: 0.25em;
    font-size: 0.875em;
}
.msg-bubble pre {
    background: rgba(0,0,0,0.3);
    padding: 0.75em;
    border-radius: 0.5em;
    overflow-x: auto;
    margin: 0.5em 0;
}
.msg-bubble pre code {
    background: none;
    padding: 0;
}
.msg-bubble ul, .msg-bubble ol {
    padding-left: 1.5em;
    margin: 0.5em 0;
}
.msg-bubble li { margin-bottom: 0.25em; }
.msg-bubble strong { font-weight: 600; }
.msg-bubble h3, .msg-bubble h4 {
    font-weight: 600;
    margin: 0.75em 0 0.25em;
}

/* ====================================== */
/* Stream Bubble — Claude CLI思考过程渲染  */
/* ====================================== */

.stream-bubble {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ── Status line ── */
.sb-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: #94a3b8;
}
.sb-status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    flex-shrink: 0;
}
.sb-dot-init       { background: #475569; }
.sb-dot-connected  { background: #3b82f6; }
.sb-dot-thinking   { background: #a78bfa; animation: sb-pulse 1.2s ease-in-out infinite; }
.sb-dot-tool       { background: #f59e0b; animation: sb-pulse 1s ease-in-out infinite; }
.sb-dot-generating { background: #22c55e; }

@keyframes sb-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}
@keyframes sb-spin { to { transform: rotate(360deg); } }

/* ── Thinking block (<details>) ── */
.sb-thinking {
    background: #1a2332;
    border: 1px solid #2d3d50;
    border-radius: 0.5rem;
    font-size: 0.82rem;
    overflow: hidden;
}
.sb-thinking-summary {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.65rem;
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.78rem;
    user-select: none;
    list-style: none;
}
.sb-thinking-summary::-webkit-details-marker { display: none; }
.sb-thinking-summary::marker { content: ''; }

.sb-thinking-spinner {
    width: 0.85rem;
    height: 0.85rem;
    border: 2px solid #334155;
    border-top-color: #a78bfa;
    border-radius: 50%;
    animation: sb-spin 0.8s linear infinite;
    flex-shrink: 0;
}
.sb-thinking-done-icon {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
}
.sb-thinking-done-icon::after {
    content: '';
    position: absolute;
    left: 0.22rem;
    top: 0.12rem;
    width: 0.25rem;
    height: 0.42rem;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.sb-thinking-body {
    padding: 0.4rem 0.65rem;
    max-height: 200px;
    overflow-y: auto;
    color: #7c8ba0;
    font-size: 0.75rem;
    font-style: italic;
    font-family: 'Menlo', 'Consolas', monospace;
    line-height: 1.55;
    word-break: break-all;
    white-space: pre-wrap;
    border-top: 1px solid #2d3d50;
}

/* ── Tool card ── */
.sb-tool {
    background: #1a2332;
    border: 1px solid #2d3d50;
    border-radius: 0.5rem;
    padding: 0.45rem 0.65rem;
    font-size: 0.82rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.sb-tool-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.sb-tool-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    flex-shrink: 0;
}
.sb-tool-running { background: #f59e0b; animation: sb-pulse 1s ease-in-out infinite; }
.sb-tool-ok      { background: #22c55e; animation: none; }
.sb-tool-fail    { background: #ef4444; animation: none; }

.sb-tool-name {
    color: #cbd5e1;
    font-weight: 500;
    font-size: 0.78rem;
}
.sb-tool-badge {
    font-size: 0.65rem;
    padding: 0.05rem 0.4rem;
    border-radius: 9999px;
    background: #854d0e;
    color: #fde68a;
    white-space: nowrap;
    margin-left: auto;
}
.sb-badge-ok {
    background: #166534;
    color: #86efac;
}
.sb-badge-fail {
    background: #991b1b;
    color: #fca5a5;
}
.sb-tool-input {
    color: #64748b;
    font-size: 0.72rem;
    font-family: 'Menlo', 'Consolas', monospace;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tool result (collapsible) */
.sb-tool-result-area { }
.sb-tool-result-details {
    font-size: 0.75rem;
}
.sb-tool-result-summary {
    cursor: pointer;
    color: #3b82f6;
    font-size: 0.72rem;
    user-select: none;
    list-style: none;
    padding: 0.15rem 0;
}
.sb-tool-result-summary::-webkit-details-marker { display: none; }
.sb-tool-result-summary::marker { content: ''; }
.sb-tool-result-summary:hover { text-decoration: underline; }

.sb-tool-result-pre {
    color: #8b9cb8;
    font-size: 0.72rem;
    background: rgba(0,0,0,0.2);
    padding: 0.35rem 0.5rem;
    border-radius: 0.25rem;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.4;
    margin: 0.25rem 0 0;
    border-left: 2px solid #22c55e;
}
.sb-result-error .sb-tool-result-pre {
    border-left-color: #ef4444;
    color: #fca5a5;
}

/* ── Reply area ── */
.sb-reply {
    line-height: 1.6;
}
.sb-reply h2, .sb-reply h3, .sb-reply h4, .sb-reply h5 {
    margin: 1rem 0 0.4rem;
    line-height: 1.3;
    font-weight: 600;
}
.sb-reply h2 { font-size: 1.05rem; color: #e2e8f0; border-bottom: 1px solid #334155; padding-bottom: 0.25rem; }
.sb-reply h3 { font-size: 0.97rem; color: #cbd5e1; }
.sb-reply h4, .sb-reply h5 { font-size: 0.9rem; color: #94a3b8; }
.sb-reply hr { border: none; border-top: 1px solid #334155; margin: 0.75rem 0; }
.sb-reply table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin: 0.6rem 0;
    border-radius: 6px;
    overflow: hidden;
}
.sb-reply table th {
    background: #1e293b;
    color: #94a3b8;
    padding: 5px 10px;
    text-align: left;
    font-weight: 500;
    white-space: nowrap;
}
.sb-reply table td {
    padding: 5px 10px;
    border-bottom: 1px solid #1e293b;
    vertical-align: top;
}
.sb-reply table tr:last-child td { border-bottom: none; }
.sb-reply table tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
/* Also apply to main chat bubbles */
.msg-bubble .sb-reply h2, .msg-bubble h2 { font-size: 1.05rem; font-weight: 600; margin: 0.9rem 0 0.35rem; border-bottom: 1px solid #334155; padding-bottom: 0.2rem; }
.msg-bubble .sb-reply h3, .msg-bubble h3 { font-size: 0.97rem; font-weight: 600; margin: 0.75rem 0 0.3rem; }
.msg-bubble table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin: 0.5rem 0; }
.msg-bubble table th { background: #1e293b; color: #94a3b8; padding: 5px 10px; text-align: left; font-weight: 500; }
.msg-bubble table td { padding: 5px 10px; border-bottom: 1px solid #1e293b; vertical-align: top; }
.msg-bubble table tr:last-child td { border-bottom: none; }

/* ── Stats tag ── */
.sb-stats {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    color: #64748b;
    padding: 0.35rem 0.5rem;
    margin-top: 0.35rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 0.375rem;
    letter-spacing: 0.01em;
}

/* Legacy typing indicator (kept for compatibility) */
.typing-indicator {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
}
.typing-indicator span {
    width: 0.5rem;
    height: 0.5rem;
    background: #64748b;
    border-radius: 50%;
    animation: typing 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-0.5rem); }
}

/* Drop zone */
#drop-zone.drag-over {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

/* Gallery */
.gallery-item {
    aspect-ratio: 4/3;
    overflow: hidden;
    border-radius: 0.5rem;
    cursor: pointer;
    border: 1px solid #334155;
    transition: all 0.2s;
}
.gallery-item:hover {
    border-color: #3b82f6;
    transform: scale(1.02);
}
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Upload item */
.upload-item {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    padding: 1rem;
}
.upload-item .status-badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}
.status-pending { background: #854d0e; color: #fde68a; }
.status-processing { background: #1e40af; color: #93c5fd; }
.status-completed { background: #166534; color: #86efac; }
.status-failed { background: #991b1b; color: #fca5a5; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Snapshot thumbnails */
.snapshot-thumb {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 0.375rem;
    border: 1px solid #334155;
    cursor: pointer;
    flex-shrink: 0;
}
.snapshot-thumb:hover {
    border-color: #3b82f6;
}

/* ====================== */
/* Stream Left-Right Layout */
/* ====================== */

/* Modal body: left panel + right video */
.stream-body {
    display: flex;
    gap: 0;
    padding: 0 !important;
    overflow: hidden;
}

/* Left control panel */
.stream-panel {
    width: 220px;
    min-width: 220px;
    background: #0f172a;
    border-right: 1px solid #334155;
    padding: 0.75rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Scrollable channel list area (between IP row and action buttons) */
.stream-ch-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.stream-panel-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.stream-panel-label {
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.stream-panel-input {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 0.375rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}
.stream-panel-input:focus {
    border-color: #3b82f6;
}

/* IP + Port grouped box */
.stream-addr-group {
    display: flex;
    gap: 0.5rem;
    padding: 0.6rem;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    background: #1e293b;
}

/* Channel checkbox list */
.stream-ch-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: #1e293b;
    border-radius: 0.375rem;
    border: 1px solid #334155;
}
.stream-ch-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.72rem;
    color: #cbd5e1;
    cursor: grab;
    transition: background 0.1s;
    user-select: none;
}
.stream-ch-item:active {
    cursor: grabbing;
}
.stream-ch-item:hover {
    background: #334155;
}
.stream-ch-item.dragging {
    opacity: 0.4;
}
.stream-ch-item input[type="checkbox"] {
    accent-color: #3b82f6;
    flex-shrink: 0;
}

/* Action buttons */
.stream-panel-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-top: 0.5rem;
    flex-shrink: 0;
}
.stream-action-btn {
    width: 100%;
    padding: 0.4rem 0;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.stream-action-connect {
    background: #16a34a;
    color: white;
}
.stream-action-connect:hover {
    background: #15803d;
}
.stream-action-disconnect {
    background: #dc2626;
    color: white;
}
.stream-action-disconnect:hover {
    background: #b91c1c;
}

/* Right video area */
.stream-video-area {
    flex: 1;
    min-width: 0;
    padding: 0.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ============== */
/* Stream NVR Grid */
/* ============== */
.stream-grid {
    display: grid;
    gap: 6px;
    flex: 1;
}
.stream-grid.layout-1  { grid-template-columns: 1fr; }
.stream-grid.layout-4  { grid-template-columns: repeat(2, 1fr); }
.stream-grid.layout-6  { grid-template-columns: repeat(3, 1fr); }
.stream-grid.layout-9  { grid-template-columns: repeat(3, 1fr); }
.stream-grid.layout-16 { grid-template-columns: repeat(4, 1fr); }

/* Layout selector buttons (icon) */
.layout-btn {
    width: 1.75rem;
    height: 1.75rem;
    background: #334155;
    color: #64748b;
    border: 1px solid #475569;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.layout-btn:hover {
    background: #475569;
    color: #cbd5e1;
}
.layout-btn.active {
    background: #2563eb;
    color: white;
    border-color: #3b82f6;
}

/* Preview mode toggle buttons */
.mode-btn {
    background: transparent;
    cursor: pointer;
    color: #94a3b8;
}
.mode-btn:hover { background: #334155; color: #cbd5e1; }
.mode-btn.active { background: #2563eb; color: white; }

/* Stream cell */
.stream-cell {
    position: relative;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 0.375rem;
    overflow: hidden;
    aspect-ratio: 16/9;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.stream-cell.drag-over {
    border-color: #3b82f6;
    box-shadow: inset 0 0 0 1px #3b82f6;
}

/* Cell label + fullscreen btn overlay */
.stream-cell-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 6px;
    background: rgba(0,0,0,0.55);
    z-index: 3;
}
.stream-cell-label {
    font-size: 0.62rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stream-cell-btns {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.stream-cell-icon-btn {
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 0.2rem;
    transition: all 0.15s;
    opacity: 0;
}
.stream-cell:hover .stream-cell-icon-btn {
    opacity: 1;
}
.stream-cell-icon-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #e2e8f0;
}
.stream-btn-close:hover {
    background: rgba(220,38,38,0.6);
    color: #fecaca;
}

/* Video element */
.stream-cell video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Status overlay */
.stream-cell-status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #64748b;
    pointer-events: none;
    z-index: 1;
}
.stream-cell-live .stream-cell-status {
    inset: auto 0 0 0;
    height: auto;
    padding: 2px 6px;
    background: linear-gradient(transparent, rgba(0,0,0,0.55));
    justify-content: flex-start;
    align-items: flex-end;
    font-size: 0.6rem;
    color: #94a3b8;
    letter-spacing: 0.02em;
}
.stream-cell-error {
    border-color: #7f1d1d;
}
.stream-cell-error .stream-cell-status {
    color: #fca5a5;
    font-size: 0.65rem;
    padding: 0.5rem;
    padding-top: 1.5rem;
    text-align: center;
    word-break: break-all;
}

/* Fullscreen: fill screen, show bar on hover */
.stream-cell:fullscreen {
    background: #000;
    border: none;
    border-radius: 0;
    aspect-ratio: auto;
    width: 100vw;
    height: 100vh;
}
.stream-cell:fullscreen .stream-cell-bar {
    opacity: 0;
    transition: opacity 0.3s;
}
.stream-cell:fullscreen:hover .stream-cell-bar {
    opacity: 1;
}
.stream-cell:fullscreen .stream-cell-icon-btn {
    opacity: 1;
}

/* Analysis result */
.analysis-result {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 0.75rem;
    line-height: 1.6;
    white-space: pre-wrap;
    font-size: 0.875rem;
}

/* ==================== */
/* Sidebar Action Cards */
/* ==================== */
.action-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.75rem;
    padding: 1rem 1.1rem;
    transition: border-color 0.2s;
}
.action-card:hover {
    border-color: #475569;
}

.action-num {
    width: 2rem;
    height: 2rem;
    background: #2563eb;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.action-suggestion {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.45rem 0.75rem;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    color: #3b82f6;
    font-size: 0.8rem;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.action-suggestion:hover {
    background: rgba(59, 130, 246, 0.08);
    border-color: #3b82f6;
}

/* ============= */
/* Modal Overlay */
/* ============= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.modal-overlay.hidden {
    display: none;
}
.modal-overlay.maximized {
    padding: 0;
}

.modal-content {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 1rem;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    transition: border-radius 0.2s;
}
.modal-overlay.maximized .modal-content {
    max-width: 100vw !important;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    height: 100vh;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}

.modal-close {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #94a3b8;
    background: none;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}
.modal-close:hover {
    background: #334155;
    color: #e2e8f0;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* ========================= */
/* Bench Connection Layout   */
/* ========================= */

.bench-body {
    display: flex;
    gap: 0;
    padding: 0 !important;
    overflow: hidden;
}

/* Left control panel */
.bench-panel {
    width: 260px;
    min-width: 260px;
    background: #0f172a;
    border-right: 1px solid #334155;
    padding: 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.bench-panel-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.bench-panel-label {
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.bench-panel-input {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 0.375rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}
.bench-panel-input:focus {
    border-color: #3b82f6;
}

/* Search row */
.bench-search-row {
    display: flex;
    gap: 0.35rem;
}
.bench-search-row .bench-panel-input {
    flex: 1;
    min-width: 0;
}
.bench-search-btn {
    padding: 0.35rem 0.6rem;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.bench-search-btn:hover {
    background: #1d4ed8;
}

/* Device list */
.bench-device-list {
    max-height: 180px;
    overflow-y: auto;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.375rem;
}
.bench-device-item {
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid #1e293b;
}
.bench-device-item:last-child {
    border-bottom: none;
}
.bench-device-item:hover {
    background: #334155;
}
.bench-device-item.selected {
    background: #1e3a5f;
    border-left: 2px solid #3b82f6;
}
.bench-device-name {
    font-size: 0.78rem;
    color: #e2e8f0;
    font-weight: 500;
}
.bench-device-meta {
    font-size: 0.65rem;
    color: #64748b;
    margin-top: 1px;
}

/* Reservation card */
.bench-res-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.375rem;
    padding: 0.5rem;
}
.bench-res-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #cbd5e1;
    padding: 0.15rem 0;
}
.bench-res-label {
    color: #64748b;
}
.bench-res-status {
    color: #22c55e;
    font-weight: 600;
}

/* Action buttons */
.bench-panel-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: auto;
    padding-top: 0.5rem;
}
.bench-action-btn {
    width: 100%;
    padding: 0.4rem 0;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.bench-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.bench-action-connect {
    background: #16a34a;
    color: white;
}
.bench-action-connect:hover:not(:disabled) {
    background: #15803d;
}
.bench-action-disconnect {
    background: #dc2626;
    color: white;
}
.bench-action-disconnect:hover {
    background: #b91c1c;
}

/* Loading / error / empty states */
.bench-loading, .bench-empty {
    font-size: 0.72rem;
    color: #64748b;
    text-align: center;
    padding: 0.75rem 0.5rem;
}
.bench-error {
    font-size: 0.72rem;
    color: #fca5a5;
    text-align: center;
    padding: 0.75rem 0.5rem;
}

/* Right terminal area */
.bench-terminal-area {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Tab bar */
.bench-tab-bar {
    display: flex;
    background: #0b1120;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}
.bench-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.2rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.bench-tab:hover {
    color: #94a3b8;
    background: rgba(255,255,255,0.03);
}
.bench-tab.active {
    color: #e2e8f0;
    border-bottom-color: #3b82f6;
    background: rgba(59, 130, 246, 0.06);
}
/* Tab content */
.bench-tab-content {
    flex: 1;
    min-height: 0;
    position: relative;
}

/* Tab panes — full size, only active is visible */
.bench-terminal-pane {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    background: #0f172a;
    overflow: hidden;
}
.bench-terminal-pane.active {
    display: flex;
}

.bench-term-status {
    font-size: 0.65rem;
    color: #64748b;
}

.bench-term-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ========================= */
/* Toast notification         */
/* ========================= */
.toast-msg {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-1rem);
    background: #334155;
    color: #e2e8f0;
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
}
.toast-msg.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ========================= */
/* Skills modal list          */
/* ========================= */
.skills-search-bar {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}
.skills-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0;
}
.skill-item {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid #1e293b;
    cursor: default;
}
.skill-item:hover {
    background: rgba(59, 130, 246, 0.08);
}
.skill-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.skill-desc {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 0.15rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.skill-item.hidden {
    display: none;
}

/* ========================= */
/* File Transfer Toolbar     */
/* ========================= */
.transfer-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: #0b1120;
    border-top: 1px solid #334155;
    flex-shrink: 0;
    font-size: 0.72rem;
    color: #64748b;
}

.transfer-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.transfer-group-label {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
}

.transfer-group-upload .transfer-group-label {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.2);
}

.transfer-group-download .transfer-group-label {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.2);
}

.transfer-dropzone {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.5rem;
    border: 1px dashed #475569;
    border-radius: 0.25rem;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
    background: transparent;
    font-size: 0.7rem;
}

.transfer-dropzone:hover {
    border-color: #22c55e;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.transfer-dropzone.drag-over {
    border-color: #22c55e;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.2);
    border-style: solid;
}

.transfer-dropzone svg {
    width: 0.9rem;
    height: 0.9rem;
    flex-shrink: 0;
}

.transfer-arrow {
    color: #475569;
    font-size: 0.75rem;
}

.transfer-separator {
    width: 1px;
    height: 2rem;
    background: linear-gradient(to bottom, transparent, #475569, transparent);
    margin: 0 0.5rem;
}

.transfer-path-input {
    width: 180px;
    padding: 0.25rem 0.4rem;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 0.25rem;
    color: #e2e8f0;
    font-size: 0.7rem;
    font-family: 'JetBrains Mono', monospace;
}

.transfer-path-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.transfer-path-input::placeholder {
    color: #475569;
}

.transfer-btn-download {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border: 1px solid #334155;
    border-radius: 0.25rem;
    background: #1e293b;
    color: #3b82f6;
    cursor: pointer;
    transition: all 0.15s;
}

.transfer-btn-download:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
}

.transfer-btn-download svg {
    width: 0.9rem;
    height: 0.9rem;
}

.transfer-target-badge {
    margin-left: auto;
    padding: 0.15rem 0.4rem;
    background: rgba(34, 197, 94, 0.15);
    border-radius: 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
}

.transfer-target-badge span {
    color: #22c55e;
}

/* ========================= */
/* Transfer Progress Modal   */
/* ========================= */
.transfer-progress-container {
    width: 100%;
    height: 8px;
    background: #1e293b;
    border-radius: 4px;
    overflow: hidden;
}

.transfer-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 4px;
    transition: width 0.3s ease-out;
    width: 0%;
}

.transfer-status {
    font-size: 0.75rem;
    color: #94a3b8;
}

.transfer-status.success {
    color: #22c55e;
}

.transfer-status.error {
    color: #ef4444;
}

/* ========================= */
/* Drag & Drop Overlay       */
/* ========================= */
.transfer-drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(59, 130, 246, 0.15);
    border: 2px dashed #3b82f6;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.transfer-drop-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.transfer-drop-content {
    text-align: center;
    color: #3b82f6;
}

.transfer-drop-content svg {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 0.5rem;
}

.transfer-drop-content p {
    font-size: 0.9rem;
    font-weight: 500;
}

/* ========================= */
/* Context Menu              */
/* ========================= */
.transfer-context-menu {
    position: fixed;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    min-width: 180px;
    z-index: 10000;
    display: none;
    padding: 0.25rem 0;
}

.transfer-context-menu.active {
    display: block;
}

.transfer-menu-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    color: #e2e8f0;
    cursor: pointer;
    transition: background 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transfer-menu-item:hover {
    background: #334155;
}

.transfer-menu-item.disabled {
    color: #64748b;
    cursor: not-allowed;
}

.transfer-menu-item.disabled:hover {
    background: transparent;
}

.transfer-menu-divider {
    height: 1px;
    background: #334155;
    margin: 0.25rem 0;
}

/* ============================================================ */
/* Demo Runner                                                    */
/* ============================================================ */

.demo-select {
    width: 100%;
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 0.375rem;
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
    cursor: pointer;
}
.demo-select:focus { outline: none; border-color: #3b82f6; }

.demo-slider {
    accent-color: #3b82f6;
    cursor: pointer;
}

.demo-radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: #cbd5e1;
    cursor: pointer;
}
.demo-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: #cbd5e1;
    cursor: pointer;
    user-select: none;
}
.demo-checkbox {
    width: 14px;
    height: 14px;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
}

.demo-btn-run {
    background: #16a34a !important;
    color: #fff !important;
}
.demo-btn-run:hover { background: #15803d !important; }

.demo-btn-stop {
    background: #dc2626 !important;
    color: #fff !important;
}
.demo-btn-stop:hover { background: #b91c1c !important; }

.demo-log {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 0.375rem;
    padding: 0.5rem;
    overflow-y: auto;
    min-height: 120px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Advanced options collapsible */
.demo-advanced { margin-top: 0; }
.demo-advanced-summary {
    cursor: pointer;
    user-select: none;
    display: list-item;
}
.demo-advanced-summary:hover { color: #93c5fd; }
.demo-hint {
    display: block;
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 400;
    margin-top: 0.1rem;
}
.demo-custom-cmd-input {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    resize: vertical;
}

/* Process steps collapsible (wraps tool calls + thinking after run) */
.demo-process-details {
    margin-bottom: 0.5rem;
}
.demo-process-summary {
    cursor: pointer;
    user-select: none;
    font-size: 0.75rem;
    color: #64748b;
    padding: 0.3rem 0.5rem;
    background: #1e293b;
    border-radius: 0.375rem;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.demo-process-summary:hover { color: #93c5fd; background: #263548; }
.demo-process-details[open] .demo-process-summary { border-radius: 0.375rem 0.375rem 0 0; }
.demo-process-details[open] .demo-process-body {
    border: 1px solid #1e293b;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    padding: 0.4rem;
}

/* Follow-up chat input bar */
.demo-chat-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0 0;
    border-top: 1px solid #1e293b;
    margin-top: 0.5rem;
    align-items: center;
}
.demo-chat-bar.hidden { display: none; }
.demo-chat-input {
    flex: 1;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.375rem;
    color: #e2e8f0;
    font-size: 0.8125rem;
    padding: 0.4rem 0.75rem;
    outline: none;
    min-width: 0;
}
.demo-chat-input:focus { border-color: #3b82f6; }
.demo-chat-send {
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 0.375rem;
    padding: 0.4rem 0.9rem;
    font-size: 0.8125rem;
    cursor: pointer;
    white-space: nowrap;
}
.demo-chat-send:hover { background: #2563eb; }
.demo-chat-send:disabled { background: #334155; cursor: default; }

/* ── Demo Resource Navigator ──────────────────────────────────────────── */
.demo-res-panel {
    width: 210px;
    min-width: 140px;
    max-width: 480px;
    background: #0f172a;
    border-left: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.demo-res-tree-area {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    height: 50%;
    min-height: 80px;
}
.demo-res-v-resizer {
    height: 4px;
    flex-shrink: 0;
    cursor: row-resize;
    background: transparent;
    transition: background 0.15s;
}
.demo-res-v-resizer:hover,
.demo-res-v-resizer.dragging { background: #3b82f6; }
.demo-res-preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0d1627;
    border-top: 1px solid #1e293b;
    min-height: 80px;
}
.demo-res-resizer {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    cursor: col-resize;
    z-index: 10;
}
.demo-res-resizer:hover,
.demo-res-resizer.dragging {
    background: #3b82f6;
}
.demo-res-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem 0.45rem;
    border-bottom: 1px solid #1e293b;
    flex-shrink: 0;
}
.demo-res-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}
.demo-res-refresh-btn {
    background: none;
    border: none;
    color: #475569;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    border-radius: 3px;
    transition: color 0.15s;
}
.demo-res-refresh-btn:hover { color: #94a3b8; }
.demo-res-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.35rem 0;
    min-height: 0;
}
.demo-res-section {
    margin-bottom: 0.1rem;
}
.demo-res-section-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    cursor: pointer;
    user-select: none;
    letter-spacing: 0.01em;
}
.demo-res-section-hd:hover { background: rgba(255,255,255,0.03); }
.demo-res-chevron { transition: transform 0.2s; flex-shrink: 0; }
.demo-res-chevron.collapsed { transform: rotate(-90deg); }
.demo-res-section-body {
    /* visible by default */
}
.demo-res-section-body.hidden { display: none; }
.demo-res-item {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    padding: 0.28rem 0.75rem 0.28rem 1.1rem;
    font-size: 0.73rem;
    color: #94a3b8;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.4;
    transition: background 0.1s;
    word-break: break-all;
}
.demo-res-item:hover { background: rgba(255,255,255,0.05); color: #e2e8f0; }
.demo-res-item.demo-res-dir { color: #7dd3fc; }
.demo-res-item.demo-res-back {
    color: #475569;
    font-size: 0.7rem;
    padding-left: 0.75rem;
}
.demo-res-item.demo-res-back:hover { color: #94a3b8; }
.demo-res-icon { flex-shrink: 0; font-size: 0.8rem; }
.demo-res-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-res-size { flex-shrink: 0; color: #475569; font-size: 0.68rem; }
.demo-res-dl {
    flex-shrink: 0;
    color: #475569;
    font-size: 0.75rem;
    line-height: 1;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}
.demo-res-item:hover .demo-res-dl { opacity: 1; }
.demo-res-dl:hover { color: #7dd3fc; }
.demo-res-msg {
    padding: 0.4rem 1.1rem;
    font-size: 0.72rem;
    color: #475569;
    font-style: italic;
}

/* ── Analysis Resource Explorer ─────────────────────────────────────────── */
.analysis-nav-panel {
    width: 280px;
    min-width: 160px;
    background: #0f172a;
    border-right: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    flex-grow: 0;
}
/* Resizer is a SIBLING element between nav-panel and preview-area */
.analysis-nav-resizer {
    width: 4px;
    flex-shrink: 0;
    cursor: col-resize;
    background: transparent;
    transition: background 0.15s;
}
.analysis-nav-resizer:hover,
.analysis-nav-resizer.dragging { background: #3b82f6; }
.analysis-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.5rem 0.45rem 0.75rem;
    border-bottom: 1px solid #1e293b;
    flex-shrink: 0;
}
.analysis-hd-path {
    font-size: 0.65rem;
    color: #475569;
    font-weight: 400;
    margin-left: 0.2rem;
}
.analysis-item-active {
    background: rgba(59, 130, 246, 0.12) !important;
    color: #93c5fd !important;
}
.analysis-preview-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0d1627;
}
.analysis-preview-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e293b;
    font-size: 0.875rem;
}
.analysis-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.875rem;
    border-bottom: 1px solid #1e293b;
    background: #0f172a;
    flex-shrink: 0;
}
.analysis-preview-title {
    font-size: 0.8rem;
    color: #94a3b8;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.analysis-preview-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}
.analysis-preview-btn {
    background: none;
    border: 1px solid #1e293b;
    color: #64748b;
    font-size: 0.72rem;
    padding: 0.18rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.analysis-preview-btn:hover { color: #94a3b8; border-color: #334155; }
.analysis-preview-close {
    background: none;
    border: none;
    color: #475569;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.15rem 0.25rem;
    border-radius: 3px;
    transition: color 0.15s;
}
.analysis-preview-close:hover { color: #f87171; }
.analysis-preview-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    color: #94a3b8;
    line-height: 1.4;
}
.analysis-preview-body .demo-preview-pre {
    line-height: 1.2;
}
.analysis-preview-body .demo-preview-lines span {
    line-height: 1.2;
}
.analysis-md-content {
    color: #cbd5e1;
    max-width: 960px;
}

/* User message bubble inside demo-log */
.demo-log .msg-user {
    display: flex;
    justify-content: flex-end;
    margin: 0.25rem 0;
}
.demo-log .msg-user .msg-bubble {
    background: #1d4ed8;
    color: #eff6ff;
    max-width: 80%;
    border-radius: 0.75rem 0.75rem 0.125rem 0.75rem;
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
}

.demo-result-banner {
    padding: 0.625rem 0.875rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.demo-result-ok   { background: #14532d; color: #86efac; border: 1px solid #166534; }
.demo-result-fail { background: #450a0a; color: #fca5a5; border: 1px solid #7f1d1d; }

.demo-cam-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}
.demo-cam-table thead { background: #1e293b; }
.demo-cam-table th {
    text-align: left;
    padding: 0.375rem 0.625rem;
    color: #94a3b8;
    font-weight: 500;
}
.demo-cam-table td {
    padding: 0.3rem 0.625rem;
    border-top: 1px solid #1e293b;
    color: #cbd5e1;
}
.demo-cam-id  { font-family: monospace; color: #93c5fd; }
.demo-cam-fps { font-family: monospace; }
.demo-cam-ok   { color: #4ade80; }
.demo-cam-fail { color: #f87171; }

/* Inline text file preview bubble in demo-log */
.demo-preview-wrapper {
    display: flex;
    justify-content: flex-start;
    margin: 0.25rem 0;
}
.demo-preview-bubble {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 0.75rem 0.75rem 0.75rem 0.125rem;
    max-width: 98%;
    width: 98%;
    padding: 0;
    overflow: hidden;
    border: 1px solid #334155;
}
.demo-preview-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #0f172a;
    border-bottom: 1px solid #334155;
    font-size: 0.75rem;
    color: #94a3b8;
}
.demo-preview-title span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: monospace;
    color: #93c5fd;
}
.demo-preview-dl {
    color: #64748b;
    text-decoration: none;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.demo-preview-dl:hover { color: #94a3b8; }
.demo-preview-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.1rem;
    flex-shrink: 0;
}
.demo-preview-close:hover { color: #f87171; }
.demo-preview-body {
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
    line-height: 1.6;
    max-height: 60vh;
    overflow-y: auto;
}
.demo-preview-pre {
    margin: 0;
    font-family: monospace;
    font-size: 0.75rem;
    white-space: pre-wrap;
    word-break: break-all;
    color: #cbd5e1;
}
/* Line-numbered plain text */
.demo-preview-lines { counter-reset: line; }
.demo-preview-lines span {
    display: block;
    white-space: pre-wrap;
    word-break: break-all;
}
.demo-preview-lines span::before {
    content: attr(data-ln);
    display: inline-block;
    min-width: 3.5em;
    padding-right: 0.75em;
    margin-right: 0.75em;
    border-right: 1px solid #2d3f55;
    color: #475569;
    text-align: right;
    user-select: none;
    font-size: 0.7rem;
    vertical-align: top;
}
.demo-preview-trunc {
    padding: 0.35rem 0.875rem;
    font-size: 0.72rem;
    color: #64748b;
    font-style: italic;
    border-top: 1px solid #1e293b;
}

/* ── Image Lightbox ──────────────────────────────────────────────────────── */
.img-lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.92);
    flex-direction: column;
}
.img-lightbox-overlay.active { display: flex; }

.img-lightbox-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: rgba(15,23,42,0.95);
    border-bottom: 1px solid #1e293b;
    flex-shrink: 0;
    gap: 0.75rem;
}
.img-lightbox-title {
    font-size: 0.82rem;
    color: #94a3b8;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.img-lightbox-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}
.img-lightbox-btn {
    background: transparent;
    border: 1px solid #2d3f55;
    color: #94a3b8;
    border-radius: 4px;
    padding: 0.2rem 0.55rem;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    line-height: 1.4;
    transition: background 0.15s, color 0.15s;
}
.img-lightbox-btn:hover { background: #1e293b; color: #e2e8f0; }
.img-lightbox-close { color: #ef4444; border-color: #7f1d1d; }
.img-lightbox-close:hover { background: #7f1d1d; color: #fca5a5; }

.img-lightbox-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    cursor: grab;
}
.img-lightbox-body:active { cursor: grabbing; }

.img-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    transition: none;
    pointer-events: none;
}
