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

[hidden] {
    display: none !important;
}

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

/* App Shell & Sidebar */
.app-shell {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    background-color: #f9fafb;
    border-right: 1px solid var(--border-base);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-smooth), padding var(--transition-smooth);
    z-index: 100;
    flex-shrink: 0;
    overflow-x: hidden;
    white-space: nowrap;
}

.sidebar.collapsed {
    width: 0 !important;
    border-right-width: 0;
    padding: 0;
    margin: 0;
}

/* Add an inner wrapper to prevent flex squishing */
.sidebar > * {
    min-width: 260px; /* Keep contents wide so they mask properly during width transition */
}

/* App Container */
.app-container {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    background: var(--bg-main);
    width: 100%;
}

.header-actions {
    margin-right: 20px;
}

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

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--primary);
}

.icon-button {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.icon-button:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Main Layouts */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-bottom: 80px;
}

.search-layout {
    transition: opacity var(--transition-smooth);
    margin-top: 15vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.search-layout[hidden] {
    display: none !important;
}

.search-layout .hero-title {
    margin-bottom: 40px;
}

.search-box-wrapper {
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
}

.composer-mode-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    align-self: center;
}

.composer-mode-toggle input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.composer-mode-toggle__pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 14px;
    border: 1px solid rgba(148, 163, 184, 0.26);
    border-radius: var(--radius-pill);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(248, 250, 252, 0.98) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    pointer-events: none;
    white-space: nowrap;
}

.composer-mode-toggle:hover .composer-mode-toggle__pill {
    border-color: rgba(148, 163, 184, 0.42);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 1) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.94), 0 4px 12px rgba(15, 23, 42, 0.05);
    transform: translateY(-1px);
}

.composer-mode-toggle input:focus-visible + .composer-mode-toggle__pill {
    border-color: rgba(37, 99, 235, 0.28);
    box-shadow: var(--shadow-focus), inset 0 1px 0 rgba(255, 255, 255, 0.96);
}

.composer-mode-toggle__label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.composer-mode-toggle input:checked + .composer-mode-toggle__pill {
    border-color: rgba(37, 99, 235, 0.22);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(239, 246, 255, 0.96) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.96), 0 0 0 1px rgba(37, 99, 235, 0.08), 0 8px 18px rgba(37, 99, 235, 0.12);
}

.composer-mode-toggle input:checked + .composer-mode-toggle__pill .composer-mode-toggle__label {
    color: var(--primary);
}

/* Bottom Sticky Chat Section */
.chat-input-sticky {
    position: fixed;
    bottom: 0;
    left: 260px; /* sidebar width */
    right: 0;
    padding: 32px 40px 40px;
    background: linear-gradient(to bottom, transparent 0%, var(--bg-main) 35%, var(--bg-main) 100%);
    transition: left var(--transition-smooth);
    /* Removed backdrop-filter to prevent muddy/dirty text rendering on scroll */
    z-index: 1000;
    transition: left var(--transition-smooth), transform 0.3s ease, opacity 0.3s ease;
}

.sidebar.collapsed + .app-container .chat-input-sticky {
    left: 0;
}

.chat-input-sticky[hidden] {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.search-input-container {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border-base);
    border-radius: 28px;
    padding: 6px 12px 6px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    transition: all var(--transition-smooth);
}

.search-input-container:focus-within {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.08);
    transform: translateY(-1px);
}

#query-input, #bottom-query-input {
    flex: 1;
    min-width: 0;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 24px;
    color: var(--text-primary);
    padding: 12px 0;
    resize: none !important;
    box-shadow: none !important;
    min-height: 48px;
    max-height: 200px;
}

#query-input::placeholder, #bottom-query-input::placeholder {
    color: var(--text-tertiary);
}

.search-submit {
    color: white;
    background: var(--border-dark);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.search-submit.active {
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.search-submit.active:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}

.search-submit svg {
    /* The send icon is optically heavy on the top-right tip, so we shift it slightly down and left to feel centered */
    transform: translate(-1px, 1px);
}

/* Loading Spinners */
@keyframes pulseRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.search-submit.loading svg {
    display: none;
}

.search-submit.loading::after {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: pulseRotate 0.8s linear infinite;
}

/* Suggestions */
.suggestions-container {
    margin-top: 32px;
    text-align: center;
    animation: fadeIn 0.8s ease;
}

.suggestions-label {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.suggestion-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.pill {
    background: var(--bg-secondary);
    border: 1px solid var(--border-base);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pill:hover {
    background: white;
    border-color: var(--primary-border);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Results Layout */
.results-layout {
    animation: slideUp 0.4s ease forwards;
}

/* Status Indicator (Thinking) */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-left: 8px;
}

.status-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-base);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: pulseRotate 0.8s linear infinite;
}

.status-text {
    font-size: 14px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.processing-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
}

/* Content Panels */
.content-panel {
    margin-bottom: 40px;
}

.answer-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.answer-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.meta-item {
    display: inline-flex;
    align-items: center;
}

.strategy-tag {
    background: rgba(123, 97, 255, 0.1);
    color: #b09cff;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}

.strategy-tag--deep {
    background: var(--primary-bg);
    color: var(--primary);
}

.answer-mode-tag {
    opacity: 0.9;
}

.deep-summary-strip {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
    margin-top: -10px;
    margin-bottom: -4px;
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-md);
    background: var(--primary-bg);
}

.deep-summary-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    line-height: 1.5;
}

.deep-summary-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.deep-summary-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    background: var(--bg-surface);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}

.deep-summary-badge--pdf {
    color: var(--text-secondary);
}

.deep-summary-badge--fallback {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.72);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge.high-confidence {
    background: var(--success-bg);
    color: var(--success);
}

/* Prose/Markdown Styles */
.prose {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.prose p {
    margin-bottom: 1.2em;
}

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

/* Inline Citations */
.citation-ref {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-bg);
    border-radius: var(--radius-sm);
    margin: 0 2px;
    padding: 0 4px;
    cursor: default;
    vertical-align: super;
    transition: all var(--transition-smooth);
}

.citation-ref:hover {
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary);
    transform: none;
    box-shadow: none;
    cursor: pointer;
}

/* Citation Tooltip */
.citation-tooltip {
    position: fixed;
    z-index: 9999;
    max-width: 360px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-base);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    font-size: 13px;
    line-height: 1.5;
}

.citation-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.citation-tooltip-title {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.citation-tooltip-meta {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Citations References List */
.citations-panel {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.citations-panel h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.citations-ordered-list {
    list-style-type: none;
    padding-left: 0;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.citation-item {
    margin-bottom: 0;
    padding: 10px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    background: var(--bg-main);
}

.citation-item:hover {
    border-color: var(--border-base);
    background: var(--bg-secondary);
}

.citation-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.citation-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.citation-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.citation-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.citation-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.citations-title-small {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

.citation-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    line-height: 1.5;
}
.citation-title:hover {
    text-decoration: underline;
}

.citation-review-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 8px;
    border-radius: var(--radius-pill);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.citation-review-badge--original {
    background: var(--success-bg);
    color: var(--success);
}

.citation-review-badge--pdf {
    background: var(--primary-bg);
    color: var(--primary);
}

.citation-review-badge--fallback {
    background: var(--border-light);
    color: var(--text-tertiary);
}

/* Error Banner */
.error-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error);
    padding: 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
}

/* Animations */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

/* Debug Panel */
.debug-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 2000;
}

.debug-overlay.open {
    opacity: 1;
    visibility: visible;
}

.debug-panel {
    position: absolute;
    top: 0; right: -400px; bottom: 0;
    width: 380px;
    background: var(--bg-surface);
    box-shadow: var(--shadow-float);
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.debug-overlay.open .debug-panel {
    right: 0;
}

.debug.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.strategy-dropdown {
    background-color: var(--bg-surface, var(--bg-primary, #ffffff));
    color: var(--text-primary);
    border: 1px solid var(--border-color, var(--border-base, #e5e7eb));
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
}

.strategy-dropdown:focus {
    outline: none;
    box-shadow: none;
}

.strategy-dropdown:hover {
    border-color: var(--accent-light);
}

.debug-link {
    color: var(--text-secondary);
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
}
.debug-link:hover {
    color: var(--accent-primary);
}

.app-header h1 {
    font-size: 14px;
    font-weight: 600;
}

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

.debug-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-tertiary);
    cursor: pointer;
}

.debug-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.debug-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-box {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: var(--radius-md);
    text-align: center;
}

.stat-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.stat-lbl {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

.answer-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Step Timeline */
.step-timeline {
    position: relative;
    margin: 4px 0 12px 0;
    padding-left: 28px;
}

.step-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 6px;
    bottom: 6px;
    width: 1.5px;
    background: var(--border-light);
    border-radius: 1px;
}

.step-item {
    position: relative;
    padding: 3px 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 24px;
}

.step-icon {
    position: absolute;
    left: -28px;
    top: 4px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    flex-shrink: 0;
    z-index: 1;
}

.step-icon--pending {
    background: var(--bg-main);
    border: 1.5px solid var(--border-base);
}

.step-icon--pending::after {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--border-base);
}

.step-icon--active {
    background: transparent;
    border: 2px solid var(--border-base);
    border-top-color: var(--primary);
    animation: stepSpin 0.7s linear infinite;
}

.step-icon--active::after {
    display: none;
}

.step-icon--done {
    background: #10b981;
    border: 1.5px solid #10b981;
}

.step-icon--done::after {
    content: '';
    display: block;
    width: 5px;
    height: 9px;
    border-right: 1.5px solid white;
    border-bottom: 1.5px solid white;
    transform: rotate(45deg);
    margin-top: -1px;
}

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

.step-label {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-tertiary);
    transition: color 0.2s;
}

.step-item.step--active .step-label {
    color: var(--primary);
    font-weight: 500;
}

.step-item.step--done .step-label {
    color: var(--text-tertiary);
    font-weight: 400;
}

.step-detail {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
    line-height: 1.4;
}

.step-detail-text {
    display: none;
}

.step-item.step--active .step-detail-text,
.step-item.step--done .step-detail-text {
    display: block;
}

/* Collapsed timeline: single line summary */
.step-timeline--collapsed {
    margin: 0 0 8px 0;
    padding-left: 0;
}

.step-timeline--collapsed::before {
    display: none;
}

.step-timeline--collapsed .step-item {
    display: none;
}

/* Expanded state: show items again — restore timeline padding for icon alignment */
.step-timeline--collapsed.step-timeline--expanded .step-item {
    display: flex;
}

.step-timeline--collapsed.step-timeline--expanded {
    padding-left: 28px;
}

.step-timeline--collapsed.step-timeline--expanded::before {
    display: block;
    left: 8px;
}

/* Keep collapse summary flush-left when expanded (compensate for timeline padding) */
.step-timeline--collapsed.step-timeline--expanded .step-collapse-summary {
    margin-left: -28px;
}

.step-timeline--collapsed .step-collapse-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 4px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-pill);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast);
}

.step-timeline--collapsed .step-collapse-summary:hover {
    background: var(--border-light);
}

.step-collapse-summary {
    display: none;
}

.step-collapse-summary .step-collapse-check {
    color: #10b981;
}

.step-collapse-chevron {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
    color: var(--text-quaternary);
}

.step-timeline--expanded .step-collapse-chevron {
    transform: rotate(180deg);
}

/* Hide original thinking and processing elements */
.thinking-container { display: none !important; }
.processing-status { display: none !important; }

.prose {
    font-size: 15px;
    line-height: 1.75;
    color: var(--text-primary);
    padding-bottom: 8px;
}

/* Markdown heading styles within prose */
.prose h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.6em 0 0.5em 0;
    padding-bottom: 0;
    border-bottom: none;
}

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

.prose h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 1.3em 0 0.4em 0;
}

.prose ul, .prose ol {
    margin: 0.6em 0;
    padding-left: 1.6em;
}

.prose li {
    margin-bottom: 0.3em;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.8em 0;
    font-size: 14px;
}

.prose th, .prose td {
    border: 1px solid var(--border-base);
    padding: 6px 10px;
    text-align: left;
}

.prose th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.prose code {
    font-size: 0.9em;
    background: var(--bg-secondary);
    padding: 1px 4px;
    border-radius: 3px;
}

.prose blockquote {
    border-left: 3px solid var(--primary);
    margin: 0.8em 0;
    padding: 0.4em 0.8em;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.debug-item {
    padding: 12px;
    border: 1px solid var(--border-base);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.debug-item.active {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.debug-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.debug-item .rank {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    background: var(--border-light);
    padding: 2px 6px;
    border-radius: 4px;
}

.debug-item .score {
    font-size: 11px;
    color: var(--text-quaternary);
}

.debug-item .title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.debug-detail {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-base);
}

.debug-detail h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.debug-detail h5 {
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
}

.debug-detail p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Match Badge */
.debug-item .match-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-bg);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

/* Score Breakdown Styles */
.score-breakdown {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 16px;
}

.breakdown-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.score-row .factor {
    color: var(--text-secondary);
}

.score-row .value {
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.score-row.highlight {
    background: var(--primary-bg);
}

.score-row.highlight .factor {
    color: var(--primary);
}

.score-row.highlight .value {
    color: var(--primary);
}

.score-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 8px;
    margin-top: 8px;
    border-top: 1px solid var(--border-base);
    font-size: 13px;
    font-weight: 600;
}

.score-total .total {
    color: var(--primary);
    font-size: 15px;
    font-family: 'JetBrains Mono', monospace;
}

/* Sidebar Specific Components */
.sidebar-header {
    padding: 16px;
}

.btn-new-chat {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--border-base);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-new-chat:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.sidebar-history-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.history-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}

.history-group-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-clear-history {
    font-size: 12px;
    color: var(--text-tertiary);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.7;
}

.btn-clear-history:hover {
    color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
    opacity: 1;
}

.btn-clear-history.confirming {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    opacity: 1;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    gap: 8px;
}

.history-item:hover {
    background: #f3f4f6;
    color: var(--text-primary);
}

.history-item.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 500;
}

.history-item-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-item-tags {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.history-item-tags .strategy-tag {
    zoom: 0.85;
}

.history-item-title-text {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Delete Button on History Item */
.history-delete-btn {
    opacity: 0;
    padding: 3px;
    border-radius: 4px;
    color: var(--text-tertiary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    cursor: pointer;
}

.history-item:hover .history-delete-btn {
    opacity: 1;
}

.history-delete-btn:hover {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

.history-delete-btn.confirming {
    opacity: 1;
    color: white !important;
    background-color: #ef4444 !important;
}

.history-delete-btn.confirming:hover {
    background-color: #dc2626 !important;
}

/* Chat Messages Stabilization */
.chat-messages {
    flex: 1;
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
    padding: 40px 0 160px; /* Removed horizontal padding to perfectly align with search box */
    display: flex;
    flex-direction: column;
    gap: 40px;
    /* Prevent layout shifting during sidebar expansion */
    flex-shrink: 0;
}

.app-content-wrapper {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Allow shrinking */
    flex: 1;
}

.message-turn {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 28px;
    padding-bottom: 36px;
    border-bottom: 1px solid var(--border-light);
    animation: fadeIn 0.4s ease-out;
}

.message-turn:first-child {
    padding-top: 0;
}

.message-turn:last-child {
    border-bottom: none;
}

.user-message {
    align-self: flex-start;
    max-width: 100%;
}

.user-query-text {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    letter-spacing: -0.01em;
}

.query-deep-badge {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-bg);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    letter-spacing: 0.02em;
    margin-left: 6px;
    position: relative;
    top: -1px;
}

.error-inline {
    color: #b45309;
    font-style: italic;
    padding: 12px 16px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    font-size: 14px;
}

.assistant-message {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.assistant-message:last-child {
    border-bottom: none;
}

.error-message {
    display: inline-flex;
    align-items: center;
    padding: 12px 16px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-base);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 8px;
}

.error-message svg {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2563eb;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

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

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
}
