/*
 * OmicVerse Code Editor Layout & Styles
 * JupyterLab-like code editor with resizable sidebar
 * =====================================================
 */

/* ========================================
   Font Awesome Icon Replacements
   ======================================== */
.feather-filter:before { content: "\f0b0"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-chevron-right:before { content: "\f054"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-layers:before { content: "\f5fd"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-grid:before { content: "\f009"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-dna:before { content: "\f471"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-align-left:before { content: "\f036"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-arrow-right:before { content: "\f061"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-search:before { content: "\f002"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-maximize:before { content: "\f31e"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-minimize:before { content: "\f2d1"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-moon:before { content: "\f186"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-sun:before { content: "\f185"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-bell:before { content: "\f0f3"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-check:before { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-code:before { content: "\f121"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-bar-chart:before { content: "\f080"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-play:before { content: "\f04b"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-trash-2:before { content: "\f2ed"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-plus:before { content: "\f067"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-file-text:before { content: "\f15c"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-check-circle:before { content: "\f058"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-x:before { content: "\f00d"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-user:before { content: "\f007"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-settings:before { content: "\f013"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-help-circle:before { content: "\f059"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-log-out:before { content: "\f2f5"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-refresh-cw:before { content: "\f2f1"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-folder:before { content: "\f07b"; font-family: "Font Awesome 6 Free"; font-weight: 900; }
.feather-save:before { content: "\f0c7"; font-family: "Font Awesome 6 Free"; font-weight: 900; }

[class^="feather-"], [class*=" feather-"] {
    speak: none;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Code Cell Styles - JupyterLab-like
   ======================================== */
.code-cell {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 10px;
    background: #fff;
    transition: box-shadow 0.2s;
}

.code-cell:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.code-cell-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 0 8px;
    min-height: 30px;
    background: transparent;
    border-bottom: 1px solid #f0f0f0;
    box-sizing: border-box;
}

/* CSS Grid same-cell layout: both pre and textarea occupy grid-area 1/1,
   guaranteeing pixel-perfect alignment without any positioning arithmetic. */
.code-cell-input {
    padding: 0;
    display: grid;
}

/* Place all three children in the same grid cell so they stack exactly */
.code-cell-input .code-highlight,
.code-cell-input .code-input,
.code-cell-input .markdown-render {
    grid-area: 1 / 1;
}

.code-cell-input textarea,
.code-cell-input pre[class*="language-"] {
    width: 100%;
    min-height: 60px;
    border: none;
    padding: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 13px;
    /* Use a pixel line-height to eliminate subpixel rounding drift across lines */
    line-height: 20px;
    margin: 0;
    white-space: pre;
    box-sizing: border-box;
    tab-size: 4;
    -moz-tab-size: 4;
    word-wrap: normal;
    overflow-wrap: normal;
}

.code-cell-input textarea {
    resize: none;
    overflow: auto;
    background: transparent;
    color: transparent !important;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 0 transparent;
    -webkit-text-stroke: 0 transparent;
    caret-color: #111827;
    z-index: 2;
    /* Hide scrollbar — it would shift layout vs the pre layer causing cursor offset */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.code-cell-input textarea::-webkit-scrollbar {
    display: none;
}

.code-cell.cell-markdown .code-input,
.code-cell.cell-raw .code-input {
    color: #111827 !important;
    -webkit-text-fill-color: #111827;
    text-shadow: none;
    max-height: 420px;
    overflow: auto;
}

.markdown-render {
    display: none;
    padding: 12px;
    border-radius: 6px;
    cursor: text;
    color: #111827;
    user-select: none;
    pointer-events: auto;
}

.markdown-render h1,
.markdown-render h2,
.markdown-render h3 {
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 6px;
}

.markdown-render code {
    background: #f3f4f6;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
}

.markdown-render pre {
    background: #f6f8fa;
    padding: 10px;
    border-radius: 6px;
    overflow: auto;
}

.markdown-render blockquote {
    border-left: 3px solid #e5e7eb;
    padding-left: 10px;
    color: #6b7280;
}

.code-cell-input .code-highlight {
    /* grid-area: 1/1 set above — no absolute positioning needed */
    pointer-events: none;
    background: transparent;
    z-index: 1;
    color: #111827;
    white-space: pre;
    overflow: hidden;
    /* Prevent the pre from contributing to grid cell height beyond textarea */
    visibility: visible;
}

.code-cell-input .code-highlight code {
    display: block;
}

/* Code Cell Output */
.code-cell-output {
    padding: 12px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 12px;
    display: none;
    overflow: auto;
    cursor: text;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.code-cell-output.markdown {
    font-family: inherit;
    background: #fff;
    color: #111827;
}

.code-cell-output.has-content {
    display: block;
}

.code-cell-output.error {
    color: #dc3545;
    background: #f8d7da;
}

.code-cell-output.success {
    color: #198754;
}

.code-output-text {
    margin: 0 0 8px 0;
    white-space: pre-wrap;
    cursor: text;
    user-select: text !important;
    -webkit-user-select: text !important;
}

/* ANSI Colors */
.ansi-black { color: #111827; }
.ansi-red { color: #dc2626; }
.ansi-green { color: #16a34a; }
.ansi-yellow { color: #ca8a04; }
.ansi-blue { color: #2563eb; }
.ansi-magenta { color: #7c3aed; }
.ansi-cyan { color: #0891b2; }
.ansi-white { color: #e5e7eb; }
.ansi-bright-black { color: #6b7280; }
.ansi-bright-red { color: #ef4444; }
.ansi-bright-green { color: #22c55e; }
.ansi-bright-yellow { color: #facc15; }
.ansi-bright-blue { color: #60a5fa; }
.ansi-bright-magenta { color: #a78bfa; }
.ansi-bright-cyan { color: #22d3ee; }
.ansi-bright-white { color: #ffffff; }

.code-output-figure {
    display: block;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fff;
    margin-top: 8px;
}

/* Cell Controls */
.cell-number {
    color: #6c757d;
    font-weight: 500;
    font-size: 11px;
    font-family: monospace;
}

.cell-toolbar {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding: 4px 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.cell-toolbar .form-select {
    height: 24px !important;
    font-size: 11px !important;
    padding: 0 6px !important;
    border-radius: 4px;
    line-height: 1 !important;
    box-sizing: border-box !important;
}

.code-cell:hover .cell-toolbar {
    opacity: 1;
}

.cell-toolbar .btn {
    padding: 1px 5px !important;
    font-size: 11px !important;
    height: 24px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}

.code-cell-output.collapsed {
    display: none;
}

.code-cell-output.partial {
    max-height: 140px;
    overflow: auto;
}

.output-hidden-note {
    display: none;
    padding: 6px 12px;
    font-size: 12px;
    color: #6b7280;
    background: #f3f4f6;
    border-top: 1px dashed #e5e7eb;
}

.output-hidden-note.visible {
    display: block;
}

.code-toolbar-group .btn[data-label] {
    position: relative;
}

.code-toolbar-group .btn[data-label]:hover::after {
    content: attr(data-label);
    position: absolute;
    top: 110%;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: #111827;
    color: #fff;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 10px;
    z-index: 10;
}

.code-toolbar-group-df-limit {
    gap: 6px;
    padding: 0 6px;
}

.code-toolbar-mini-label {
    font-size: 11px;
    color: #6b7280;
    margin: 0;
    line-height: 1;
    user-select: none;
}

.code-toolbar-mini-input {
    width: 68px;
    min-width: 68px;
    height: 22px !important;
    font-size: 11px !important;
    padding: 0 6px !important;
}

/* Prism.js Integration */
.code-cell-input pre[class*="language-"] {
    margin: 0;
    border-radius: 0;
}

/* ========================================
   Toolbar Styles
   ======================================== */
#code-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
}

.code-toolbar-group {
    display: inline-flex;
    align-items: center;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.code-toolbar-group .form-select {
    border: none;
    border-radius: 0;
    padding: 6px 30px 6px 10px;
    font-size: 12px;
    min-width: 180px;
}

.code-toolbar-group .form-select:focus {
    box-shadow: none;
}

.code-toolbar-group .btn {
    border-radius: 0;
    border: none;
    border-right: 1px solid #e5e7eb;
    padding: 6px 10px;
    font-size: 12px;
}

.code-toolbar-group .btn:last-child {
    border-right: none;
}

.code-toolbar-separator {
    width: 1px;
    height: 24px;
    background: #e5e7eb;
    margin: 0 4px;
}

.code-toolbar-label {
    font-size: 12px;
    color: #6b7280;
    margin-right: 8px;
}

/* ========================================
   Agent View Styles
   ======================================== */
.agent-view {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

.agent-panel {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 520px;
}

.agent-panel-header {
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.agent-panel-title {
    font-weight: 600;
    color: #283c50;
}

.agent-harness-panel {
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 18px;
    background: #fcfcfd;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.agent-harness-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.agent-harness-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #475569;
}

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

.agent-harness-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.agent-harness-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.agent-harness-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
}

.agent-harness-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
}

.agent-harness-column {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    min-height: 120px;
    display: flex;
    flex-direction: column;
}

.agent-harness-subtitle {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    padding: 10px 12px 6px;
}

.agent-harness-list,
.agent-harness-trace {
    padding: 0 12px 12px;
    overflow: auto;
    font-size: 12px;
    color: #334155;
    cursor: text;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.agent-harness-empty {
    color: #94a3b8;
    font-style: italic;
}

.agent-harness-approval {
    border: 1px solid #dbeafe;
    background: #eff6ff;
    border-radius: 8px;
    padding: 8px 10px;
    margin-top: 8px;
}

.agent-harness-approval:first-child {
    margin-top: 0;
}

.agent-harness-approval-title {
    font-weight: 600;
    color: #1d4ed8;
    margin-bottom: 4px;
}

.agent-harness-approval-actions {
    margin-top: 8px;
    display: flex;
    gap: 6px;
}

.agent-harness-trace pre {
    background: #0f172a;
    color: #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    cursor: text;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.agent-messages {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background: #f8fafc;
}

.agent-message {
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 10px;
    max-width: 75%;
    line-height: 1.5;
    font-size: 14px;
    cursor: text;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.agent-message p {
    margin: 0 0 8px;
}

.agent-message p:last-child {
    margin-bottom: 0;
}

.agent-message ul {
    padding-left: 18px;
    margin: 8px 0;
}

.agent-message blockquote {
    margin: 8px 0;
    padding-left: 10px;
    border-left: 2px solid rgba(148, 163, 184, 0.5);
    color: #64748b;
}

.agent-message code {
    background: rgba(15, 23, 42, 0.08);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 12px;
}

.agent-message h1,
.agent-message h2,
.agent-message h3 {
    margin: 6px 0;
    font-size: 14px;
}

.agent-message.user {
    background: #dbeafe;
    color: #1e3a8a;
    margin-left: auto;
}

.agent-message.assistant {
    background: #ecfdf3;
    color: #065f46;
    margin-right: auto;
}

.agent-message pre {
    background: #0f172a;
    color: #e5e7eb;
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    overflow-x: auto;
    margin: 8px 0 0;
    cursor: text;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.agent-input {
    border-top: 1px solid #e5e7eb;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    background: #ffffff;
}

.agent-attachment-strip {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.agent-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 12px;
    line-height: 1;
}

.agent-attachment-chip button {
    border: none;
    background: transparent;
    color: inherit;
    padding: 0;
    line-height: 1;
    cursor: pointer;
}

.agent-input textarea {
    flex: 1;
    resize: none;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
    min-height: 44px;
    font-size: 14px;
}

.agent-input .btn {
    white-space: nowrap;
}

.agent-panel-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.agent-session-badge {
    font-size: 10px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    cursor: default;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Streaming cursor ---- */
.agent-streaming .agent-llm-text::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 14px;
    margin-left: 2px;
    background: #065f46;
    border-radius: 1px;
    animation: agent-blink 0.7s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes agent-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}

/* ---- Inline event cards ---- */
.agent-card {
    margin: 8px 0 0;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.5;
}

.agent-card-tool {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.agent-card-label {
    font-weight: 600;
    white-space: nowrap;
}

.agent-card-detail {
    color: #6b7280;
    word-break: break-all;
}

.agent-card-code {
    background: #0f172a;
    color: #e5e7eb;
    padding: 0;
    overflow: hidden;
}

.agent-card-code pre {
    margin: 0;
    padding: 8px 10px;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    cursor: text;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.agent-card-result {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    font-weight: 500;
}

.agent-card-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

@media (max-width: 992px) {
    .agent-harness-columns {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   File Manager Styles
   ======================================== */
.file-manager {
    display: none;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
}

.fm-section {
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.fm-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.fm-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    margin-bottom: 8px;
}

.fm-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
}

.fm-section-toggle {
    font-size: 12px;
    color: #9ca3af;
}

.file-manager-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.file-manager-title {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
}

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

.file-manager-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.file-manager-path {
    font-size: 11px;
    color: #9ca3af;
    margin-bottom: 8px;
    word-break: break-all;
}

.file-manager-up {
    cursor: pointer;
    font-size: 11px;
    color: #2563eb;
    margin-bottom: 8px;
}

.file-manager-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: #374151;
}

.file-manager-item .file-icon {
    margin-right: 6px;
    color: #6b7280;
}

.file-manager-item.is-dir .file-icon {
    color: #2563eb;
}

.file-manager-item:hover {
    background: #f3f4f6;
}

.file-manager-meta {
    font-size: 11px;
    color: #9ca3af;
}

.file-tree {
    list-style: none;
    padding-left: 12px;
    margin: 0;
}

.file-tree-node {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    color: #374151;
}

.file-tree-node:hover {
    background: #f3f4f6;
}

.file-tree-node .node-toggle {
    font-size: 10px;
    color: #9ca3af;
    width: 10px;
    text-align: center;
}

.file-tree-children {
    list-style: none;
    margin: 4px 0 4px 14px;
    padding-left: 0;
    display: none;
}

.file-tree-children.open {
    display: block;
}

.file-tree-spacer {
    height: 32px;
}

.file-context-menu {
    position: fixed;
    z-index: 2000;
    min-width: 180px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    padding: 6px;
    display: none;
}

.file-context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 12px;
    color: #111827;
    border-radius: 6px;
    cursor: pointer;
}

.file-context-menu-item:hover {
    background: #f3f4f6;
}

.file-context-menu-sep {
    height: 1px;
    background: #e5e7eb;
    margin: 6px 0;
}

/* ========================================
   Kernel Monitor Styles
   ======================================== */
.kernel-metrics {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kernel-metric {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px;
}

.kernel-metric-title {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

.kernel-metric-value {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.kernel-var-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
}

.kernel-var-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    padding: 6px 6px;
    border-radius: 6px;
}

.kernel-var-bar {
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.kernel-var-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #60a5fa, #34d399);
    border-radius: 999px;
}

.var-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.var-table th,
.var-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.var-table th {
    color: #6b7280;
    font-weight: 600;
}

.var-preview {
    color: #6b7280;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.var-row {
    cursor: pointer;
}

.var-child td:first-child {
    padding-left: 20px;
}

.var-detail-view {
    display: none;
    padding: 12px;
    background: #fff;
}

.var-detail-meta {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
}

.var-table-view {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.var-table-view th,
.var-table-view td {
    border-bottom: 1px solid #e5e7eb;
    padding: 6px 8px;
    text-align: left;
}

/* ========================================
   File Viewers
   ======================================== */
.page-header-right-items-wrapper {
    gap: 6px !important;
}

.text-file-view {
    display: none;
    padding: 12px;
    background: #fff;
}

.text-file-view textarea {
    width: 100%;
    min-height: 480px;
    border: none;
    outline: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 12px;
    white-space: pre;
    resize: vertical;
}

/* CodeMirror wrap inside text-file-view */
#cm-editor-wrap {
    min-height: 480px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
}

#cm-editor-wrap .CodeMirror {
    height: 100%;
    min-height: 480px;
    font-size: 13px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, monospace;
    line-height: 1.55;
}

.md-file-view {
    display: none;
    padding: 12px;
    gap: 12px;
}

.md-editor {
    flex: 1;
    min-width: 0;
}

.md-editor textarea {
    width: 100%;
    min-height: 480px;
    border: none;
    outline: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    resize: vertical;
}

.md-editor .CodeMirror {
    min-height: 520px;
    height: 100%;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 13px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, monospace;
    line-height: 1.6;
}

.md-preview {
    flex: 1;
    min-width: 0;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    overflow: auto;
    line-height: 1.6;
    color: #111827;
}

.md-preview h1 { font-size: 20px; }
.md-preview h2 { font-size: 18px; }
.md-preview h3 { font-size: 16px; }

.md-preview ul {
    padding-left: 20px;
}

.md-preview ol {
    padding-left: 22px;
}

.md-preview li + li {
    margin-top: 0.25rem;
}

.md-preview blockquote {
    border-left: 3px solid #e5e7eb;
    padding-left: 10px;
    color: #6b7280;
}

.md-preview h1, .md-preview h2, .md-preview h3 {
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 6px;
}

.md-preview code {
    background: #f3f4f6;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
}

.md-preview pre {
    background: #f6f8fa;
    color: #111827;
    padding: 10px;
    border-radius: 6px;
    overflow: auto;
}

.md-preview table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.md-preview th,
.md-preview td {
    padding: 0.65rem 0.8rem;
    border: 1px solid #e5e7eb;
    vertical-align: top;
    text-align: left;
}

.md-preview th {
    background: #f8fafc;
    font-weight: 700;
    color: #0f172a;
}

.md-preview tbody tr:nth-child(even) {
    background: #f8fafc;
}

.md-preview hr {
    border: 0;
    border-top: 1px solid #e5e7eb;
    margin: 1.25rem 0;
}

.md-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.image-file-view {
    display: none;
    padding: 12px;
    background: #fff;
}

.image-file-view img {
    max-width: 100%;
    height: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
}

/* ========================================
   Editor Tabs
   ======================================== */
.editor-tabs {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 0 36px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    margin-top: 0;
}

.editor-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    cursor: pointer;
}

.editor-tab.active {
    border-color: #2563eb;
    color: #2563eb;
}

.editor-tab .tab-close {
    color: #9ca3af;
    font-size: 12px;
}

/* ========================================
   Page Layout
   ======================================== */

/* Code editor view: remove all horizontal/top padding from main-content and nxl-content */
body.view-code-active .main-content {
    padding-top: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

body.view-code-active .nxl-content {
    padding-left: 0 !important;
}

#viz-toolbar {
    display: flex;
    align-items: center;
}

.page-toolbar {
    display: none;
    align-items: center;
    justify-content: flex-start;
    padding: 8px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    position: sticky;
    top: 76px;
    z-index: 1020;
}

.header-pagebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.nxl-container {
    top: 76px;
}

.header-pagebar .page-header-title h5 {
    margin-bottom: 0;
    margin-right: 8px;
    padding-right: 10px;
    color: #283c50;
    font-weight: 600;
    border-right: 1px solid #cdd4e8;
}

.header-pagebar .breadcrumb {
    padding: 0;
    display: inline-flex;
    margin-bottom: 0;
    background: none;
    font-size: 13px;
    color: #7587a7;
    font-weight: 800;
}

.header-pagebar .breadcrumb a {
    color: #283c50;
}

/* Interrupt Button Animation */
#interrupt-btn {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

#interrupt-btn:disabled {
    animation: none;
    opacity: 0.5;
}

/* AnnData rich output */
.anndata-output {
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    font-size: 0.82rem;
}

html.app-skin-dark .anndata-output {
    background: #1e2330;
    border-color: #374151;
}

/* JupyterLab-like Scrolling */
#code-cells-container {
    padding-top: 6px !important;
    padding-bottom: 80vh !important;
}

/* ── Terminal Manager ──────────────────────────────────────────────────────
   Session list lives inside .nxl-navigation (#term-nav-panel).
   The #terminal-view fills the whole nxl-container with xterm panels.
   ─────────────────────────────────────────────────────────────────────── */

/* Full-height content wrapper — no internal padding */
.term-full-view {
    position: relative;
    padding: 0 !important;
    overflow: hidden;
    min-height: calc(100vh - 76px);
    height: calc(100vh - 76px);
}

/* ── #term-nav-panel — inside nxl-navigation ──────────────────────────── */
/* Mirrors the height below the sidebar logo (m-header = 42px) */
#term-nav-panel {
    /* display set to 'flex' via JS when terminal view is active */
    flex-direction: column;
    height: calc(100vh - 42px);
    overflow: hidden;
    border-right: 1px solid var(--nxl-border-color, #e5e7eb);
}

.term-nav-header {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 12px 16px 10px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--nxl-muted, #8a8fa8);
    border-bottom: 1px solid var(--nxl-border-color, #e2e8f0);
    flex-shrink: 0;
}

/* ── Session list ──────────────────────────────────────────────────────── */
.term-session-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 6px 0;
    scrollbar-width: thin;
}

.term-session-item {
    display: flex;
    align-items: center;
    padding: 7px 10px 7px 12px;
    margin: 1px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--nxl-muted, #6b7280);
    transition: background 0.12s, color 0.12s;
    gap: 0;
    user-select: none;
}
.term-session-item:hover {
    background: var(--nxl-gray-100, #f1f5f9);
    color: var(--nxl-body-color, #1e293b);
}
.term-session-item.active {
    background: rgba(59, 130, 246, 0.10);
    color: #3b82f6;
    font-weight: 500;
}

/* blue indicator bar on left of active item */
.term-session-indicator {
    width: 3px;
    height: 16px;
    border-radius: 2px;
    margin-right: 8px;
    flex-shrink: 0;
    background: transparent;
    transition: background 0.15s;
}
.term-session-item.active .term-session-indicator {
    background: #3b82f6;
}

.term-session-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    pointer-events: none;
}

.term-session-del {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--nxl-muted, #9ca3af);
    cursor: pointer;
    padding: 2px 3px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s, background 0.12s;
}
.term-session-item:hover .term-session-del,
.term-session-item.active .term-session-del {
    opacity: 1;
}
.term-session-del:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.10);
}

/* ── Footer / New button ───────────────────────────────────────────────── */
.term-nav-footer {
    padding: 8px;
    border-top: 1px solid var(--nxl-border-color, #e2e8f0);
    flex-shrink: 0;
}

#term-new-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: none;
    border: 1px dashed var(--nxl-border-color, #cbd5e1);
    color: var(--nxl-muted, #6b7280);
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 0.80rem;
    cursor: pointer;
    transition: all 0.15s;
}
#term-new-btn:hover {
    background: rgba(59, 130, 246, 0.07);
    border-color: #3b82f6;
    color: #3b82f6;
}

/* ── xterm panels — fill the nxl-container content area ──────────────── */
#term-panels {
    position: absolute;
    inset: 0;
    background: #1a1c20;
}

.term-panel {
    position: absolute;
    inset: 0;
    display: none;
    padding: 6px;
    box-sizing: border-box;
}

/* Make xterm fill its panel */
.term-panel .xterm,
.term-panel .xterm-viewport,
.term-panel .xterm-screen {
    height: 100% !important;
}
.term-panel .xterm-helper-textarea { position: absolute; }
