/* GraphTalker Web UI */

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

body {
    font-family: var(--font-sans);
    background-color: var(--color-background-default);
    color: var(--color-text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-size-adjust: 100%;
    font-weight: 400;
    letter-spacing: 0.01071em;
    font-size: 1rem;
    line-height: 1.4;
}

/* Top Header Bar */
.top-header {
    padding: 12px 20px;
    background-color: var(--color-background-paper);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.top-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo {
    height: 2.8rem;
    width: auto;
    display: block;
}

.app-version {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.06em;
    color: var(--color-text-disabled, rgba(0, 0, 0, 0.38));
}

/* Tab Bar */
.tab-bar {
    display: flex;
    gap: 0;
    background-color: var(--color-background-paper);
    border-bottom: 1px solid var(--border-default);
    padding: 0 20px;
    flex-shrink: 0;
}

.tab-btn {
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: 0.02857em;
    border: none;
    background: none;
    border-radius: 0;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
}

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

.tab-btn.active {
    font-weight: 500;
    color: var(--color-primary-main);
    border-bottom-color: var(--color-primary-main);
}

/* Tab Content */
.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: block;
}

.container {
    display: flex;
    height: 100%;
    gap: 1px;
    background-color: var(--border-default);
}

/* Left Panel - Chat style */
.left-panel {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    background-color: var(--color-background-default);
    min-width: 300px;
    overflow: hidden;
}

/* Right Panel - Iterations */
.right-panel {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    background-color: var(--panel-dark-bg);
    color: var(--panel-dark-text);
    min-width: 300px;
    overflow: hidden;
}

/* Panel Headers (inside left/right panels) */
.panel-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--panel-dark-border);
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--panel-dark-accent-info);
    letter-spacing: normal;
    text-transform: uppercase;
}

.panel-header h2#iterations-header {
    font-family: var(--font-mono);
}

/* Query List Header */
.query-list-header {
    padding: 12px 16px;
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-default);
    border-radius: 4px;
    font-size: 0.9rem;
}

.search-input:hover {
    outline: none;
    border: 1px solid var(--color-primary-main);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary-main);
    box-shadow: inset 0 0 0 0.5px var(--color-primary-main);
}

.search-input::placeholder {
    color: var(--color-grey-500);
}

/* Query List */
.query-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.query-card {
    background-color: var(--color-background-paper);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.query-card:hover {
    border-color: var(--color-primary-light);
    box-shadow: var(--shadow-accent);
    background-color: color-mix(in srgb, var(--color-info-main) 5%, white);
}

.query-card.selected {
    border-color: var(--color-primary-light);
    background-color: var(--info-surface);
}

.query-card-title {
    font-weight: 500;
    color: var(--color-grey-900);
    margin-bottom: 4px;
}

.query-card-description {
    font-size: 0.85rem;
    color: var(--color-grey-700);
    line-height: 1.4;
}

.query-card-meta {
    font-size: 0.75rem;
    color: var(--color-grey-700);
    margin-top: 8px;
}

/* Query Details Panel */
.query-details-panel {
    position: relative;
    background-color: var(--color-background-default);
    color: var(--color-text-primary);
}

.query-details-panel .panel-header {
    border-bottom: 1px solid var(--border-default);
}

.query-details-panel .panel-header h2 {
    color: var(--text-heading);
    text-transform: uppercase;
}

.query-details {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 18px;
    padding: 12px 16px;
    overflow-y: auto;
    background-color: var(--color-background-paper);
}

.query-detail-section {}

.query-detail-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
    letter-spacing: 0.15px;
    text-transform: uppercase;
}

.query-detail-section>p {
    font-size: 0.875rem;
    font-weight: 600;
}

/* URI Row with Copy Button */
.uri-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 8px 12px;
}

.uri-text {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-text-primary);
    word-break: break-all;
    background: none;
    padding: 0;
}

.copy-btn {
    flex-shrink: 0;
    padding: 6px;
    background-color: var(--border-subtle);
    border: 1px solid var(--border-soft);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.copy-btn:hover {
    background-color: var(--border-soft);
    border-color: var(--border-strong);
    color: var(--text-strong);
}

.copy-btn.copied {
    background-color: var(--success-surface);
    border-color: var(--success-border);
    color: var(--success-text);
}

.copy-btn svg {
    display: block;
}

/* Delete Button */
.delete-btn {
    flex-shrink: 0;
    padding: 6px;
    background-color: var(--error-surface-strong);
    border: 1px solid var(--error-border-strong);
    border-radius: 4px;
    cursor: pointer;
    color: var(--error-text-strong);
    transition: background-color 0.2s, border-color 0.2s;
}

.delete-btn:hover {
    background-color: var(--error-surface-hover);
    border-color: var(--error-border-hover);
    color: var(--error-text-strong);
}

.delete-btn svg {
    display: block;
}

.query-detail-section pre {
    background-color: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Query Description (Markdown) */
.query-description-section {}

.query-description-content {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--color-grey-900);
    font-family: var(--font-sans);
}

.query-description-content h1,
.query-description-content h2,
.query-description-content h3,
.query-description-content h4 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    color: var(--color-text-primary);
}

.query-description-content h1 {
    font-size: 1.3rem;
}

.query-description-content h2 {
    font-size: 1.15rem;
}

.query-description-content h3 {
    font-size: 1rem;
}

.query-description-content p {
    margin-bottom: 0.8em;
}

.query-description-content ul,
.query-description-content ol {
    margin-left: 1.5em;
    margin-bottom: 0.8em;
}

.query-description-content li {
    margin-bottom: 0.3em;
}

.query-description-content code {
    background-color: var(--surface-2);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

.query-description-content pre {
    background-color: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 1em 0;
}

.query-description-content pre code {
    background: none;
    padding: 0;
}

/* Visualization Grid */
.viz-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.viz-card {
    background-color: var(--color-grey-200);
    border: 1px solid var(--color-grey-400);
    border-radius: 6px;
    padding: 12px 12px 28px;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.viz-card::after {
    content: "Click to view visualizations";
    position: absolute;
    left: 12px;
    bottom: 5px;
    font-size: 0.875rem;
    color: var(--link-default);
    text-decoration: underline;
    pointer-events: none;
}

.viz-card:hover {
    border-color: var(--color-primary-light);
    box-shadow: var(--shadow-accent);
}

.viz-card-type {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-primary-main);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.viz-card-description {
    font-size: 0.85rem;
    color: var(--color-text-primary);
    line-height: 1.4;
    margin-top: 10px;
}

.viz-card-summary {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    margin-top: 10px;
    font-style: italic;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* Modal Overlay */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--overlay-bg);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background-color: var(--color-background-paper);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-modal);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    gap: 16px;
    border-bottom: 1px solid var(--border-default);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--color-text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px 12px;
    line-height: 1;
    font-weight: 400;
    text-overflow: inherit;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    background-color: var(--color-grey-100);
}

/* Visualization Summary Section */
.viz-summary-section {
    border-radius: 8px;
    line-height: 1.7;
}

.viz-summary-content {
    font-size: 0.95rem;
    color: var(--color-text-primary);
    font-family: var(--font-sans);
}

.viz-summary-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin: 16px 0 8px 0;
}

.viz-summary-content h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted-strong);
    margin: 12px 0 6px 0;
}

.viz-summary-content strong {
    color: var(--text-heading);
}

/* Markdown tables in summary */
.viz-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.85rem;
}

.viz-table th,
.viz-table td {
    border: 1px solid var(--border-soft);
    padding: 8px 12px;
    text-align: left;
}

.viz-table th {
    background-color: var(--border-subtle);
    font-weight: 600;
    color: var(--text-muted-strong);
}

.viz-table tr:nth-child(even) {
    background-color: var(--surface-1);
}

.viz-table tr:hover {
    background-color: var(--border-subtle);
}

/* Wider modal for visualizations */
.viz-modal-content {
    max-width: 900px;
}

.viz-info {
    background-color: var(--surface-1);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.85rem;
}

.viz-config {
    margin-bottom: 16px;
}

.viz-config h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.viz-config pre {
    background-color: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    max-height: 300px;
}

.viz-render {
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 20px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
}

.viz-render-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.viz-render-container canvas {
    max-width: 100%;
    height: auto;
}

/* Multi-chart dashboard layout */
.viz-render-container.multi-chart {
    max-width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

/* Table container - wider and scrollable */
.viz-render-container.table-container {
    max-width: 100%;
    overflow-x: auto;
}

/* Network graph container */
.viz-render-container.network-graph-container {
    max-width: 100%;
    padding: 10px;
}

.network-graph-svg {
    width: 100%;
    height: 500px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background-color: var(--surface-3);
}

.network-graph-svg svg {
    width: 100%;
    height: 100%;
}

/* Map container (Leaflet) */
.viz-render-container.map-container {
    max-width: 100%;
    padding: 0;
}

.leaflet-map {
    width: 100%;
    height: 500px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    z-index: 1;
}

/* Network graph node and edge styles */
.network-graph-svg .nodes circle {
    transition: r 0.2s ease;
}

.network-graph-svg .nodes circle:hover {
    r: 20;
    filter: brightness(1.1);
}

.network-graph-svg .labels text {
    font-family: var(--font-mono);
    fill: var(--color-text-primary);
    pointer-events: none;
}

.network-graph-svg .edge-labels text {
    font-family: var(--font-mono);
    pointer-events: none;
}

.network-graph-svg .legend text {
    font-family: var(--font-mono);
    fill: var(--color-text-primary);
}

.chart-wrapper {
    flex: 1 1 300px;
    min-width: 280px;
    max-width: 500px;
    background-color: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 16px;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 250px !important;
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 12px 0;
    text-align: center;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-separator {
    color: var(--border-contrast);
    font-size: 0.9rem;
}

.header-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s;
}

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

/* Context Bar */
.context-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.context-label {
    color: var(--color-grey-700);
    font-weight: 500;
}

.context-meter {
    width: 80px;
    height: 6px;
    background-color: var(--secondary-button-bg);
    border-radius: 3px;
    overflow: hidden;
}

.context-fill {
    height: 100%;
    background-color: var(--color-success-main);
    width: 0%;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.context-fill.warning {
    background-color: var(--color-warning-main);
}

.context-fill.danger {
    background-color: var(--color-error-main);
}

.context-pct {
    font-weight: 500;
    min-width: 35px;
    font-size: 0.85rem;
}

/* Repository Selector */
.repo-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.repo-label {
    color: var(--color-grey-700);
    font-weight: 500;
}

.repo-selector select {
    padding: 6px 12px;
    font-size: 0.85rem;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    background-color: var(--color-background-paper);
    color: var(--color-text-primary);
    cursor: pointer;
    min-width: 150px;
    max-width: 250px;
}

.repo-selector select:focus {
    outline: none;
    border-color: var(--color-primary-main);
}

.repo-selector select:hover {
    border-color: var(--border-muted);
}

.repo-selector select:disabled {
    background-color: var(--color-background-default);
    color: var(--text-subtle);
    cursor: not-allowed;
}

/* Status indicator */

kbd {
    display: inline-block;
    padding: 1px 5px;
    font-size: 0.7rem;
    font-family: var(--font-sans);
    line-height: 1.4;
    color: var(--color-text-secondary);
    background-color: var(--color-background-default);
    border: 1px solid var(--border-default);
    border-bottom-width: 2px;
    border-radius: 4px;
}

.status {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status.running {
    color: var(--color-success-main);
}

.status.running::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--color-success-main);
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Chat Area - Scrollable middle section */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.welcome-message {
    position: relative;
    background: color-mix(in srgb, var(--color-info-light) 20%, transparent);
    border: 1px solid var(--color-info-light);
    border-radius: 6px;
    padding: 12px 14px;
    color: var(--color-text-primary);
    line-height: 1.4;
}

.welcome-message .hint {
    margin-top: 12px;
}

/* Chat Messages */
.chat-message {
    max-width: 100%;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message.assistant {
    align-self: flex-start;
}

.message-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.user .message-label {
    text-align: right;
}

.message-content {
    padding: 16px;
    border-radius: 10px;
    font-weight: 400;
    letter-spacing: 0.01071em;
    line-height: 1.4;
}

.user .message-content {
    background-color: var(--color-primary-light);
    color: var(--text-inverse);
    border-top-right-radius: 3px;
}

.assistant .message-content {
    background-color: white;
    border: 1px solid var(--color-grey-200);
    color: var(--grey-900);
    border-top-left-radius: 3px;
    box-shadow: rgba(0, 0, 0, 0.05) 0px 1px 2px 0px;
}

/* Markdown in assistant messages */
.assistant .message-content pre {
    background-color: var(--color-background-paper);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Handle images in assistant messages - prevent broken/missing images from creating large empty spaces */
.assistant .message-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 8px 0;
}

.assistant .message-content img:not([src]),
.assistant .message-content img[src=""] {
    display: none;
}

/* Handle iframes and embedded content */
.assistant .message-content iframe {
    max-width: 100%;
    border: 1px solid var(--border-default);
    border-radius: 6px;
}

/* Hide empty code/pre blocks that may result from markdown parsing */
.assistant .message-content pre:empty,
.assistant .message-content code:empty {
    display: none;
}

/* Make tables in assistant messages responsive */
.assistant .message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.85rem;
    display: block;
    overflow-x: auto;
}

.assistant .message-content th,
.assistant .message-content td {
    border: 1px solid var(--border-default);
    padding: 8px 12px;
    text-align: left;
    min-width: 100px;
}

.assistant .message-content th {
    background-color: var(--surface-2);
    font-weight: 600;
}

/* Force single-column layout for content that might have side-by-side elements */
.assistant .message-content {
    display: block;
    overflow-x: auto;
}

.assistant .message-content>* {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Override any inline flex/grid layouts to stack vertically */
.assistant .message-content div,
.assistant .message-content section,
.assistant .message-content article {
    display: block !important;
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Reset any multi-column layouts */
.assistant .message-content * {
    column-count: unset !important;
    columns: unset !important;
}

/* Handle any inline content that might cause horizontal overflow */
.assistant .message-content img,
.assistant .message-content canvas,
.assistant .message-content svg {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 8px auto;
}

.assistant .message-content code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* ASCII art blocks - when not in pre/code, marked may wrap in p tags */
.assistant .message-content .ascii-art,
.assistant .message-content pre code {
    font-family: var(--font-mono) !important;
    white-space: pre;
    line-height: 1.2;
}

.assistant .message-content p code {
    background-color: var(--color-background-paper);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid var(--border-default);
}

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

.assistant .message-content p:first-child {
    margin-top: 0;
}

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

/* Lists in assistant messages need left padding for bullets/numbers */
.assistant .message-content ul,
.assistant .message-content ol {
    margin: 8px 0;
    padding-left: 28px;
}

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

/* Nested lists */
.assistant .message-content ul ul,
.assistant .message-content ol ol,
.assistant .message-content ul ol,
.assistant .message-content ol ul {
    margin: 4px 0;
    padding-left: 24px;
}

/* Error Message */
.chat-message.error .message-content {
    background-color: var(--error-surface);
    border: 1px solid var(--error-border);
    color: var(--error-text);
}

/* Input Area - Fixed at bottom */
.input-area {
    position: relative;
    padding: 20px 16px;
    border-top: 1px solid var(--border-default);
    background-color: var(--color-background-paper);
    flex-shrink: 0;
}

.input-row {
    position: relative;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-row textarea {
    flex: 1;
    padding: 12px;
    padding-right: 92px;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    height: 74px;
    min-height: 74px;
    max-height: 120px;
    border: 1px solid var(--color-primary-main);
    background-color: var(--color-grey-100);
    transition: box-shadow 0.2s;
}

.input-row textarea:hover {
    outline: none;
    border: 1px solid var(--color-primary-main);
}

.input-row textarea:focus {
    outline: none;
    border: 1px solid var(--color-primary-main);
    box-shadow: inset 0 0 0 0.5px var(--color-primary-main);
}

.input-row textarea::placeholder {
    color: var(--color-text-secondary);
}

.input-options {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-top: 8px;
}

/* Buttons */
button {
    padding: 6px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.75;
    font-family: var(--font-sans);
    letter-spacing: 0.02857em;
    border: none;
    box-sizing: border-box;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.btn-icon {
    letter-spacing: 0;
    font-family: Arial, sans-serif;
    font-size: 1.1em;
}

.primary-button {
    color: #ffffff;
    background-color: var(--color-primary-main);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 7px;
    box-shadow: rgba(0, 0, 0, 0.25) 0px 3px 6px;
    border: none;
}

.primary-button:hover {
    background-color: var(--color-primary-dark);
    box-shadow: rgba(0, 0, 0, 0.3) 0px 4px 8px;
}

.primary-button:disabled {
    background-color: var(--border-muted);
    cursor: not-allowed;
}

#send-btn {
    min-width: 80px;
    position: absolute;
    right: 14px;
    bottom: 10px;
}

/* Stop button - red, shown during query execution */
.stop-btn {
    position: absolute;
    right: 14px;
    bottom: 10px;
    min-width: 80px;
    color: #ffffff;
    background-color: var(--color-error-main);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 7px;
    box-shadow: rgba(0, 0, 0, 0.25) 0px 3px 6px;
    border: none;
}

.stop-btn:hover {
    background-color: var(--color-error-dark);
    box-shadow: rgba(0, 0, 0, 0.3) 0px 4px 8px;
}

button.secondary {
    min-width: 64px;
    background-color: transparent;
    color: var(--color-primary-main);
    border: 1px solid var(--color-primary-main);
}

button.secondary:hover {
    background-color: rgba(1, 23, 60, 0.04);
}

button.small {
    padding: 5px 15px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted-strong);
    cursor: pointer;
}

.checkbox-label input {
    cursor: pointer;
    accent-color: var(--color-primary-main);
}

.iterations-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted-strong);
    margin-left: 16px;
}

.iterations-label input[type="number"] {
    width: 60px;
    padding: 4px 6px;
    border: 1px solid var(--border-default);
    background-color: var(--color-background-default);
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
}

.iterations-label input[type="number"]:focus {
    outline: none;
    border-color: var(--color-primary-main);
}

/* Iterations Panel */
.iterations-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.placeholder {
    color: var(--color-text-secondary);
    font-family: inherit;
    white-space: normal;
    font-weight: 400;
}

/* Iteration blocks */
.iteration-block {
    margin-bottom: 16px;
    border-left: 3px solid var(--panel-dark-accent);
    padding-left: 12px;
}

.iteration-header {
    color: var(--panel-dark-accent);
    font-weight: bold;
    margin-bottom: 8px;
}

.tool-call {
    color: var(--panel-dark-accent-warning);
}

.tool-input {
    color: var(--panel-dark-accent-info);
}

.tool-result {
    color: var(--panel-dark-text);
    max-height: 300px;
    overflow-y: auto;
    background-color: var(--panel-dark-surface);
    padding: 8px;
    border-radius: 4px;
    margin: 4px 0;
}

.stop-reason {
    color: var(--panel-dark-accent-purple);
}

.final-answer-marker {
    color: var(--color-success-main);
    font-weight: bold;
    margin-top: 16px;
    padding-top: 8px;
    border-top: 1px solid var(--panel-dark-border-strong);
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Scrollbar styling */
.chat-area::-webkit-scrollbar,
.iterations-content::-webkit-scrollbar {
    width: 8px;
}

.chat-area::-webkit-scrollbar-track {
    background: var(--surface-2);
}

.chat-area::-webkit-scrollbar-thumb {
    background: var(--border-contrast);
    border-radius: 4px;
}

.chat-area::-webkit-scrollbar-thumb:hover {
    background: var(--border-muted);
}

.iterations-content::-webkit-scrollbar-track {
    background: var(--panel-dark-bg);
}

.iterations-content::-webkit-scrollbar-thumb {
    background: var(--panel-dark-border-strong);
    border-radius: 4px;
}

.iterations-content::-webkit-scrollbar-thumb:hover {
    background: var(--panel-dark-scrollbar);
}

/* Responsive */
@media (max-width: 900px) {
    .container {
        flex-direction: column;
    }

    .left-panel,
    .right-panel {
        max-width: 100%;
        min-width: 100%;
        height: 50vh;
    }
}

/* ==================== Session Storage Styles ==================== */

/* Session Preview in Details Panel */
.session-preview {
    margin-bottom: 74px;
    padding: 12px 8px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background-color: var(--surface-1);
}

.session-message {
    margin-bottom: 16px;
    border-radius: 8px;
    word-wrap: break-word;
}

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

.session-message.user {
    margin-left: 20%;
}

.session-message.assistant {
    margin-right: 10%;
}

.session-message .message-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.session-message.user .message-label {}

.session-message.assistant .message-label {}

.session-message .message-content {
    line-height: 1.4;
}

/* Markdown content in session preview */
.session-message .message-content h1,
.session-message .message-content h2,
.session-message .message-content h3 {
    margin-top: 16px;
    margin-bottom: 8px;
}

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

.session-message .message-content ul,
.session-message .message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.session-message .message-content pre {
    background-color: var(--panel-dark-bg);
    color: var(--panel-dark-text);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.session-message .message-content code {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.session-message .message-content hr {
    border-color: var(--color-grey-300);
}


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

.session-message .message-content p:first-child {
    margin-top: 0;
}

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

/* Session Action Buttons */
.session-actions {
    position: absolute;
    bottom: 0;
    right: 16px;
    left: 16px;
    padding: 0 0 16px;
    background-color: var(--color-background-paper);
    display: flex;
    gap: 12px;
}

.session-actions button {
    flex: 1;
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 0.875rem;
    line-height: 1.75;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.session-actions button.primary {
    border: none;
    color: var(--text-inverse);
    background-color: var(--color-primary-main);
    box-shadow: rgba(0, 0, 0, 0.2) 0px 3px 1px -2px, rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px;
}

.session-actions button.primary:hover {
    background: var(--color-primary-dark);
    box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 4px -1px, rgba(0, 0, 0, 0.14) 0px 4px 5px 0px, rgba(0, 0, 0, 0.12) 0px 1px 10px 0px;
}

.session-actions button.danger {
    background: var(--color-background-paper);
    color: var(--danger-main);
    border: 1px solid var(--danger-main);
}

.session-actions button.danger:hover {
    background: var(--danger-main);
    color: var(--text-inverse);
}

/* ==================== Collapsible Visualization Code Widget ==================== */

details.viz-code-collapsed {
    margin: 12px 0;
    border: 1px solid var(--secondary-button-bg);
    border-radius: 6px;
    background: var(--surface-1);
    overflow: hidden;
}

details.viz-code-collapsed summary {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.9em;
    color: var(--color-text-secondary);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

details.viz-code-collapsed summary::-webkit-details-marker {
    display: none;
}

details.viz-code-collapsed summary::before {
    content: '▶';
    font-size: 0.7em;
    transition: transform 0.2s ease;
}

details.viz-code-collapsed[open] summary::before {
    transform: rotate(90deg);
}

details.viz-code-collapsed summary:hover {
    background: var(--surface-2);
}

details.viz-code-collapsed[open] summary {
    border-bottom: 1px solid var(--secondary-button-bg);
}

details.viz-code-collapsed pre {
    margin: 0;
    border-radius: 0;
    max-height: 400px;
    overflow: auto;
}

details.viz-code-collapsed pre code {
    font-size: 0.85em;
}