/* Council - Multi-Model AI Decision Support
   A modern, clean design inspired by professional decision tools */

/* ============================================
   CSS Variables & Theme
   ============================================ */
:root {
    /* Colors - Light theme */
    --bg-primary: #f7f7f9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f2f5;
    --bg-card: #ffffff;
    
    --text-primary: #1f2933;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-error: #ef4444;
    
    --border-color: #d9dce3;
    --border-light: #e5e7eb;
    
    /* Typography */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Spacing */
    --sidebar-width: 320px;
    --content-max-width: 1100px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

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

html {
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================
   Layout
   ============================================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.logo.text-logo {
    flex-direction: column;
    gap: 0.25rem;
}

.brand-name {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    line-height: 1;
}

.brand-tagline {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.logo img {
    width: 230px;
    height: auto;
    display: block;
}

.logo-image {
    width: 100%;
    max-width: 260px;
    height: auto;
    display: block;
}

.new-project-btn {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--accent-primary);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    transition: background var(--transition-fast);
}

.new-project-btn:hover {
    background: var(--accent-secondary);
}

/* Project List */
.project-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.project-list-header {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.project-item {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-primary);
    border-radius: 8px;
    margin-bottom: 0.125rem;
    transition: background var(--transition-fast);
}

.project-item:hover {
    background: var(--bg-tertiary);
}

.project-item.active {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent-primary);
}

.project-item-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.project-item-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tier-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tier-light { background: #374151; color: #9ca3af; }
.tier-medium { background: #4338ca; color: #c7d2fe; }
.tier-ultra { background: #7c2d12; color: #fed7aa; }

.empty-state {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.version {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 2rem;
}

/* ============================================
   New Project Page
   ============================================ */
.new-project-page {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

/* Context banner for follow-ups */
.context-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--accent-secondary);
}

.context-icon {
    font-size: 1rem;
}

.context-link {
    margin-left: auto;
    color: var(--accent-primary);
    text-decoration: none;
}

.context-link:hover {
    text-decoration: underline;
}

.draft-notice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 8px;
    font-size: 0.875rem;
    color: #22c55e;
}

.draft-icon {
    font-size: 1rem;
}

.clear-draft-btn {
    margin-left: auto;
    background: transparent;
    border: 1px solid rgba(34, 197, 94, 0.5);
    color: #22c55e;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.clear-draft-btn:hover {
    background: rgba(34, 197, 94, 0.2);
}

/* File Upload Section */
.file-upload-section {
    margin-top: 0.25rem;
}

.file-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--accent-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #ffffff !important;
    transition: all var(--transition-fast);
}

.file-upload-label * {
    color: #ffffff !important;
}

.file-upload-label:hover {
    background: var(--accent-secondary);
}

/* Drag and drop state */
.file-upload-section.drag-over {
    background: rgba(99, 102, 241, 0.1);
    border: 2px dashed var(--accent-primary);
    border-radius: 8px;
    padding: 0.5rem;
}

.file-upload-section.drag-over .file-upload-label {
    background: transparent;
    border-color: transparent;
}

.file-upload-icon {
    font-size: 1rem;
}

.file-upload-hint {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
}

.file-upload-formats {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

.attached-files-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.attached-file {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 6px;
    font-size: 0.8rem;
}

.attached-file-icon {
    font-size: 1.1rem;
}

.attached-file-name {
    color: var(--text-primary);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.attached-file-size {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* Image thumbnails in file chips */
.attached-image {
    padding: 0.25rem 0.5rem;
}

.attached-image-thumb {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.remove-file-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}

.remove-file-btn:hover {
    color: var(--error);
}

/* [MVP] Context Budget Progress Bar */
.context-budget {
    margin-top: 0.75rem;
    padding: 0.5rem 0;
}

.context-budget-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.context-budget-label span:first-child {
    font-weight: 500;
}

.context-budget-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.context-budget-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 3px;
    transition: width 0.3s ease, background 0.3s ease;
}

.context-budget-fill.warning {
    background: var(--warning, #f59e0b);
}

.context-budget-fill.danger {
    background: var(--error, #ef4444);
}

/* Form Styles */
.project-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--text-secondary);
}


.analysis-mode-selector {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--accent-primary);
    border-radius: 6px;
    padding: 2px;
}

.mode-option {
    cursor: pointer;
    display: flex;
    align-items: center;
}

.mode-option input {
    display: none;
}

.mode-option span {
    padding: 0.1rem 1rem;
    font-size: 1.125rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.mode-option input:checked + span {
    background: white;
    color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.mode-option:hover span {
    color: white;
}

.mode-option input:checked + span:hover {
    color: var(--accent-primary);
}

textarea {
    width: 100%;
    padding: 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    min-height: 72px;
    transition: border-color var(--transition-fast);
}

textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

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

/* Tier Selector */
.tier-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.tier-option {
    cursor: pointer;
}

.tier-option input {
    display: none;
}

.tier-option {
    flex: 1;
    min-width: 140px;
    max-width: 180px;
}

.tier-card {
    padding: 1rem;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    transition: all var(--transition-fast);
    text-align: center;
    height: 100%;
}

.tier-option:hover .tier-card {
    border-color: var(--border-light);
}

.tier-option.selected .tier-card {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

.tier-name {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.tier-description {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.tier-price {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-success);
}

.tier-tag {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-left: 0.5rem;
    vertical-align: middle;
}

.tier-tag.recommended {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-primary);
}

.tier-option.single-model .tier-card {
    border-style: dashed;
}

/* Advanced Options */
.advanced-options {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.advanced-options summary {
    padding: 1rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    list-style: none;
}

.advanced-options summary::-webkit-details-marker {
    display: none;
}

.advanced-options summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform var(--transition-fast);
}

.advanced-options[open] summary::before {
    transform: rotate(90deg);
}

.advanced-content {
    padding: 0 1rem 1rem;
}

.form-row {
    margin-bottom: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.125rem;
    accent-color: var(--accent-primary);
}

.checkbox-label span {
    display: block;
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Buttons */
.form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-secondary);
}

.btn-primary:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-icon {
    font-size: 1.25em;
}

/* ============================================
   Project Page
   ============================================ */
.project-page {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.project-header {
    margin-bottom: 1.5rem;
}

.project-title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.project-name {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    outline: none;
    border-bottom: 2px solid transparent;
    transition: border-color var(--transition-fast);
}

.project-name:focus {
    border-bottom-color: var(--accent-primary);
}

.project-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.project-status {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-weight: 500;
    text-transform: capitalize;
}

.status-complete { background: rgba(16, 185, 129, 0.2); color: var(--accent-success); }
.status-failed { background: rgba(239, 68, 68, 0.2); color: var(--accent-error); }
.status-cancelled { background: rgba(107, 114, 128, 0.2); color: var(--text-muted); }

/* Progress Stepper */
.progress-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 100px;
}

.stage-indicator {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition-normal);
}

.stage-complete .stage-indicator {
    background: var(--accent-success);
    color: white;
}

.stage-in_progress .stage-indicator {
    background: var(--accent-primary);
    color: white;
}

.stage-pending .stage-indicator {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.stage-skipped .stage-indicator {
    background: transparent;
    border: 2px dashed var(--border-color);
    color: var(--text-muted);
}

.stage-skipped .stage-name {
    color: var(--text-muted);
    text-decoration: line-through;
    opacity: 0.6;
}

.stage-skipped {
    opacity: 0.5;
}

.skip-icon {
    font-weight: bold;
    font-size: 1.2rem;
}

.connector-skipped {
    opacity: 0.3;
    border-style: dashed;
}

.stage-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.stage-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
}

.stage-complete .stage-name { color: var(--accent-success); }
.stage-in_progress .stage-name { color: var(--accent-primary); }

/* Progress bar under each stage */
.stage-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 6px;
}

.stage-pending .stage-progress-bar {
    opacity: 0.3;
}

.stage-complete .stage-progress-bar {
    opacity: 1;
}

.stage-in_progress .stage-progress-bar {
    opacity: 1;
}

.stage-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    transition: width 0.3s linear;
}

.stage-complete .stage-progress-fill {
    width: 100%;
    background: var(--accent-success);
}

/* Timing display */
.stage-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    height: 1rem;
}

.stage-pending .stage-time {
    visibility: hidden;
}

.stage-connector {
    width: 3rem;
    height: 2px;
    background: var(--border-color);
    margin: 0 0.25rem;
    margin-bottom: 2.5rem;  /* Account for progress bar height */
}

.check { font-weight: bold; }

.dot {
    width: 8px;
    height: 8px;
    background: currentColor;
    border-radius: 50%;
}

.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Global Progress Bar */
.global-progress {
    margin: 1rem 0 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.global-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.global-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-success));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.global-progress-info {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.global-progress-text {
    color: var(--text-secondary);
}

.global-progress-eta {
    color: var(--accent-primary);
    font-weight: 500;
    font-family: var(--font-mono);
}

.btn-cancel {
    background: transparent;
    border: 1px solid var(--accent-error);
    color: var(--accent-error);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel:hover {
    background: var(--accent-error);
    color: white;
}

/* Resume button - matches cancel style with accent color */
.btn-resume {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-resume:hover {
    background: var(--accent);
    color: white;
}

/* Action buttons container in progress stepper */
.stepper-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
    align-self: center;
    margin-bottom: 2rem;  /* Align with stage names */
}

.stepper-action-btn {
    /* Shared sizing for cancel/resume in stepper */
}

/* Clarifying Questions Form */
.clarifying-questions-form {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border: 1px solid var(--border-color);
}

.questions-header h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.questions-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.question-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.question-item:last-of-type {
    border-bottom: none;
}

.question-rank {
    background: var(--accent-primary);
    color: white;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    flex-shrink: 0;
}

.question-content {
    flex: 1;
}

.question-content label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.question-rationale {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    font-style: italic;
}

.question-content textarea {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
}

.question-content textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.questions-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Warnings Banner */
.warnings-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    margin-bottom: 1rem;
    color: var(--accent-warning);
}

.warning-expand {
    margin-left: auto;
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 4px;
    color: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}

.warnings-detail {
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.warnings-detail.hidden {
    display: none;
}

/* Memo Card */
.memo-section {
    margin-bottom: 2rem;
}

.memo-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid var(--border-color);
}

.memo-card.memo-pending {
    text-align: center;
    color: var(--text-muted);
    padding: 4rem 2rem;
}

.memo-bottom-line {
    margin-bottom: 1rem;
}

.memo-bottom-line h2 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.memo-bottom-line p,
.bottom-line-content {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.5;
}

/* Override markdown-body padding for bottom line content */
.bottom-line-content.markdown-body {
    padding: 0 !important;
    font-size: 1.25rem !important;
    font-weight: 500 !important;
    line-height: 1.5 !important;
}

.bottom-line-content.markdown-body p {
    font-size: 1.25rem !important;
    font-weight: 500 !important;
    line-height: 1.5 !important;
    margin: 0 !important;
}

.memo-confidence {
    padding: 0.5rem 0.75rem 0.25rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.confidence-high { background: rgba(16, 185, 129, 0.15); }
.confidence-med { background: rgba(245, 158, 11, 0.15); }
.confidence-low { background: rgba(239, 68, 68, 0.15); }

.confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.confidence-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.confidence-value {
    font-weight: 700;
}

.confidence-high .confidence-value { color: var(--accent-success); }
.confidence-med .confidence-value { color: var(--accent-warning); }
.confidence-low .confidence-value { color: var(--accent-error); }

.confidence-rationale {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    line-height: 1.4;
}

/* Override markdown-body defaults for confidence rationale */
.confidence-rationale.markdown-body {
    padding: 0;
    line-height: 1.4;
}

.confidence-rationale p,
.confidence-rationale.markdown-body p {
    margin: 0 !important;
    margin-bottom: 0 !important;
}

/* Structural fix for checkbox lines - each paragraph with checkbox becomes flex container */
.confidence-rationale p:has(.checkbox),
.confidence-rationale.markdown-body p:has(.checkbox) {
    display: flex !important;
    align-items: flex-start !important;
    margin-bottom: 0.04rem !important;
    line-height: 1.4 !important;
}

/* Remove space after last paragraph in confidence rationale */
.confidence-rationale p:last-child,
.confidence-rationale.markdown-body p:last-child {
    margin-bottom: 0 !important;
}

/* Checkbox styling for confidence rationale checklists */
.checkbox {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2em;
    height: 1.2em;
    border-radius: 3px;
    margin-right: 0.6rem;
    font-weight: bold;
    font-size: 0.85em;
    flex-shrink: 0;
    margin-top: 0.15em;
}

.checkbox.checked {
    background: var(--accent-success);
    color: white;
}

.checkbox.unchecked {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}

/* Ensure KaTeX elements don't inherit bold styling */
.katex {
    font-weight: normal !important;
}

.memo-section-inner {
    margin-bottom: 1rem;
}

.memo-section-inner h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.memo-list {
    padding-left: 1.25rem;
}

.memo-list li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.memo-list.numbered {
    list-style-type: decimal;
}

.memo-notes {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Next Steps (Checklist Style) */
.next-steps-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.next-steps-checklist {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.checklist-item:hover {
    background: rgba(99, 102, 241, 0.08);
}

.checklist-item:has(input:checked) {
    background: rgba(99, 102, 241, 0.12);
}

.checklist-item input[type="checkbox"] {
    display: none;
}

.checklist-checkbox {
    flex-shrink: 0;
    width: 1.125rem;
    height: 1.125rem;
    margin-top: 0.125rem;
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    border-radius: 4px;
    transition: all var(--transition-fast);
    position: relative;
}

.checklist-item:hover .checklist-checkbox {
    border-color: var(--accent-primary);
}

.checklist-item:has(input:checked) .checklist-checkbox {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.checklist-item:has(input:checked) .checklist-checkbox::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}

.checklist-text {
    color: var(--text-secondary);
    line-height: 1.4;
    font-size: 0.9rem;
}

.checklist-item:has(input:checked) .checklist-text {
    color: var(--text-primary);
}

/* Execute area (horizontal layout) */
.next-steps-execute-area {
    margin-top: 0.75rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.execute-row {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.execute-prompt-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.execute-prompt-group label,
.execute-tier-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.execute-prompt-group textarea {
    padding: 0.625rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    resize: none;
    min-height: 44px;
}

.execute-prompt-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.execute-prompt-group textarea::placeholder {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.execute-tier-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.execute-tier-group select {
    padding: 0.625rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    min-width: 100px;
}

.execute-tier-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.execute-row .btn {
    padding: 0.625rem 1.25rem;
    min-height: 44px;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--border-light);
}

@media (max-width: 600px) {
    .execute-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .execute-tier-group select {
        width: 100%;
    }
    
    .execute-row .btn {
        width: 100%;
    }
}

/* Warnings section styling */
.warnings-section summary {
    color: var(--accent-warning);
}

/* Per-Analysis Cost Bar (permanent, non-collapsible, styled like expand-section summary) */
.analysis-cost-bar {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 0.75rem;
}

/* Run Statistics Section (legacy/cumulative) */
.cumulative-label {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.75rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.stats-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
}

.stats-table th,
.stats-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.stats-table th {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 500;
}

.cost-cell {
    font-family: var(--font-mono);
    color: var(--accent-success);
}

.warnings-summary-text {
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.warnings-list {
    padding-left: 1.25rem;
    color: var(--text-muted);
}

.warnings-list li {
    margin-bottom: 0.5rem;
}

/* Artifact (Code/Data) */
.artifact-container {
    position: relative;
}

.artifact-lang {
    font-size: 0.7rem;
    padding: 0.125rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    margin-left: 0.5rem;
    font-weight: 500;
    text-transform: uppercase;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.copy-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.artifact-content {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0;
}

.artifact-content code {
    color: var(--text-secondary);
}

/* Detailed Analysis Section */
.detailed-analysis-section {
    margin-top: 1.5rem;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.detailed-analysis-section summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    cursor: pointer;
    list-style: none;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.detailed-analysis-section summary::-webkit-details-marker {
    display: none;
}

.detailed-analysis-section summary h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.expand-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.detailed-analysis-section:not([open]) .expand-hint {
    display: none;
}

.detailed-analysis-section:not([open]) summary::after {
    content: "Click to expand";
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Markdown Body Styling */
.markdown-body {
    padding: 1.5rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.markdown-body h1 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-primary);
}

.markdown-body h1:first-child {
    margin-top: 0;
}

.markdown-body h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.markdown-body h2:first-child {
    margin-top: 0;
}

.markdown-body h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 1.25rem 0 0.5rem;
}

.markdown-body h4 {
    font-size: 1rem;
    color: var(--text-primary);
    margin: 1rem 0 0.5rem;
}

.markdown-body p {
    margin-bottom: 1rem;
}

.markdown-body ul,
.markdown-body ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

.markdown-body strong {
    color: var(--text-primary);
    font-weight: 600;
}

.markdown-body em {
    font-style: italic;
}

.markdown-body blockquote {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--accent-primary);
    background: var(--bg-tertiary);
    border-radius: 0 8px 8px 0;
}

.markdown-body blockquote p {
    margin: 0;
}

.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--bg-tertiary);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    color: var(--accent-secondary);
}

.markdown-body pre {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    overflow-x: auto;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.markdown-body table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.markdown-body th {
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.markdown-body a {
    color: var(--accent-primary);
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body hr {
    margin: 1.5rem 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

/* Legacy detailed-analysis-content for backwards compat */
.detailed-analysis-content {
    padding: 1.5rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.detailed-analysis-content h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.detailed-analysis-content h2:first-child {
    margin-top: 0;
}

.detailed-analysis-content h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin: 1.25rem 0 0.5rem;
}

.detailed-analysis-content p {
    margin-bottom: 1rem;
}

.detailed-analysis-content ul,
.detailed-analysis-content ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.detailed-analysis-content li {
    margin-bottom: 0.5rem;
}

/* Expandable Sections */
.expandable-sections {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.expand-section {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.expand-section summary {
    padding: 1rem 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    list-style: none;
    transition: background var(--transition-fast);
}

.expand-section summary::-webkit-details-marker {
    display: none;
}

.expand-section summary:hover {
    background: var(--bg-tertiary);
}

.expand-section summary::after {
    content: '▶';
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.expand-section[open] summary::after {
    transform: rotate(90deg);
}

.section-icon {
    font-size: 1.125rem;
}

.badge {
    padding: 0.125rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.stage-model-badge {
    margin-left: auto;
    padding: 0.2rem 0.6rem;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--accent-secondary);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-warning);
}

.section-content {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.prompt-text {
    white-space: pre-wrap;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Q&A Items */
.qa-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.question {
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
}

.q-rank {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    line-height: 1.5rem;
    text-align: center;
    background: var(--accent-primary);
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.75rem;
}

.q-label {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 8px;
}

.q-label-critical {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.q-label-strategic {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.q-label-operational {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.answer {
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.answer.unanswered {
    font-style: italic;
    color: var(--text-muted);
}

.rationale {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Case File */
.case-file-content {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    white-space: pre-wrap;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
}

/* Council Tabs */
.council-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    background: var(--bg-tertiary);
}

.tab-btn.active {
    background: var(--accent-primary);
    color: white;
}

.tab-panel {
    display: none;
}

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

.answer-content {
    white-space: pre-wrap;
    line-height: 1.7;
    color: var(--text-secondary);
}

.expert-extra-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.expert-extra-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.sources-list {
    font-size: 0.9rem;
}

.source-link {
    color: var(--accent-primary);
    text-decoration: none;
}

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

.source-claim {
    color: var(--text-muted);
    font-style: italic;
}

/* Disagreement */
.disagreement-status,
.disagreement-confidence {
    margin-bottom: 0.75rem;
}

.disagreement-reasons ul {
    padding-left: 1.25rem;
    margin-top: 0.5rem;
}

/* Critiques */
.critique-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.critique-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.critique-model {
    font-weight: 600;
    color: var(--accent-primary);
}

.most-defensible {
    font-size: 0.8rem;
    color: var(--accent-success);
}

.critique-content {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Debug Section */
.debug-section {
    opacity: 0.7;
}

.debug-section summary {
    font-size: 0.875rem;
}

.model-map-table {
    width: 100%;
    border-collapse: collapse;
}

.model-map-table th,
.model-map-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.model-map-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.model-map-table code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-secondary);
}

/* Model Reference Section */
.model-reference-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.section-subtitle {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.section-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 1rem 0;
    line-height: 1.5;
}

/* Synthesizer Section */
.synthesizer-content {
    padding: 0;
}

.synthesizer-summary {
    color: var(--text-secondary);
    line-height: 1.7;
}

.synthesizer-summary h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    color: var(--text-primary);
}

.synthesizer-summary ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

.synthesizer-summary li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.synthesizer-summary li:last-child {
    border-bottom: none;
}

.synthesizer-summary strong {
    color: var(--text-primary);
    margin-right: 0.5rem;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
    
    .progress-stepper {
        padding: 1rem;
    }
    
    .stage {
        min-width: 60px;
    }
    
    .stage-connector {
        width: 1.5rem;
    }
    
    .tier-selector {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Utilities
   ============================================ */
/* ============================================
   Configuration Page
   ============================================ */
.config-page {
    max-width: 1200px;
    margin: 0 auto;
}

.config-header-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.config-select,
.config-input {
    padding: 0.625rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    min-width: 160px;
}

.config-select:focus,
.config-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.config-input {
    width: 100px;
}

/* Config Table */
.config-table-wrapper {
    overflow-x: auto;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.config-table {
    width: 100%;
    border-collapse: collapse;
}

.config-table th {
    padding: 1rem 0.75rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.config-table th.stage-col {
    min-width: 140px;
}

.config-table th.slot-col {
    min-width: 140px;
}

.config-table th.param-col {
    min-width: 100px;
}

.config-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.stage-row.disabled {
    opacity: 0.5;
}

.stage-row.skipped {
    opacity: 0.4;
    background: var(--bg-tertiary);
}

.stage-row.toggled-off .slot-cell,
.stage-row.toggled-off .param-cell {
    opacity: 0.5;
}

.stage-skipped-badge {
    font-size: 0.6rem;
    padding: 0.125rem 0.5rem;
    background: rgba(107, 114, 128, 0.3);
    border-radius: 4px;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.stage-required-badge {
    font-size: 0.6rem;
    padding: 0.125rem 0.375rem;
    background: rgba(99, 102, 241, 0.2);
    border-radius: 4px;
    color: var(--accent-secondary);
    margin-left: 0.25rem;
}

.option-combo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.option-combo .toggle-label {
    margin-right: 0.25rem;
}

.option-combo .option-label {
    margin-left: 0.25rem;
}

.stage-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stage-icon {
    font-size: 1.25rem;
}

.stage-label {
    font-weight: 500;
    color: var(--text-primary);
}

.stage-disabled-badge {
    font-size: 0.65rem;
    padding: 0.125rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.slot-cell {
    min-width: 130px;
}

.slot-na {
    color: var(--text-muted);
    font-style: italic;
}

.slot-provider,
.slot-model {
    margin-bottom: 0.375rem;
}

.slot-provider-select,
.slot-model-select {
    width: 100%;
    padding: 0.375rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8rem;
}

.slot-provider-select:focus,
.slot-model-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.slot-model-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.param-cell {
    min-width: 90px;
}

.param-input {
    width: 80px;
    padding: 0.375rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.param-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Config Actions */
.config-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Options Cell */
.options-cell {
    min-width: 100px;
}

.option-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.option-input {
    width: 60px;
    padding: 0.375rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.option-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.toggle-input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent-primary);
}

.stage-hidden-badge {
    font-size: 0.6rem;
    padding: 0.125rem 0.375rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

/* Future Capabilities Section */
.future-capabilities {
    margin-top: 1.5rem;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.future-capabilities summary {
    padding: 1rem 1.5rem;
    cursor: pointer;
    list-style: none;
    font-weight: 500;
    color: var(--text-secondary);
}

.future-capabilities summary::-webkit-details-marker {
    display: none;
}

.future-capabilities summary::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.75rem;
    font-size: 0.75rem;
    transition: transform var(--transition-fast);
}

.future-capabilities[open] summary::before {
    transform: rotate(90deg);
}

.future-content {
    padding: 0 1.5rem 1.5rem;
    display: grid;
    gap: 1rem;
}

.future-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    opacity: 0.7;
}

.future-icon {
    font-size: 1.5rem;
}

.future-info strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.future-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

/* Config Status */
.config-status {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-weight: 500;
}

.config-status.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.config-status.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Config Link in Sidebar */
.config-link {
    display: block;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}

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

/* ============================================
   Utilities
   ============================================ */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ============================================
   Debug Section
   ============================================ */
.debug-section {
    border-color: #4a5568;
    background: rgba(74, 85, 104, 0.1);
}

.debug-section summary {
    color: #718096;
}

.debug-stage {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.debug-stage:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.debug-stage-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.debug-model-badge {
    font-size: 0.75rem;
    font-weight: 400;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--text-muted);
}

.debug-prompt-section {
    margin-bottom: 1rem;
}

.debug-prompt-section strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.debug-prompt-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    font-size: 0.8rem;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
    color: var(--text-secondary);
}

.debug-response {
    background: rgba(99, 102, 241, 0.05);
    border-color: rgba(99, 102, 241, 0.3);
}

.debug-models-list {
    margin: 0;
    padding-left: 1.5rem;
}

.debug-models-list li {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

/* Previous Analysis - collapsible wrapper */
.previous-analysis-wrapper {
    margin-bottom: 1rem;
}

.previous-analysis-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-secondary);
}

.previous-analysis-header:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.previous-analysis-wrapper[open] .previous-analysis-header {
    border-radius: 8px 8px 0 0;
    border-bottom: none;
}

.previous-analysis-wrapper[open] .memo-section {
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
}

.current-analysis-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 8px 8px 0 0;
    margin-bottom: -8px;
}

.label-icon {
    font-size: 1rem;
}

/* ============================================
   Follow-up Controls (Project Page)
   ============================================ */
.next-steps-section {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1rem;
}

.followup-prompt-area {
    margin: 1rem 0;
}

.followup-prompt-area label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.followup-prompt-area textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    resize: vertical;
    min-height: 60px;
    font-family: var(--font-sans);
}

.followup-prompt-area textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.fine-print {
    margin-top: 0.1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.followup-controls-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group label:not(.toggle-label) {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.tier-control select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.questions-control {
    flex: 1;
}

.questions-control .toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.questions-control .toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

.questions-control .toggle-text {
    white-space: nowrap;
}

.btn-run {
    padding: 0.6rem 1.5rem;
    font-size: 0.95rem;
}

/* ============================================
   Code Execution - Collapsible Boxes
   ============================================ */
.code-execution-details {
    margin: 1rem 0;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-success);
    border-radius: 8px;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.code-execution-details.error {
    border-left-color: var(--accent-error);
}

.code-execution-details summary {
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    list-style: none;
}

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

.code-execution-details summary::before {
    content: "▶ ";
    color: var(--accent-primary);
    transition: transform var(--transition-fast);
    display: inline-block;
}

.code-execution-details[open] summary::before {
    content: "▼ ";
}

.code-execution-details summary:hover {
    background: var(--bg-tertiary);
}

.code-execution-details .code-content {
    padding: 0.75rem 1rem;
}

.code-execution-details pre {
    margin: 0.5rem 0;
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow-x: auto;
}

.code-execution-details code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.code-execution-details .code-output,
.code-execution-details .code-error {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.code-execution-details .code-output strong {
    color: var(--accent-success);
}

.code-execution-details .code-error strong {
    color: var(--accent-error);
}

/* Code execution images (matplotlib plots, etc.) */
/* Visible images section - plots shown directly, not collapsed */
.code-images-visible {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.code-images-visible .code-image {
    text-align: center;
    margin: 0.5rem 0;
}

.code-images-visible .code-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: white;  /* Plots often have white background */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Legacy: images inside collapsed details (keeping for backwards compat) */
.code-execution-details .code-images {
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.code-execution-details .code-image {
    text-align: center;
    margin: 0.5rem 0;
}

.code-execution-details .code-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: white;  /* Plots often have white background */
}

/* Collapsible code blocks (markdown ```code```) */
.code-block-details {
    margin: 1rem 0;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-secondary);
    border-radius: 8px;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.code-block-details summary {
    padding: 0.5rem 1rem;
    cursor: pointer;
    user-select: none;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    list-style: none;
}

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

.code-block-details summary::before {
    content: "▶ ";
    color: var(--accent-secondary);
    display: inline-block;
}

.code-block-details[open] summary::before {
    content: "▼ ";
}

.code-block-details summary:hover {
    background: var(--bg-tertiary);
}

.code-block-details pre {
    margin: 0;
    padding: 1rem;
    background: var(--bg-primary);
    overflow-x: auto;
}

.code-block-details code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

/* Artifact section (Final Verified Code) */
.artifact-section {
    border: 2px solid var(--accent-success);
    border-radius: 8px;
    padding: 0 !important;
    overflow: hidden;
}

.artifact-section h3 {
    background: linear-gradient(135deg, var(--accent-success), #059669);
    color: white;
    padding: 0.75rem 1rem;
    margin: 0;
    font-size: 1rem;
}

.artifact-details {
    margin: 0;
    border: none;
    border-radius: 0;
}

.artifact-details summary {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    list-style: none;
}

.artifact-details summary::-webkit-details-marker {
    display: none;
}

.artifact-details summary::before {
    content: "▶ ";
    color: var(--accent-success);
}

.artifact-details[open] summary::before {
    content: "▼ ";
}

.artifact-details .artifact-lang {
    background: var(--accent-primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.artifact-details .artifact-lines {
    color: var(--text-muted);
}

.artifact-details .copy-btn {
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.artifact-details .copy-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.artifact-details pre {
    margin: 0;
    padding: 1rem;
    background: var(--bg-primary);
    overflow-x: auto;
}

.artifact-details code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}


/* Response content inside snapshot sections */
.response-content {
    margin-top: 0.5rem;
    line-height: 1.6;
}

/* ============================================
   Footnotes Styling
   ============================================ */
.footnote-ref {
    font-size: 0.75em;
    vertical-align: super;
    line-height: 0;
    margin-left: 2px;
}

.footnote-ref a {
    color: var(--accent-primary);
    text-decoration: none;
    padding: 0 2px;
    border-radius: 3px;
    transition: background 0.2s;
}

.footnote-ref a:hover {
    background: rgba(99, 102, 241, 0.15);
    text-decoration: underline;
}

.footnotes-section {
    margin-top: 2.5rem;
    padding-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footnotes-sep {
    border: none;
    border-top: 1px solid var(--border-light);
    width: 20%;
    margin-bottom: 1rem;
}

.footnote-item {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    scroll-margin-top: 100px; /* Offset for sticky headers */
}

.footnote-item:target {
    background: rgba(99, 102, 241, 0.05);
    border-radius: 4px;
}

.footnote-num {
    font-weight: 600;
    min-width: 1.5rem;
}

.footnote-content {
    flex: 1;
    line-height: 1.5;
}

.footnote-url {
    word-break: break-all;
    color: var(--accent-secondary);
    text-decoration: none;
}

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

.footnote-backref {
    text-decoration: none;
    color: var(--accent-primary);
    font-weight: bold;
    padding: 0 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.footnote-backref:hover {
    opacity: 1;
}