* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Accent colors (set per theme) */
    --theme-border: #1b5e20;
    --theme-bg: #e8f5e9;
    --theme-hover-bg: #c8e6c9;
    --theme-accent: #1b5e20;
    --theme-accent-rgb: 27, 94, 32;

    /* UI surface colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #fafafa;
    --bg-input: #ffffff;
    --bg-hover: #f0f0f0;
    --bg-card: #ffffff;

    /* Text colors */
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;

    /* Border colors */
    --border-primary: #e0e0e0;
    --border-subtle: #f0f0f0;
}

body {
    font-family: 'JetBrains Mono', monospace;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

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

/* Tab Bar */
.tab-bar {
    display: flex;
    align-items: stretch;
    background: var(--bg-primary);
    padding: 0;
    gap: 0;
    overflow: hidden;
    border-bottom: 1px solid var(--border-primary);
    height: 25px;
    position: relative;
    z-index: 10;
}

.tab-bar-spacer {
    flex: 1;
}

#dynamicTabs {
    display: flex;
    align-items: stretch;
    min-width: 0;
    flex: 0 1 auto;
    overflow: hidden;
}

.tab {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    background: var(--bg-primary);
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    white-space: nowrap;
    transition: all 0.15s;
    border-right: 1px solid var(--border-subtle);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.5px;
    position: relative;
    flex-shrink: 1;
    min-width: 36px;
    overflow: hidden;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--theme-accent);
    font-weight: 500;
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1.5px;
    background: var(--theme-accent);
}

.tab-bar > .tab {
    flex-shrink: 0;
}

.tab-title {
    font-size: 10px;
    font-weight: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-close {
    margin-left: 6px;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.15s;
    line-height: 1;
}

.tab:hover .tab-close {
    opacity: 0.4;
}

.tab-close:hover {
    opacity: 1 !important;
}

.tab-status {
    width: 8px;
    height: 8px;
    position: relative;
    margin-left: 2px;
}

.tab-status.generating {
    animation: orbit-rotate 1.2s linear infinite;
}

.tab-status span {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: var(--theme-accent);
    top: 50%;
    left: 50%;
}

.tab-status span:nth-child(1) {
    transform: translate(-50%, -50%) translateY(-3px);
}

.tab-status span:nth-child(2) {
    transform: translate(-50%, -50%) rotate(120deg) translateY(-3px);
}

.tab-status span:nth-child(3) {
    transform: translate(-50%, -50%) rotate(240deg) translateY(-3px);
}

@keyframes orbit-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.settings-btn,
.files-btn,
.debug-btn,
.sessions-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-left: 1px solid var(--border-subtle);
    padding: 0 8px;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.settings-btn:hover,
.files-btn:hover,
.debug-btn:hover,
.sessions-btn:hover {
    color: var(--text-primary);
}

.settings-btn.active,
.files-btn.active,
.debug-btn.active,
.sessions-btn.active {
    color: var(--theme-accent);
    font-weight: 500;
}

.new-tab-wrapper {
    position: static;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    border-right: 1px solid var(--border-subtle);
}

.new-tab-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 0 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    line-height: 1;
}

.new-tab-btn:hover {
    color: var(--text-primary);
}

.new-tab-menu {
    display: none;
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 9999;
    min-width: 180px;
}

.new-tab-menu.active {
    display: block;
}

.menu-item {
    padding: 8px 12px;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.3px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    transition: all 0.15s;
    color: var(--text-primary);
    background: var(--bg-card);
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: var(--theme-accent);
    color: white;
}

/* Content Area */
.content-area {
    flex: 1;
    overflow: hidden;
    position: relative;
    z-index: 1;
    transition: margin-right 0.3s ease;
    display: flex;
}

.panel-open .content-area {
    margin-right: 480px;
}

.files-panel-open .content-area {
    margin-right: 320px;
}

/* Left Sidebar - Agents Overview */
.agents-sidebar {
    width: var(--sidebar-width, 180px);
    min-width: 140px;
    max-width: 400px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    overflow: visible;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.sidebar-resize-handle {
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 11;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: clip;
    padding: 8px 12px;
}

.sidebar-empty {
    padding: 12px;
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
}

/* Sidebar Legend */
.sidebar-legend {
    padding: 8px 12px;
    border-top: 1px solid var(--border-primary);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 9px;
    color: var(--text-muted);
}

.sidebar-legend span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-square {
    width: 5px;
    height: 5px;
    background: var(--theme-accent);
}

.legend-circle {
    width: 5px;
    height: 5px;
    background: var(--theme-accent);
    border-radius: 50%;
}

.legend-box {
    width: 12px;
    height: 6px;
    background: var(--bg-card);
    border: 1px solid var(--theme-accent);
    border-radius: 1px;
}

/* Sidebar Controls */
.sidebar-controls {
    padding: 8px 12px;
    border-top: 1px solid var(--border-primary);
    display: flex;
    gap: 12px;
}

.sidebar-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.sidebar-checkbox input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    accent-color: var(--theme-accent);
}

/* Timeline Widget */
.tl-widget {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.tl-widget:last-child {
    margin-bottom: 0;
}

.tl-widget.active .tl-name {
    color: var(--theme-accent);
}

/* Active tab indicator arrow — right side of workspace-block and agent-box */
.tl-widget.active > .workspace-block::before {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-right: 5px solid var(--theme-accent);
}

.tl-widget.closed {
    opacity: 0.5;
}

.tl-widget.closed .tl-name::after {
    content: ' (closed)';
    font-weight: normal;
    font-size: 8px;
}

/* Workspace block - left edge aligned with vertical line */
.workspace-block {
    display: flex;
    align-items: stretch;
    margin-bottom: 8px;
    margin-left: 4px;  /* Align left edge with vertical line at 4px */
    position: relative;
    border: 1px solid var(--theme-accent);
}

/* Line connecting workspace block to timeline */
.tl-widget.compact > .workspace-block::after {
    content: '';
    position: absolute;
    left: -1px;  /* Align with vertical line */
    top: calc(100% + 1px);  /* Start below the border */
    width: 1px;
    height: 8px;
    background: var(--border-primary);
}

.workspace-label {
    padding: 3px 6px;
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    background: var(--theme-accent);
    color: var(--bg-primary);
    flex-shrink: 0;
}

.workspace-name {
    padding: 3px 8px;
    font-size: 9px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.tl-widget.closed .workspace-block {
    opacity: 0.5;
}

/* Timeline - vertical line from first to last dot */
.tl {
    position: relative;
    margin-left: 2px;
    padding-left: 16px;
}

/* The vertical line - centered on dots */
.tl::before {
    content: '';
    position: absolute;
    left: 2px;
    top: var(--line-top, 0);
    height: var(--line-height, 0);
    width: 1px;
    background: var(--border-primary);
}

/* Row */
.tl-row {
    position: relative;
    margin-bottom: 4px;
}

.tl-row:last-child {
    margin-bottom: 0;
}

/* Dot - sits on the vertical line */
.tl-dot {
    position: absolute;
    left: -16px;
    top: -2px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--theme-accent);
    cursor: pointer;
    transition: transform 0.1s;
    z-index: 2;
}

.tl-dot:hover {
    transform: scale(1.3);
}

/* User messages are square */
.tl-row.user .tl-dot {
    border-radius: 0;
}

/* Generating dot animation */
.tl-dot.generating {
    animation: pulse 1s ease-in-out infinite;
}

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

/* Inline label next to dot — always visible, single line truncated */
.tl-label {
    position: absolute;
    left: -6px;
    right: 0;
    top: -5px;
    font-size: 8px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tool tag widget — colored label + description */
.tl-tool {
    position: absolute;
    left: -6px;
    right: 0;
    top: -6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tl-tool-tag {
    font-size: 6px;
    font-weight: 600;
    letter-spacing: 0.3px;
    background: var(--theme-accent);
    color: var(--bg-primary);
    padding: 1px 4px;
    border-radius: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

.tl-tool-text {
    font-size: 8px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* On hover: show popup with full text for tool entries */
.tl-row.turn:hover .tl-tool {
    z-index: 10;
    right: auto;
    max-width: calc(var(--sidebar-width, 180px) - 40px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    padding: 3px 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.tl-row.turn:hover .tl-tool-text {
    white-space: normal;
    word-break: break-word;
    overflow: visible;
    color: var(--text-primary);
}

/* On hover: show popup with full text */
.tl-row.turn:hover .tl-label {
    z-index: 10;
    white-space: normal;
    word-break: break-word;
    overflow: visible;
    right: auto;
    max-width: calc(var(--sidebar-width, 180px) - 40px);
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    padding: 3px 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* Horizontal connector to agent */
.tl-row.has-agent .tl-dot::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 11px;
    height: 1px;
    background: var(--theme-accent);
}

/* Agent box - compact style */
.agent-box {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--theme-accent);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* Active tab indicator arrow on agent-box */
.agent-box.active {
    overflow: visible;
}

.agent-box.active::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-right: 5px solid var(--theme-accent);
}

.agent-header {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 4px;
    margin: -1px 0 -1px -1px;
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    background: var(--theme-accent);
    color: var(--bg-primary);
    flex-shrink: 0;
}

/* Collapse toggle - inside agent header, white arrow */
.agent-header .collapse-toggle {
    width: 8px;
    height: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.agent-header .collapse-toggle::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-top: 4px solid var(--bg-primary);
    transition: transform 0.2s;
}

.agent-header .collapse-toggle.collapsed::before {
    transform: rotate(-90deg);
}

.agent-body {
    padding: 2px 6px;
    font-size: 9px;
    background: var(--bg-tertiary);
    border: none;
    display: flex;
    align-items: center;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
}

.agent-body-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-status {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding-left: 6px;
    color: var(--text-muted);
    font-size: 8px;
    flex-shrink: 0;
}

/* Progress spinner */
.agent-progress {
    width: 8px;
    height: 8px;
    position: relative;
    animation: orbit-rotate 1.2s linear infinite;
}

.agent-progress span {
    position: absolute;
    width: 1.5px;
    height: 1.5px;
    border-radius: 50%;
    background: var(--theme-accent);
    top: 50%;
    left: 50%;
}

.agent-progress span:nth-child(1) { transform: translate(-50%, -50%) translateY(-3px); }
.agent-progress span:nth-child(2) { transform: translate(-50%, -50%) rotate(120deg) translateY(-3px); }
.agent-progress span:nth-child(3) { transform: translate(-50%, -50%) rotate(240deg) translateY(-3px); }

/* Done checkmark */
.agent-done {
    width: 8px;
    height: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agent-done::before {
    content: '';
    width: 2px;
    height: 5px;
    border: 1px solid var(--theme-accent);
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-1px, -1px);
}

/* Aborted agent - cross instead of checkmark */
.agent-done.aborted::before {
    content: '×';
    width: auto;
    height: auto;
    border: none;
    transform: none;
    font-size: 10px;
    line-height: 1;
    color: var(--text-secondary);
}

/* Simple turn - natural height from label, min-height fallback */
.tl-row.turn {
    min-height: 12px;
}

.tl-turn-count {
    font-size: 8px;
    color: var(--text-muted);
    white-space: nowrap;
    position: absolute;
    left: -6px;
    top: -5px;
}

/* Nested timeline for sub-agents */
.tl-nested {
    position: relative;
    margin-left: -2px;
    margin-top: 0;
}

.tl-nested .tl {
    margin-left: 0;
    padding-top: 6px;
}

/* Return row - positioned dynamically by JS to align with last nested dot */
.tl-row.tl-return {
    position: relative;
}

/* Horizontal connector - positioned from dot's right edge, width set by JS */
.tl-return-connector {
    position: absolute;
    left: -11px;  /* dot is at -16px, width 5px, so right edge is -11px */
    top: 0;
    height: 1px;
    background: var(--border-primary);
}

/* Collapsible sub-agents */
.tl-nested.collapsed .tl-row,
.tl-nested.collapsed .tl-widget {
    display: none;
}

.tl-nested.collapsed {
    padding-bottom: 6px;
}

.tl-nested.collapsed .tl {
    --line-height: 0 !important;
    --line-top: 0 !important;
    padding-top: 0;
    min-height: 0;
}

.tl-nested.collapsed .tl::before {
    display: none;
}

/* Main Content Area (right of sidebar) */
.main-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.tab-content {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Launcher Buttons */
.launcher-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 6px 12px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.launcher-btn:hover {
    background: var(--theme-accent);
    color: var(--bg-primary);
    border-color: var(--theme-accent);
}

.launcher-btn:active {
    transform: translateY(1px);
}

/* Agent Content */
.agent-interface {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.agent-interface > .agent-header {
    background: var(--bg-secondary);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-primary);
    display: none; /* Hidden for cleaner UI */
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

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

.agent-type {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.agent-interface > .agent-header h2 {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 1px;
    color: var(--text-primary);
    margin-top: 4px;
}

.agent-interface > .agent-body {
    flex: 1;
    display: block;
    align-items: initial;
    background: var(--bg-primary);
    padding: 20px;
    overflow-y: auto;
}

.chat-container {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    font-size: 12px;
}

.jupyter-notebook-container {
    width: 100%;
    margin: 0;
    max-width: 100%;
    font-size: 13px;
}

.welcome-message {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
    max-width: 700px;
    margin: 0 auto;
    padding: 20px 20px;
}

.welcome-message p {
    margin-bottom: 10px;
}

.welcome-message ul {
    list-style: none;
    padding-left: 0;
    margin: 12px 0;
}

.welcome-message li {
    margin: 8px 0;
    padding-left: 20px;
    position: relative;
}

.welcome-message li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--theme-accent);
}

.welcome-message strong {
    color: var(--text-secondary);
    font-weight: 500;
}

.workflow-diagram {
    margin: 20px 0;
    padding: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
}

.diagram-svg {
    width: 100%;
    max-width: 500px;
    height: auto;
    display: block;
    margin: 0 auto;
    font-family: inherit;
}

/* Messages */
.message {
    margin-bottom: 20px;
    line-height: 1.6;
}

.message.user {
    padding: 6px 12px;
    background: rgba(var(--theme-accent-rgb), 0.12);
    border-left: 2px solid var(--theme-accent);
    color: var(--text-primary);
}

.message.assistant {
    padding: 0;
    color: var(--text-primary);
}

.message.assistant > .action-widget {
    margin-left: 15px;
}

/* Unified message content styling for both user and assistant messages */
.message-content {
    line-height: 1.6;
}

.message.assistant .message-content {
    padding-left: 15px;
}

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 24px;
    list-style-position: outside;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content code {
    background: var(--border-primary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

.message-content pre {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
    border: 1px solid var(--border-primary);
}

.message-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: 12px;
}

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

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

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 12px 0 8px 0;
    font-weight: 600;
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child,
.message-content h4:first-child,
.message-content h5:first-child,
.message-content h6:first-child {
    margin-top: 0;
}

.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.15em; }
.message-content h4 { font-size: 1.05em; }
.message-content h5 { font-size: 1em; }
.message-content h6 { font-size: 0.95em; color: var(--text-secondary); }

/* Blockquotes */
.message-content blockquote {
    margin: 8px 0;
    padding: 8px 16px;
    border-left: 4px solid var(--theme-accent, #4a9eff);
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.message-content blockquote p {
    margin: 0;
}

/* Strikethrough */
.message-content del {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Horizontal rule */
.message-content hr {
    border: none;
    border-top: 1px solid var(--border-primary);
    margin: 16px 0;
}

/* LaTeX / KaTeX */
.message-content .katex-display {
    margin: 12px 0;
    overflow: visible;
}

.message-content .katex-error {
    color: #c62828;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

.system-message {
    padding: 8px 12px;
    margin: 8px 0;
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    border-radius: 4px;
    background: var(--bg-tertiary);
}


.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 24px;
    list-style-position: outside;
}

.message-content li {
    margin-bottom: 4px;
    white-space: normal;
}

.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 12px 0 8px 0;
    font-weight: 500;
    white-space: normal;
}

.message-content h1 {
    font-size: 16px;
}

.message-content h2 {
    font-size: 15px;
}

.message-content h3 {
    font-size: 14px;
}

.message-content p {
    margin: 0;
    white-space: pre-wrap;
}

.message-content p:not(:last-child) {
    margin-bottom: 8px;
}

.message-content code {
    background: var(--border-primary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

.message-content pre {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
    border: 1px solid var(--border-primary);
}

.message-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: 12px;
}

/* Override Prism.js defaults (white text-shadow and semi-transparent backgrounds) */
code[class*="language-"],
pre[class*="language-"] {
    text-shadow: none !important;
}

pre code [class*="token"] {
    background: transparent !important;
    text-shadow: none !important;
}

/* Code Cell Styling */
.code-cell {
    margin: 16px 0;
    overflow: hidden;
}

.code-cell-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--bg-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    background: var(--theme-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-cell-label:hover {
    opacity: 0.9;
}

.code-cell-code {
    background: var(--bg-tertiary);
    padding: 0;
    margin: 0;
    border: 1px solid var(--border-primary);
    border-top: none;
}

.code-cell-code pre {
    margin: 0;
    padding: 12px;
    background: transparent;
}

.code-cell-code code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-primary);
    background: transparent;
}

.code-cell-output {
    padding: 12px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary);
}

.code-cell-output.error {
    background: #ffebee;
    color: #c62828;
}

.code-cell-image {
    padding: 12px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-primary);
}

.code-cell-image img {
    max-width: 400px;
    height: auto;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.code-cell-image img:hover {
    opacity: 0.85;
}

.code-cell-image svg {
    max-width: 100%;
    height: auto;
}

.figure-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding: 4px 8px;
    background: var(--border-primary);
    border-radius: 3px;
}

/* Tool cell label with spinner */
.code-cell-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-cell-label .tool-spinner {
    width: 12px;
    height: 12px;
    position: relative;
    animation: orbit-rotate 1.2s linear infinite;
}

.code-cell-label .tool-spinner span {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--bg-card);
    top: 50%;
    left: 50%;
}

.code-cell-label .tool-spinner span:nth-child(1) {
    transform: translate(-50%, -50%) translateY(-4.5px);
}

.code-cell-label .tool-spinner span:nth-child(2) {
    transform: translate(-50%, -50%) rotate(120deg) translateY(-4.5px);
}

.code-cell-label .tool-spinner span:nth-child(3) {
    transform: translate(-50%, -50%) rotate(240deg) translateY(-4.5px);
}

/* Progress widget - shown while waiting for model response */
.progress-widget {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    font-size: 12px;
    color: var(--text-muted);
}

.progress-widget .progress-spinner {
    width: 14px;
    height: 14px;
    position: relative;
    animation: orbit-rotate 1.2s linear infinite;
}

.progress-widget .progress-spinner span {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--theme-accent);
    top: 50%;
    left: 50%;
}

.progress-widget .progress-spinner span:nth-child(1) {
    transform: translate(-50%, -50%) translateY(-5px);
}

.progress-widget .progress-spinner span:nth-child(2) {
    transform: translate(-50%, -50%) rotate(120deg) translateY(-5px);
}

.progress-widget .progress-spinner span:nth-child(3) {
    transform: translate(-50%, -50%) rotate(240deg) translateY(-5px);
}

.progress-widget .progress-text {
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.5px;
}

.input-area {
    padding: 10px 20px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-primary);
}

.input-container {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-container textarea {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-primary);
    min-height: 38px;
    max-height: 200px;
    resize: none;
    overflow-y: hidden;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s ease;
}

.input-container textarea:focus {
    border-color: var(--theme-accent);
    box-shadow: 0 0 0 1px var(--theme-accent);
}

.input-container textarea::placeholder {
    color: var(--text-muted);
}

.input-container button {
    padding: 10px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.5px;
}

.input-container button:hover {
    background: var(--theme-accent);
    color: var(--bg-primary);
    border-color: var(--theme-accent);
}

.input-container button:active {
    transform: translateY(1px);
}

/* Scrollbar styling — global */
*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

*::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
}

*::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 0;
}

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

/* Settings Interface */
.settings-interface {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
}

.settings-header {
    background: var(--bg-secondary);
    padding: 20px;
    border-bottom: 1px solid var(--border-primary);
}

.settings-header h2 {
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 2px;
    color: var(--text-primary);
}

.settings-body {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    max-width: 800px;
}

.settings-section {
    margin-bottom: 16px;
}

.settings-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 6px;
}

.label-text {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.label-description {
    font-size: 9px;
    color: var(--text-secondary);
    font-weight: 300;
}

.settings-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    font-family: inherit;
    font-size: 11px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s ease;
}

.settings-input:focus {
    border-color: var(--theme-accent);
    background: var(--bg-card);
}

.settings-input::placeholder {
    color: var(--text-muted);
}

.settings-textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s ease;
    resize: vertical;
    min-height: 48px;
    box-sizing: border-box;
}

.settings-textarea:focus {
    border-color: var(--theme-accent);
    background: var(--bg-card);
}

.settings-textarea::placeholder {
    color: var(--text-muted);
}

/* Theme Color Picker */
.theme-color-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 6px;
    margin-top: 6px;
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    border: 1.5px solid transparent;
    transition: all 0.15s;
}

.theme-option:hover {
    background: var(--bg-secondary);
}

.theme-option.selected {
    border-color: var(--theme-accent);
    background: var(--bg-secondary);
}

.theme-preview {
    width: 36px;
    height: 20px;
    border-left: 3px solid;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.theme-name {
    font-size: 9px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.theme-option.selected .theme-name {
    color: var(--theme-accent);
}

.settings-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.settings-save-btn,
.settings-cancel-btn {
    padding: 6px 14px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 500;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.3px;
    border: 1px solid var(--border-primary);
}

.settings-save-btn {
    background: var(--theme-accent);
    color: white;
    border-color: var(--theme-accent);
}

.settings-save-btn:hover {
    opacity: 0.85;
}

.settings-cancel-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.settings-cancel-btn:hover {
    background: var(--bg-hover);
}

.settings-status {
    margin-top: 8px;
    font-size: 10px;
    padding: 6px 8px;
    border-radius: 3px;
    display: none;
}

.settings-status.success {
    display: block;
    background: var(--theme-bg);
    color: var(--theme-accent);
    border: 1px solid var(--theme-accent);
}

.settings-status.error {
    display: block;
    background: #ffebee;
    color: #c62828;
    border: 1px solid #c62828;
}

/* Task Widget (matches mock.html design) */
.action-widget {
    margin: 12px 0;
    overflow: hidden;
}

.action-widget-clickable {
    cursor: pointer;
}

.action-widget-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--theme-accent);
    transition: opacity 0.2s;
}

.action-widget-clickable:hover .action-widget-header {
    opacity: 0.9;
}

.action-widget-type {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bg-primary);
}

.action-widget-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

/* Orbiting Dots Indicator for action widget */
.action-widget .orbit-indicator {
    width: 14px;
    height: 14px;
    position: relative;
    animation: orbit-rotate 1.2s linear infinite;
}

.action-widget .orbit-indicator span {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--bg-card);
    top: 50%;
    left: 50%;
}

.action-widget .orbit-indicator span:nth-child(1) {
    transform: translate(-50%, -50%) translateY(-5px);
}

.action-widget .orbit-indicator span:nth-child(2) {
    transform: translate(-50%, -50%) rotate(120deg) translateY(-5px);
}

.action-widget .orbit-indicator span:nth-child(3) {
    transform: translate(-50%, -50%) rotate(240deg) translateY(-5px);
}

/* Done indicator - checkmark */
.action-widget .done-indicator {
    width: 14px;
    height: 14px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-widget .done-indicator::before {
    content: '';
    position: absolute;
    width: 4px;
    height: 7px;
    border: 1.5px solid var(--bg-primary);
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-1px, -1px);
}

/* Aborted action widget - cross instead of checkmark */
.action-widget .done-indicator.aborted::before {
    content: '×';
    width: auto;
    height: auto;
    border: none;
    transform: none;
    font-size: 12px;
    line-height: 1;
    color: var(--bg-primary);
}

.action-widget-body {
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-top: none;
}

.action-widget .section-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.action-widget .section-content {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-primary);
}

.action-widget .section-content ul,
.action-widget .section-content ol {
    margin: 8px 0;
    padding-left: 24px;
    list-style-position: outside;
}

.action-widget .section-content li {
    margin-bottom: 4px;
}

.action-widget .section-content img,
.action-widget img {
    max-width: 400px !important;
    width: auto !important;
    height: auto !important;
    margin: 8px 0;
    border-radius: 3px;
}

.action-widget-result {
    padding: 12px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-card);
    border-top: 1px solid var(--border-primary);
}

.action-widget-result ul,
.action-widget-result ol {
    margin: 8px 0;
    padding-left: 24px;
    list-style-position: outside;
}

.action-widget-result li {
    margin-bottom: 4px;
}

.action-widget-result h1,
.action-widget-result h2,
.action-widget-result h3 {
    margin: 12px 0 8px 0;
    font-weight: 500;
}

.action-widget-result h1 {
    font-size: 14px;
}

.action-widget-result h2 {
    font-size: 13px;
}

.action-widget-result h3 {
    font-size: 12px;
}

.action-widget-result p {
    margin-bottom: 8px;
}

.action-widget-result-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-primary);
}

.action-widget-result img {
    max-width: 400px;
    height: auto;
    margin: 8px 0;
    border-radius: 3px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.action-widget-result img:hover {
    opacity: 0.85;
}

/* File transfer (upload/download) widget styles */
.transfer-paths {
    margin: 0;
    padding-left: 20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

.transfer-paths li {
    margin: 4px 0;
    color: var(--text-primary);
}

.transfer-output {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.transfer-output.error {
    color: #c62828;
}

/* Result Preview in CODE agent */
.result-preview {
    margin: 16px 0;
    overflow: hidden;
}

.result-preview-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--bg-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    background: var(--theme-accent);
}

.result-preview-content {
    padding: 12px 15px;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-top: none;
}

.result-preview-content img {
    max-height: 400px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.result-preview-content img:hover {
    opacity: 0.85;
}

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

    .settings-body {
        padding: 20px;
    }
}

/* Research Agent Styles */
.research-container,
.research-container.message.assistant {
    margin-bottom: 16px;
    margin-left: 0 !important;
    padding: 0 !important;
    padding-left: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
}

.research-container::before,
.research-container.message.assistant::before {
    content: none !important;
    display: none !important;
}

.research-body {
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-top: none;
    line-height: 1.6;
}

.research-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--theme-accent);
    min-height: 28px;
}

.research-header-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--bg-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.queries-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.toggle-irrelevant-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.toggle-irrelevant-label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.toggle-irrelevant-label span {
    cursor: pointer;
}

.research-reasoning-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-primary);
}

.research-reasoning {
    font-size: 11px;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.5;
}

/* Tree structure for queries */
.queries-tree-container {
    position: relative;
    padding-left: 20px;
}

.queries-tree-container::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #666;
}

.query-tree {
    position: relative;
    padding-bottom: 8px;
}

.query-tree::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 10px;
    width: 12px;
    height: 1px;
    background: #666;
}

.query-tree.last::after {
    content: '';
    position: absolute;
    left: -20px;
    top: 11px;
    bottom: 0;
    width: 1px;
    background: var(--bg-secondary);
}

.query-node {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.query-text {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
    flex: 1;
}

.query-stats {
    font-size: 10px;
    white-space: nowrap;
    margin-left: 8px;
}

.stat-relevant {
    color: #2e7d32;
}

.stat-irrelevant {
    color: var(--text-muted);
}

.stat-error {
    color: #c62828;
}

.query-sources-tree {
    position: relative;
    padding-left: 20px;
}

.query-sources-tree::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #888;
}

/* Tree structure for sources */
.source-tree-node {
    position: relative;
    margin-bottom: 1px;
}

.source-tree-node::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 10px;
    width: 12px;
    height: 1px;
    background: #888;
}

.source-tree-node.last::after {
    content: '';
    position: absolute;
    left: -20px;
    top: 11px;
    bottom: 0;
    width: 1px;
    background: var(--bg-secondary);
}

.source-tree-line {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 0;
}

.source-status {
    font-size: 11px;
    min-width: 12px;
    text-align: center;
    user-select: none;
    flex-shrink: 0;
}

.source-status.status-relevant {
    color: #2e7d32;
}

.source-status.status-irrelevant {
    color: var(--text-muted);
}

.source-status.status-error {
    color: #d32f2f;
}

.source-title {
    font-size: 11px;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-controls {
    display: flex;
    gap: 3px;
    align-items: center;
    flex-shrink: 0;
}

.source-control-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 2px;
    padding: 0px 4px;
    font-size: 10px;
    line-height: 16px;
    cursor: pointer;
    color: var(--text-secondary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    transition: all 0.15s;
}

.source-control-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.source-control-btn.toggle-btn {
    font-weight: 600;
}

.source-control-btn.link-btn {
    font-size: 11px;
}

.source-tree-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.2s ease;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.source-tree-content.expanded {
    max-height: 2000px;
    opacity: 1;
    margin-top: 4px;
    margin-bottom: 6px;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border-left: 2px solid var(--border-primary);
    border-radius: 2px;
}

.source-tree-content ul,
.source-tree-content ol {
    margin: 6px 0;
    padding-left: 20px;
    list-style-position: outside;
}

.source-tree-content li {
    margin-bottom: 3px;
}

.source-tree-content h1,
.source-tree-content h2,
.source-tree-content h3 {
    margin: 8px 0 4px 0;
    font-weight: 500;
}

.source-tree-content h1 {
    font-size: 12px;
}

.source-tree-content h2 {
    font-size: 11px;
}

.source-tree-content h3 {
    font-size: 11px;
}

.source-tree-content p {
    margin-bottom: 6px;
}

.research-sources-section {
    margin-bottom: 16px;
}

.research-progress-section {
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border-primary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--theme-accent);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.research-source {
    margin: 6px 0;
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    background: var(--bg-card);
}

.research-source.irrelevant {
    opacity: 0.6;
    background: var(--bg-tertiary);
}

.research-source.error {
    background: #fff5f5;
    border-color: #ffcdd2;
}

.source-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    user-select: none;
}

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

.source-status-icon {
    font-size: 12px;
    min-width: 16px;
    text-align: center;
}

.research-source.relevant .source-status-icon {
    color: #2e7d32;
}

.research-source.irrelevant .source-status-icon {
    color: var(--text-muted);
}

.research-source.error .source-status-icon {
    color: #d32f2f;
}

.source-url {
    color: #1976d2;
    text-decoration: none;
    font-size: 12px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-url:hover {
    text-decoration: underline;
}

.source-toggle {
    color: var(--text-muted);
    font-size: 10px;
}

.source-analysis {
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-primary);
    padding: 0 12px 12px 12px;
    border-top: 1px solid var(--border-primary);
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.source-analysis ul,
.source-analysis ol {
    margin: 8px 0;
    padding-left: 24px;
    list-style-position: outside;
}

.source-analysis li {
    margin-bottom: 4px;
}

.source-analysis h1,
.source-analysis h2,
.source-analysis h3 {
    margin: 12px 0 8px 0;
    font-weight: 500;
}

.source-analysis h1 {
    font-size: 15px;
}

.source-analysis h2 {
    font-size: 14px;
}

.source-analysis h3 {
    font-size: 13px;
}

.source-analysis p {
    margin-bottom: 8px;
}

.research-assessment {
    margin: 20px 0;
    padding: 15px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
}

.assessment-status {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 3px;
}

.assessment-status.complete {
    background: var(--theme-bg);
    color: var(--theme-accent);
}

.assessment-status.continuing {
    background: #fff3e0;
    color: #f57c00;
}

.assessment-info {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.missing-aspects {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    font-size: 12px;
}

.missing-aspects strong {
    color: var(--text-secondary);
    font-weight: 500;
    display: block;
    margin-bottom: 6px;
}

.missing-aspects ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.missing-aspects li {
    padding: 4px 0;
    color: var(--text-primary);
    padding-left: 16px;
    position: relative;
}

.missing-aspects li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #f57c00;
}

.agent-result {
    margin: 12px 0;
    overflow: hidden;
}

.result-header {
    padding: 6px 12px;
    background: var(--theme-accent);
    font-size: 10px;
    font-weight: 600;
    color: var(--bg-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-content {
    padding: 12px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-top: none;
}

.result-content h1,
.result-content h2,
.result-content h3 {
    margin-top: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 500;
}

.result-content h1 {
    font-size: 14px;
}

.result-content h2 {
    font-size: 13px;
}

.result-content h3 {
    font-size: 12px;
}

.result-content p {
    margin-bottom: 12px;
}

.result-content ul,
.result-content ol {
    margin-bottom: 12px;
    padding-left: 24px;
}

.result-content li {
    margin-bottom: 6px;
}

.result-content img {
    max-width: 400px;
    height: auto;
    margin: 8px 0;
    border-radius: 3px;
}

.result-content strong {
    font-weight: 500;
    color: var(--text-primary);
}

.result-content a,
.result-preview-content a,
.source-analysis a,
.action-widget-result a {
    color: var(--theme-accent);
    text-decoration: underline;
}

.result-content a:visited,
.result-preview-content a:visited,
.source-analysis a:visited,
.action-widget-result a:visited {
    color: color-mix(in srgb, var(--theme-accent) 60%, var(--text-muted));
}

/* Markdown tables */
.markdown-table,
.message-content table,
.result-preview-content table,
.action-widget-result table,
.action-widget .section-content table,
.result-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    font-size: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    table-layout: auto;
}

.markdown-table th,
.message-content table th,
.result-preview-content table th,
.action-widget-result table th,
.action-widget .section-content table th,
.result-content table th {
    background: var(--bg-tertiary);
    padding: 6px 8px;
    text-align: left;
    font-weight: 500;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-primary);
}

.markdown-table td,
.message-content table td,
.result-preview-content table td,
.action-widget-result table td,
.action-widget .section-content table td,
.result-content table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: top;
}

.markdown-table tr:last-child td,
.message-content table tr:last-child td,
.result-preview-content table tr:last-child td,
.action-widget-result table tr:last-child td,
.action-widget .section-content table tr:last-child td,
.result-content table tr:last-child td {
    border-bottom: none;
}

.markdown-table tr:hover,
.message-content table tr:hover,
.result-preview-content table tr:hover,
.action-widget-result table tr:hover,
.action-widget .section-content table tr:hover,
.result-content table tr:hover {
    background: var(--bg-tertiary);
}

.result-content code,
.result-preview-content code,
.action-widget-result code,
.action-widget .section-content code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

/* Code blocks in reports, result previews, and action widgets */
.result-content pre,
.result-preview-content pre,
.action-widget-result pre,
.action-widget .section-content pre {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
    border: 1px solid var(--border-primary);
}

.result-content pre code,
.result-preview-content pre code,
.action-widget-result pre code,
.action-widget .section-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

/* Debug Panel */
.debug-panel {
    position: fixed;
    top: 25px;
    right: -600px;
    width: 600px;
    height: calc(100vh - 25px);
    background: var(--bg-card);
    border-left: 1px solid var(--border-primary);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.debug-panel.active {
    right: 0;
}

.debug-header {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--theme-accent);
}

.debug-header h3 {
    margin: 0;
    font-size: 10px;
    font-weight: 500;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.debug-close {
    background: none;
    border: none;
    font-size: 16px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.15s;
}

.debug-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.debug-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.debug-controls {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
}

.debug-refresh {
    padding: 4px 10px;
    background: var(--theme-accent);
    color: white;
    border: none;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: opacity 0.15s;
}

.debug-refresh:hover {
    opacity: 0.9;
}

.debug-content {
    flex: 1;
    padding: 0;
    margin: 0;
    overflow: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    line-height: 1.5;
    background: var(--bg-card);
}

.debug-call-item {
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-card);
}

.debug-call-header {
    padding: 6px 12px;
    background: var(--bg-card);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
    user-select: none;
}

.debug-call-header:hover {
    background: var(--bg-secondary);
}

.debug-call-arrow {
    color: var(--text-secondary);
    font-size: 9px;
    width: 10px;
    display: inline-block;
}

.debug-call-title {
    font-weight: 500;
    font-size: 11px;
    color: var(--text-primary);
    flex: 1;
}

.debug-call-time {
    color: var(--text-muted);
    font-size: 9px;
}

.debug-call-content {
    margin: 0;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
    font-size: 10px;
}

/* Debug button uses same styling as settings/files buttons */

/* Settings Panel (side panel like debug) */
.settings-panel {
    position: fixed;
    top: 25px;
    right: -480px;
    width: 480px;
    height: calc(100vh - 25px);
    background: var(--bg-card);
    border-left: 1px solid var(--border-primary);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.settings-panel.active {
    right: 0;
}

.settings-panel-header {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--theme-accent);
    position: sticky;
    top: 0;
    z-index: 1;
}

.settings-panel-header h3 {
    margin: 0;
    font-size: 10px;
    font-weight: 500;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-path {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin: 0 12px;
}

.settings-panel-close {
    background: none;
    border: none;
    font-size: 16px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.15s;
}

.settings-panel-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.settings-panel-body {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

/* Settings List (providers/models) */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.provider-item,
.model-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    font-size: 11px;
}

.provider-info,
.model-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.provider-name,
.model-name {
    font-weight: 500;
    font-size: 11px;
    color: var(--text-primary);
}

.provider-endpoint,
.model-details {
    font-size: 9px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.provider-actions,
.model-actions {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.provider-edit-btn,
.provider-delete-btn,
.model-edit-btn,
.model-delete-btn {
    background: none;
    border: none;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
    transition: all 0.15s;
}

.provider-edit-btn:hover,
.model-edit-btn:hover {
    background: var(--border-primary);
    color: var(--text-primary);
}

.provider-delete-btn:hover,
.model-delete-btn:hover {
    background: #ffebee;
    color: #c62828;
}

.empty-list {
    padding: 8px;
    text-align: center;
    color: var(--text-muted);
    font-size: 10px;
    font-style: italic;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-primary);
    border-radius: 3px;
}

.settings-add-btn {
    background: none;
    border: 1px dashed var(--border-primary);
    padding: 5px 10px;
    font-family: inherit;
    font-size: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.15s;
    width: 100%;
    text-align: center;
}

.settings-add-btn:hover {
    border-color: var(--theme-accent);
    color: var(--theme-accent);
    background: var(--theme-bg);
}

/* Settings Select (dropdowns) */
.settings-select {
    width: 100%;
    padding: 5px 24px 5px 8px;
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    font-family: inherit;
    font-size: 10px;
    background: var(--bg-card);
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}

.settings-select:hover {
    border-color: #bbb;
}

.settings-select:focus {
    border-color: var(--theme-accent);
}

/* Notebook models grid */
.agent-models-grid {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 4px 8px;
    align-items: center;
}

.agent-models-grid label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

/* Settings Dialog (modal) */
.settings-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.settings-dialog-overlay.active {
    display: flex;
}

.settings-dialog {
    background: var(--bg-card);
    border-radius: 6px;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.settings-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--theme-accent);
}

.settings-dialog-header h3 {
    margin: 0;
    font-size: 10px;
    font-weight: 500;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-dialog-close {
    background: none;
    border: none;
    font-size: 14px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.15s;
}

.settings-dialog-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.settings-dialog-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dialog-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dialog-label {
    font-size: 9px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

.dialog-hint {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
}

.settings-dialog-actions {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
    justify-content: flex-end;
}

.settings-dialog-actions .settings-save-btn,
.settings-dialog-actions .settings-cancel-btn {
    padding: 5px 12px;
    font-size: 10px;
}

/* Files Panel (right side panel, like settings/debug) */
.files-panel {
    position: fixed;
    top: 25px;
    right: -320px;
    width: 320px;
    height: calc(100vh - 25px);
    background: var(--bg-card);
    border-left: 1px solid var(--border-primary);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.files-panel.active {
    right: 0;
}

.files-panel-header {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--theme-accent);
    gap: 8px;
}

.files-panel-header h3 {
    margin: 0;
    font-size: 10px;
    font-weight: 500;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.files-panel-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.files-show-hidden {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
}

.files-show-hidden input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 2px;
    background: transparent;
    cursor: pointer;
    position: relative;
}

.files-show-hidden input[type="checkbox"]:checked {
    background: var(--bg-card);
    border-color: white;
}

.files-show-hidden input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 1px;
    font-size: 10px;
    color: var(--theme-accent);
    font-weight: bold;
}

.files-refresh-btn {
    background: none;
    border: none;
    color: white;
    font-size: 13px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.15s;
}

.files-refresh-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.files-panel-close {
    background: none;
    border: none;
    font-size: 16px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.15s;
}

.files-panel-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.files-panel-body {
    flex: 1;
    padding: 6px 0;
    overflow-y: auto;
    font-size: 11px;
}

.files-loading {
    padding: 12px;
    color: var(--text-secondary);
    text-align: center;
    font-size: 10px;
}

/* File Tree Styles - matching research tree pattern */
.file-tree-root {
    padding: 6px 10px;
}

.file-tree-header {
    font-size: 10px;
    color: var(--text-secondary);
    padding: 0 0 3px 0;
    margin-bottom: 3px;
}

/* Container for tree items - has vertical line */
.file-tree-container {
    position: relative;
    padding-left: 20px;
}

.file-tree-container::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-primary);
}

/* Individual tree item */
.file-tree-item {
    position: relative;
    margin-bottom: 1px;
}

/* Horizontal branch line */
.file-tree-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 10px;
    width: 12px;
    height: 1px;
    background: var(--border-primary);
}

/* Last item covers the vertical line below it */
.file-tree-item.last::after {
    content: '';
    position: absolute;
    left: -20px;
    top: 11px;
    bottom: 0;
    width: 1px;
    background: var(--bg-card);
}

.file-tree-line {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    font-size: 11px;
    color: var(--text-primary);
}

.file-tree-line:hover {
    color: var(--theme-accent);
}

.file-tree-line:hover .file-tree-name {
    text-decoration: underline;
}

.file-tree-icon {
    font-size: 10px;
    min-width: 12px;
    text-align: center;
    color: var(--theme-accent);
    flex-shrink: 0;
}

.file-tree-item.file .file-tree-icon {
    color: transparent;
}

.file-tree-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Children container - same pattern as parent */
.file-tree-children {
    display: none;
    position: relative;
    padding-left: 20px;
}

.file-tree-children::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-primary);
}

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

/* Retry Indicator */
.retry-indicator {
    padding: 12px 16px;
    margin: 8px 0;
    background: #fff3e0;
    border: 1px solid #ffb74d;
    border-radius: 6px;
    animation: retryPulse 2s ease-in-out infinite;
}

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

.retry-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.retry-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #ffb74d;
    border-top-color: #f57c00;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.retry-text {
    flex: 1;
}

.retry-message {
    font-size: 11px;
    color: #e65100;
    margin-bottom: 4px;
}

.retry-status {
    font-size: 10px;
    color: #f57c00;
    font-weight: 500;
}

/* Session Selector (inside welcome message) */
.session-selector {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-primary);
}

/* Welcome explanation section (below session selector) */
.welcome-explanation {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-primary);
    color: var(--text-secondary);
}

.session-selector-form {
    display: flex;
    gap: 20px;
    align-items: flex-end;
}

.session-new {
    flex: 1;
}

.session-existing {
    flex: 1;
}

.session-new label,
.session-existing label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.session-new-input {
    display: flex;
    gap: 6px;
}

.session-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
}

.session-input-wrapper input {
    flex: 1;
    padding: 7px 28px 7px 10px;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    height: 32px;
    box-sizing: border-box;
    background: var(--bg-input);
    color: var(--text-primary);
}

.session-input-wrapper input:focus {
    outline: none;
    border-color: var(--theme-accent);
}

.session-regenerate-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #bbb;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.session-regenerate-btn:hover {
    color: var(--theme-accent);
}

.session-new-input button:not(.session-regenerate-btn) {
    padding: 7px 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.5px;
}

.session-new-input button:not(.session-regenerate-btn):hover {
    background: var(--theme-accent);
    color: var(--bg-primary);
    border-color: var(--theme-accent);
}

.session-existing {
    position: relative;
}

.session-existing::after {
    content: '';
    position: absolute;
    right: 14px;
    bottom: 13px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-muted);
    pointer-events: none;
}

.session-existing select {
    width: 100%;
    padding: 7px 32px 7px 10px;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    height: 32px;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: border-color 0.2s ease;
}

.session-existing select:hover {
    border-color: #bbb;
}

.session-existing select:focus {
    outline: none;
    border-color: var(--theme-accent);
}

/* Sessions Panel (right side) */
.sessions-panel {
    position: fixed;
    top: 25px;
    right: -320px;
    width: 320px;
    height: calc(100vh - 25px);
    background: var(--bg-card);
    border-left: 1px solid var(--border-primary);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.sessions-panel.active {
    right: 0;
}

.sessions-panel-open .content-area {
    margin-right: 320px;
}

.sessions-panel-header {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--theme-accent);
}

.sessions-panel-header h3 {
    margin: 0;
    font-size: 10px;
    font-weight: 500;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sessions-panel-close {
    background: none;
    border: none;
    font-size: 16px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.15s;
}

.sessions-panel-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sessions-panel-body {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.sessions-panel-body label {
    display: block;
    font-size: 9px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.sessions-current-name,
.sessions-new-input {
    display: flex;
    gap: 6px;
}

.sessions-current-name input,
.sessions-new-input input {
    flex: 1;
    padding: 5px 24px 5px 8px;
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    font-size: 11px;
    font-family: inherit;
}

.sessions-new-input .session-input-wrapper {
    width: 180px;
    position: relative;
    display: flex;
}

.sessions-new-input .session-input-wrapper input {
    width: 100%;
    flex: none;
}

.sessions-current-name input:focus,
.sessions-new-input input:focus {
    outline: none;
    border-color: var(--theme-accent);
}

.sessions-current-name button,
.sessions-new-input button:not(.session-regenerate-btn) {
    padding: 5px 10px;
    background: var(--theme-accent);
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.sessions-current-name button:hover,
.sessions-new-input button:not(.session-regenerate-btn):hover {
    opacity: 0.9;
}

.sessions-divider {
    height: 1px;
    background: var(--border-primary);
    margin: 10px 0;
}

.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sessions-list-item {
    padding: 5px 8px;
    background: var(--bg-secondary);
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sessions-list-item:hover {
    background: var(--bg-hover);
}

.sessions-list-item.current {
    background: var(--theme-accent-bg);
    border: 1px solid var(--theme-accent);
}

.sessions-list-item-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
}

.sessions-list-item-date {
    font-size: 9px;
    color: var(--text-muted);
    flex: 1;
    text-align: right;
    margin-right: 6px;
}

.sessions-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s;
}

.sessions-delete-btn:hover {
    color: #e53935;
}

.sessions-loading {
    text-align: center;
    color: var(--text-secondary);
    font-size: 10px;
    padding: 12px;
}

/* ==================== Dark theme shared overrides ==================== */

/* Dark themes: code/pre syntax colors */
[data-theme="terminal"] .message-content code,
[data-theme="terminal"] .action-widget-result code,
[data-theme="terminal"] .result-preview-content code { color: #33ff33; }

[data-theme="noir"] .message-content code,
[data-theme="noir"] .action-widget-result code,
[data-theme="noir"] .result-preview-content code { color: #d4d4d4; }

[data-theme="eclipse"] .message-content code,
[data-theme="eclipse"] .action-widget-result code,
[data-theme="eclipse"] .result-preview-content code { color: #a8c8f0; }

[data-theme="terminal"] .message-content pre,
[data-theme="terminal"] .message-content pre code { color: #33ff33; }

[data-theme="noir"] .message-content pre,
[data-theme="noir"] .message-content pre code { color: #d4d4d4; }

[data-theme="eclipse"] .message-content pre,
[data-theme="eclipse"] .message-content pre code { color: #c8daf0; }

/* Links */
.chat-container a { color: var(--theme-accent); text-decoration: underline; }
.chat-container a:visited { color: color-mix(in srgb, var(--theme-accent) 60%, var(--text-muted)); text-decoration: underline; }

/* Dark themes: links */
[data-theme="terminal"] .chat-container a { color: #33ff33; }
[data-theme="terminal"] .chat-container a:visited { color: #22aa22; }
[data-theme="noir"] .chat-container a { color: #cccccc; }
[data-theme="noir"] .chat-container a:visited { color: #999999; }
[data-theme="eclipse"] .chat-container a { color: #7ab0ff; }
[data-theme="eclipse"] .chat-container a:visited { color: #5a8acc; }

/* Dark themes: active dot glow */
[data-theme="terminal"] .tl-row.active .tl-dot { box-shadow: 0 0 4px #00ff00; }
[data-theme="noir"] .tl-row.active .tl-dot { box-shadow: 0 0 4px #ffffff40; }
[data-theme="eclipse"] .tl-row.active .tl-dot { box-shadow: 0 0 4px #5c9eff60; }

/* Dark themes: input caret */
[data-theme="terminal"] .input-container textarea { caret-color: #00ff00; }
[data-theme="noir"] .input-container textarea { caret-color: #e0e0e0; }
[data-theme="eclipse"] .input-container textarea { caret-color: #5c9eff; }

/* Dark themes: SVG workflow diagrams (hardcoded fill/stroke attributes) */
[data-theme="terminal"] .diagram-svg rect[fill="#fafafa"],
[data-theme="noir"] .diagram-svg rect[fill="#fafafa"],
[data-theme="eclipse"] .diagram-svg rect[fill="#fafafa"] { fill: var(--bg-card); }

[data-theme="terminal"] .diagram-svg rect[fill="white"],
[data-theme="noir"] .diagram-svg rect[fill="white"],
[data-theme="eclipse"] .diagram-svg rect[fill="white"] { fill: var(--bg-tertiary); }

[data-theme="terminal"] .diagram-svg rect[fill="#f5f5f5"],
[data-theme="terminal"] .diagram-svg rect[fill="#f8f8f8"],
[data-theme="terminal"] .diagram-svg rect[fill="#fbfbfb"],
[data-theme="noir"] .diagram-svg rect[fill="#f5f5f5"],
[data-theme="noir"] .diagram-svg rect[fill="#f8f8f8"],
[data-theme="noir"] .diagram-svg rect[fill="#fbfbfb"],
[data-theme="eclipse"] .diagram-svg rect[fill="#f5f5f5"],
[data-theme="eclipse"] .diagram-svg rect[fill="#f8f8f8"],
[data-theme="eclipse"] .diagram-svg rect[fill="#fbfbfb"] { fill: var(--bg-secondary); }

[data-theme="terminal"] .diagram-svg rect[stroke="#e0e0e0"],
[data-theme="terminal"] .diagram-svg rect[stroke="#ccc"],
[data-theme="terminal"] .diagram-svg rect[stroke="#e8e8e8"],
[data-theme="terminal"] .diagram-svg rect[stroke="#eee"],
[data-theme="terminal"] .diagram-svg rect[stroke="#f0f0f0"],
[data-theme="noir"] .diagram-svg rect[stroke="#e0e0e0"],
[data-theme="noir"] .diagram-svg rect[stroke="#ccc"],
[data-theme="noir"] .diagram-svg rect[stroke="#e8e8e8"],
[data-theme="noir"] .diagram-svg rect[stroke="#eee"],
[data-theme="noir"] .diagram-svg rect[stroke="#f0f0f0"],
[data-theme="eclipse"] .diagram-svg rect[stroke="#e0e0e0"],
[data-theme="eclipse"] .diagram-svg rect[stroke="#ccc"],
[data-theme="eclipse"] .diagram-svg rect[stroke="#e8e8e8"],
[data-theme="eclipse"] .diagram-svg rect[stroke="#eee"],
[data-theme="eclipse"] .diagram-svg rect[stroke="#f0f0f0"] { stroke: var(--border-primary); }

[data-theme="terminal"] .diagram-svg text[fill="#333"],
[data-theme="noir"] .diagram-svg text[fill="#333"],
[data-theme="eclipse"] .diagram-svg text[fill="#333"] { fill: var(--text-primary); }

[data-theme="terminal"] .diagram-svg text[fill="#666"],
[data-theme="noir"] .diagram-svg text[fill="#666"],
[data-theme="eclipse"] .diagram-svg text[fill="#666"] { fill: var(--text-secondary); }

[data-theme="terminal"] .diagram-svg text[fill="#999"],
[data-theme="noir"] .diagram-svg text[fill="#999"],
[data-theme="eclipse"] .diagram-svg text[fill="#999"] { fill: var(--text-muted); }

[data-theme="terminal"] .diagram-svg line[stroke="#eee"],
[data-theme="noir"] .diagram-svg line[stroke="#eee"],
[data-theme="eclipse"] .diagram-svg line[stroke="#eee"] { stroke: var(--border-primary); }

/* Dark themes: research tree lines (hardcoded #666/#888) */
[data-theme="terminal"] .query-tree-container::before,
[data-theme="terminal"] .query-tree::before,
[data-theme="terminal"] .source-tree-container::before,
[data-theme="terminal"] .source-tree-node::before,
[data-theme="noir"] .query-tree-container::before,
[data-theme="noir"] .query-tree::before,
[data-theme="noir"] .source-tree-container::before,
[data-theme="noir"] .source-tree-node::before,
[data-theme="eclipse"] .query-tree-container::before,
[data-theme="eclipse"] .query-tree::before,
[data-theme="eclipse"] .source-tree-container::before,
[data-theme="eclipse"] .source-tree-node::before {
    background: var(--border-primary);
}


/* ============================================================
   Agent Tool Cells (search, read, screenshot)
   ============================================================ */

.tool-cell {
    margin: 16px 0;
    overflow: hidden;
}

.tool-cell-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--bg-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    background: var(--theme-accent);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.tool-cell-label:hover {
    opacity: 0.9;
}

.tool-cell-desc {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.tool-cell-input {
    background: var(--bg-tertiary);
    padding: 10px 12px;
    border: 1px solid var(--border-primary);
    border-top: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-primary);
    word-break: break-all;
}

.tool-cell-output {
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-top: none;
    font-size: 12px;
}

.search-results-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.search-result-item a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 12px;
}

.search-result-item a:hover {
    text-decoration: underline;
}

.search-snippet {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.3;
}

.tool-cell-read-summary {
    color: var(--text-muted);
    font-size: 11px;
}

.read-content-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--accent-color);
    font-size: 10px;
    cursor: pointer;
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 6px;
}

.read-content-toggle:hover {
    background: var(--accent-color);
    color: var(--bg-primary);
}

.read-content-body {
    display: none;
    max-height: 400px;
    overflow-y: auto;
    padding: 8px 10px;
    margin-top: 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.5;
    background: var(--bg-primary);
}

.read-content-body.expanded {
    display: block;
}

.screenshot-img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 2px;
}

.generated-img {
    max-width: 100%;
    border-radius: 4px;
    cursor: pointer;
}

/* Widget collapse toggle — used in tool-cell, code-cell, action-widget headers */
.widget-collapse-toggle {
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.widget-collapse-toggle:hover {
    opacity: 1;
}

.widget-collapse-toggle::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--bg-primary);
    transition: transform 0.2s;
}

.widget-collapse-toggle.collapsed::before {
    transform: rotate(-90deg);
}

/* Collapsed state for tool-cell, code-cell, action-widget */
.tool-cell.collapsed > :not(.tool-cell-label),
.code-cell.collapsed > :not(.code-cell-label),
.action-widget.collapsed > :not(.action-widget-clickable):not(.action-widget-header) {
    display: none;
}
