/* Modern REPL Visualizer Styles */

/* CSS Variables for theming */
:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;

    --accent-blue: #3b82f6;
    --accent-blue-light: #dbeafe;
    --accent-green: #10b981;
    --accent-green-light: #d1fae5;
    --accent-amber: #f59e0b;
    --accent-amber-light: #fef3c7;
    --accent-red: #ef4444;
    --accent-red-light: #fee2e2;
    --accent-purple: #8b5cf6;
    --accent-purple-light: #ede9fe;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Monaco, Consolas, monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.95);
}

.header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.header-actions button {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-actions button:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
}

.session-selector-btn {
    background: var(--accent-blue) !important;
    color: white !important;
    border-color: var(--accent-blue) !important;
}

.session-selector-btn:hover {
    background: #2563eb !important;
}

/* Theme toggle button */
.theme-toggle-btn {
    font-size: 16px;
    padding: 6px 10px !important;
    background: var(--bg-tertiary) !important;
    border: 1px solid var(--border-color) !important;
}

/* Session Selector Modal */
.session-selector-modal {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100vh;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    border-left: 1px solid var(--border-color);
}

.session-selector-modal.active {
    display: flex;
    flex-direction: column;
}

.session-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.session-selector-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.hierarchical-selector {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Tree styles */
.tree-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tree-node-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.tree-node-header:hover {
    background: var(--bg-tertiary);
}

.tree-toggle {
    font-size: 10px;
    color: var(--text-muted);
    width: 16px;
    transition: transform 0.2s;
}

.tree-node-header.expanded .tree-toggle {
    transform: rotate(90deg);
}

.tree-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.tree-node-experiment .tree-label {
    color: var(--accent-blue);
    font-weight: 600;
}

.tree-node-method .tree-label {
    color: var(--accent-purple);
}

.tree-node-k-value .tree-label {
    color: var(--accent-green);
    font-size: 12px;
}

.tree-node-session .tree-label {
    font-weight: 400;
    font-size: 12px;
}

.tree-session-header {
    margin-left: 24px;
}

.tree-session-header:hover {
    background: var(--accent-blue-light);
}

.tree-content {
    margin-left: 16px;
    display: none;
}

/* Session Browser */
.session-browser {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.browser-section {
    border-radius: var(--radius-sm);
}

.browser-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    user-select: none;
}

.browser-header:hover {
    background: var(--bg-tertiary);
}

.browser-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.browser-label {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.browser-section-folder > .browser-header .browser-label {
    color: var(--accent-blue);
    font-weight: 600;
}

.browser-section-method > .browser-header .browser-label {
    color: var(--accent-purple);
}

.browser-section-kvalue > .browser-header .browser-label {
    color: var(--accent-green);
}

.browser-badge {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
}

.browser-chevron {
    font-size: 14px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.browser-section.expanded > .browser-header .browser-chevron {
    transform: rotate(90deg);
}

.browser-children {
    display: none;
    margin-left: 20px;
    margin-top: 2px;
}

.browser-section.expanded > .browser-children {
    display: block;
}

/* Session items */
.session-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0;
}

.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    background: transparent;
}

.session-item:hover {
    background: var(--accent-blue-light);
}

.session-item-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.session-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-meta {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.session-item-cost {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-green);
    white-space: nowrap;
}

.empty-state {
    padding: 32px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* Main content */
.main-content {
    flex: 1;
    padding: 24px 32px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Panels */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.panel h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Session info */
.info-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.info-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
}

.info-card h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.info-card p {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.info-item .label {
    color: var(--text-secondary);
}

.info-item span:last-child {
    font-weight: 600;
    color: var(--text-primary);
}

/* Final answer */
.final-answer-content {
    background: linear-gradient(135deg, var(--accent-green-light), #ecfdf5);
    border: 1px solid #a7f3d0;
    border-radius: var(--radius-md);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    color: #065f46;
}

/* Trajectory */
.trajectory-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.no-data {
    text-align: center;
    color: var(--text-muted);
    padding: 48px;
    font-size: 14px;
}

/* Timestep */
.timestep {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.timestep-header {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-primary));
    padding: 14px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.timestep-header:hover {
    background: var(--bg-tertiary);
}

.timestep-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.timestep-toggle {
    color: var(--text-muted);
    font-size: 12px;
    transition: transform 0.2s;
}

.timestep-toggle.expanded {
    transform: rotate(90deg);
}

.timestep-content {
    display: none;
    padding: 20px;
}

.timestep-content.expanded {
    display: block;
}

/* LLM Call section */
.llm-call {
    background: linear-gradient(135deg, var(--accent-blue-light), #eff6ff);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    padding: 16px;
}

.llm-call h4 {
    font-size: 13px;
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 12px;
}

.llm-call-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.llm-call-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.llm-call-meta .label {
    color: var(--text-muted);
}

.llm-call-meta .value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Split view */
.split-view-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.split-left {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.split-right {
    background: linear-gradient(135deg, var(--accent-green-light), #ecfdf5);
    border: 1px solid #a7f3d0;
    border-radius: var(--radius-md);
    padding: 12px;
    max-height: 750px;
    overflow-y: auto;
}

.split-right h5 {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Query/Response sections */
.llm-query-section,
.llm-response-section {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-md);
    padding: 10px;
}

.llm-query-section h5,
.llm-response-section h5 {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.query-block {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    color: var(--text-secondary);
    max-height: 300px;
    overflow-y: auto;
}

.content-block {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 1.4;
    white-space: pre-wrap;
    color: var(--text-secondary);
}

/* Query highlight */
.query-highlight {
    color: var(--accent-blue);
    font-weight: 600;
}

/* Truncated text with expand */
.truncated-text {
    display: inline;
}

.truncated-visible {
    display: inline;
}

.truncated-full {
    display: none;
}

.truncated-expander {
    display: block;
    text-align: center;
    padding: 12px 16px;
    margin: 8px 0;
    background: linear-gradient(135deg, var(--accent-blue-light), #dbeafe);
    border: 1px dashed var(--accent-blue);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.truncated-expander:hover {
    background: linear-gradient(135deg, #bfdbfe, var(--accent-blue-light));
    border-style: solid;
}

.expander-dots {
    display: block;
    font-size: 18px;
    font-weight: bold;
    color: var(--accent-blue);
    letter-spacing: 4px;
    margin-bottom: 4px;
}

.expander-info {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Inline REPL highlighting */
.repl-inline {
    display: inline;
    background: color-mix(in srgb, var(--link-color) 15%, transparent);
    border-left: 3px solid var(--link-color);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.repl-inline:hover {
    background: color-mix(in srgb, var(--link-color) 25%, transparent);
}

.repl-inline.highlight {
    background: color-mix(in srgb, var(--link-color) 30%, transparent);
    border-left-width: 4px;
}

.repl-tag {
    color: var(--link-color);
    font-weight: 600;
}

.repl-inline-code {
    color: var(--text-primary);
}

.repl-inline-link {
    display: inline-block;
    background: var(--link-color);
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 4px;
    vertical-align: middle;
}


.response-block {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 12px;
    white-space: pre-wrap;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    word-break: break-word;
    color: var(--text-secondary);
    max-height: 400px;
    overflow-y: auto;
}

/* Jupyter Notebook Style */
.jupyter-notebook {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.jupyter-cell {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--cell-color);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.15s;
}

.jupyter-cell:hover {
    border-color: var(--cell-color);
    box-shadow: var(--shadow-sm);
}

.jupyter-cell.highlight {
    border-color: var(--cell-color);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--cell-color) 30%, transparent);
}

.jupyter-cell.error {
    border-left-color: var(--accent-red);
}

.jupyter-input,
.jupyter-output {
    display: flex;
    align-items: stretch;
}

.jupyter-input {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.jupyter-output {
    background: white;
}

.jupyter-output.error {
    background: #fef2f2;
}

.jupyter-prompt {
    width: 50px;
    min-width: 50px;
    padding: 8px 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    text-align: right;
    user-select: none;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}

.input-prompt {
    color: #2563eb;
    background: #eff6ff;
    border-right: 1px solid #bfdbfe;
}

.output-prompt {
    color: #dc2626;
    background: #fef2f2;
    border-right: 1px solid #fecaca;
}

.jupyter-code,
.jupyter-result {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    overflow-x: auto;
}

.jupyter-code {
    background: #1e293b;
}

.jupyter-code pre {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    color: #e2e8f0;
}

.jupyter-code code {
    font-family: inherit;
}

.jupyter-result {
    background: white;
}

.jupyter-result pre {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
    max-height: 200px;
    overflow-y: auto;
}

.jupyter-error {
    color: var(--accent-red);
    display: block;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid #fecaca;
}

.no-executions {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 16px;
    font-size: 11px;
}

/* Final Answer Block */
.final-answer-block {
    margin-top: 12px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.final-answer-header {
    background: #f59e0b;
    color: white;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 10px;
}

.final-answer-text {
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    color: #92400e;
    line-height: 1.4;
}

/* Recursive calls section (in right panel) */
.recursive-calls-section {
    margin-top: 12px;
    border: 1px solid #fcd34d;
    border-radius: var(--radius-sm);
    background: #fffbeb;
    overflow: hidden;
}

.recursive-calls-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #fef3c7;
    transition: background 0.15s;
}

.recursive-calls-header:hover {
    background: #fde68a;
}

.recursive-title {
    font-size: 10px;
    font-weight: 700;
    color: #92400e;
    text-transform: uppercase;
}

.recursive-calls-toggle {
    color: #92400e;
    font-size: 12px;
    transition: transform 0.2s;
}

.recursive-calls-toggle.expanded {
    transform: rotate(90deg);
}

.recursive-calls-content {
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
}

.recursive-calls-content.expanded {
    display: flex;
}

/* Sub-LM Call Items */
.sub-lm-call {
    background: white;
    border: 1px solid #fcd34d;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.sub-lm-call.expanded {
    border-color: #f59e0b;
}

.sub-lm-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    background: #fef3c7;
    transition: background 0.15s;
}

.sub-lm-header:hover {
    background: #fde68a;
}

.sub-lm-num {
    font-size: 11px;
    font-weight: 700;
    color: #92400e;
}

.sub-lm-meta {
    flex: 1;
    font-size: 10px;
    color: var(--text-muted);
}

.sub-lm-toggle {
    font-size: 12px;
    color: #92400e;
    transition: transform 0.2s;
}

.sub-lm-toggle.expanded {
    transform: rotate(90deg);
}

.sub-lm-preview {
    padding: 8px 10px;
    font-size: 10px;
    color: var(--text-secondary);
    line-height: 1.4;
    border-top: 1px solid #fef3c7;
}

.sub-lm-call.expanded .sub-lm-preview {
    display: none;
}

.sub-lm-detail {
    display: none;
    border-top: 1px solid #fde68a;
}

.sub-lm-detail.expanded {
    display: block;
}

.sub-lm-section {
    padding: 8px 10px;
    border-bottom: 1px solid #fef3c7;
}

.sub-lm-section:last-child {
    border-bottom: none;
}

.sub-lm-label {
    font-size: 9px;
    font-weight: 700;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.sub-lm-content {
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 1.4;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
}

.content-block.small {
    font-size: 10px;
    padding: 6px;
    max-height: 80px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 1200px) {
    .split-view-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 16px;
    }

    .header {
        padding: 12px 16px;
        flex-direction: column;
        gap: 12px;
    }

    .info-cards {
        grid-template-columns: 1fr;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .session-selector-modal {
        width: 100%;
    }
}

/* Dark mode - applied via class or system preference */
@media (prefers-color-scheme: dark) {
    html:not(.light) {
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-tertiary: #334155;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;
        --border-color: #334155;
        --border-light: #475569;
    }
}

/* Dark mode via class (manual toggle) */
html.dark {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #475569;
}

@media (prefers-color-scheme: dark) {
    html:not(.light) .header {
        background: rgba(30, 41, 59, 0.95);
    }

    html:not(.light) .llm-call {
        background: linear-gradient(135deg, #1e3a5f, #1e293b);
        border-color: #3b82f6;
    }

    html:not(.light) .llm-call h4 {
        color: #93c5fd;
    }

    html:not(.light) .llm-call-meta .meta-item {
        background: rgba(0, 0, 0, 0.3);
    }

    html:not(.light) .llm-call-meta .label {
        color: #94a3b8;
    }

    html:not(.light) .llm-call-meta .value {
        color: #e2e8f0;
    }

    html:not(.light) .split-right {
        background: linear-gradient(135deg, #14532d, #1e293b);
        border-color: #22c55e;
    }

    html:not(.light) .split-right h5 {
        color: #86efac;
    }

    html:not(.light) .final-answer-content {
        background: linear-gradient(135deg, #14532d, #1e293b);
        border-color: #22c55e;
        color: #86efac;
    }

    html:not(.light) .recursive-calls-in-timestep {
        background: linear-gradient(135deg, #78350f, #1e293b);
        border-color: #f59e0b;
    }

    html:not(.light) .repl-block-container {
        background: var(--bg-secondary);
    }

    html:not(.light) .llm-query-section,
    html:not(.light) .llm-response-section {
        background: rgba(0, 0, 0, 0.2);
    }

    html:not(.light) .execution-link,
    html:not(.light) .block-link {
        background: rgba(59, 130, 246, 0.2);
    }

    /* Jupyter notebook dark mode */
    html:not(.light) .jupyter-cell {
        background: var(--bg-secondary);
        border-color: var(--border-color);
    }

    html:not(.light) .jupyter-input {
        background: #1e293b;
        border-bottom-color: var(--border-color);
    }

    html:not(.light) .jupyter-output {
        background: #0f172a;
    }

    html:not(.light) .jupyter-output.error {
        background: #450a0a;
    }

    html:not(.light) .input-prompt {
        background: #1e3a8a;
        border-right-color: #3b82f6;
        color: #93c5fd;
    }

    html:not(.light) .output-prompt {
        background: #450a0a;
        border-right-color: #dc2626;
        color: #fca5a5;
    }

    html:not(.light) .jupyter-result {
        background: #0f172a;
    }

    html:not(.light) .jupyter-result pre {
        color: #e2e8f0;
    }

    html:not(.light) .jupyter-error {
        color: #fca5a5;
        border-top-color: #7f1d1d;
    }

    /* Sub-LM calls dark mode */
    html:not(.light) .recursive-calls-section {
        background: #1e293b;
        border-color: #f59e0b;
    }

    html:not(.light) .recursive-calls-header {
        background: #334155;
    }

    html:not(.light) .recursive-calls-header:hover {
        background: #475569;
    }

    html:not(.light) .recursive-title {
        color: #fbbf24;
    }

    html:not(.light) .recursive-calls-toggle {
        color: #fbbf24;
    }

    html:not(.light) .sub-lm-call {
        background: #0f172a;
        border-color: #475569;
    }

    html:not(.light) .sub-lm-header {
        background: #334155;
    }

    html:not(.light) .sub-lm-header:hover {
        background: #475569;
    }

    html:not(.light) .sub-lm-num {
        color: #fbbf24;
    }

    html:not(.light) .sub-lm-meta {
        color: #94a3b8;
    }

    html:not(.light) .sub-lm-toggle {
        color: #94a3b8;
    }

    html:not(.light) .sub-lm-preview {
        border-top-color: #334155;
        color: #cbd5e1;
        background: #1e293b;
    }

    html:not(.light) .sub-lm-detail {
        border-top-color: #334155;
        background: #1e293b;
    }

    html:not(.light) .sub-lm-section {
        border-bottom-color: #334155;
    }

    html:not(.light) .sub-lm-label {
        color: #fbbf24;
    }

    html:not(.light) .sub-lm-content {
        color: #e2e8f0;
        background: #0f172a;
        padding: 8px;
        border-radius: 4px;
    }
}

/* Dark mode styles when .dark class is applied */
html.dark .header {
    background: rgba(30, 41, 59, 0.95);
}

html.dark .llm-call {
    background: linear-gradient(135deg, #1e3a5f, #1e293b);
    border-color: #3b82f6;
}

html.dark .llm-call h4 {
    color: #93c5fd;
}

html.dark .llm-call-meta .meta-item {
    background: rgba(0, 0, 0, 0.3);
}

html.dark .llm-call-meta .label {
    color: #94a3b8;
}

html.dark .llm-call-meta .value {
    color: #e2e8f0;
}

html.dark .split-right {
    background: linear-gradient(135deg, #14532d, #1e293b);
    border-color: #22c55e;
}

html.dark .split-right h5 {
    color: #86efac;
}

html.dark .final-answer-content {
    background: linear-gradient(135deg, #14532d, #1e293b);
    border-color: #22c55e;
    color: #86efac;
}

html.dark .recursive-calls-in-timestep {
    background: linear-gradient(135deg, #78350f, #1e293b);
    border-color: #f59e0b;
}

html.dark .repl-block-container {
    background: var(--bg-secondary);
}

html.dark .llm-query-section,
html.dark .llm-response-section {
    background: rgba(0, 0, 0, 0.2);
}

html.dark .execution-link,
html.dark .block-link {
    background: rgba(59, 130, 246, 0.2);
}

html.dark .jupyter-cell {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

html.dark .jupyter-input {
    background: #1e293b;
    border-bottom-color: var(--border-color);
}

html.dark .jupyter-output {
    background: #0f172a;
}

html.dark .jupyter-output.error {
    background: #450a0a;
}

html.dark .input-prompt {
    background: #1e3a8a;
    border-right-color: #3b82f6;
    color: #93c5fd;
}

html.dark .output-prompt {
    background: #450a0a;
    border-right-color: #dc2626;
    color: #fca5a5;
}

html.dark .jupyter-result {
    background: #0f172a;
}

html.dark .jupyter-result pre {
    color: #e2e8f0;
}

html.dark .jupyter-error {
    color: #fca5a5;
    border-top-color: #7f1d1d;
}

html.dark .recursive-calls-section {
    background: #1e293b;
    border-color: #f59e0b;
}

html.dark .recursive-calls-header {
    background: #334155;
}

html.dark .recursive-calls-header:hover {
    background: #475569;
}

html.dark .recursive-title {
    color: #fbbf24;
}

html.dark .recursive-calls-toggle {
    color: #fbbf24;
}

html.dark .sub-lm-call {
    background: #0f172a;
    border-color: #475569;
}

html.dark .sub-lm-header {
    background: #334155;
}

html.dark .sub-lm-header:hover {
    background: #475569;
}

html.dark .sub-lm-num {
    color: #fbbf24;
}

html.dark .sub-lm-meta {
    color: #94a3b8;
}

html.dark .sub-lm-toggle {
    color: #94a3b8;
}

html.dark .sub-lm-preview {
    border-top-color: #334155;
    color: #cbd5e1;
    background: #1e293b;
}

html.dark .sub-lm-detail {
    border-top-color: #334155;
    background: #1e293b;
}

html.dark .sub-lm-section {
    border-bottom-color: #334155;
}

html.dark .sub-lm-label {
    color: #fbbf24;
}

html.dark .sub-lm-content {
    color: #e2e8f0;
    background: #0f172a;
    padding: 8px;
    border-radius: 4px;
}

/* Prism overrides */
.token.comment { color: #6a9955; }
.token.punctuation { color: #d4d4d4; }
.token.property, .token.tag, .token.boolean, .token.number { color: #b5cea8; }
.token.string, .token.char { color: #ce9178; }
.token.keyword { color: #569cd6; }
.token.function { color: #dcdcaa; }
.token.variable { color: #9cdcfe; }
