/* CodeContext - Dual Theme Design System */
/* Light theme (default) + Dark Navy theme */

/* ============================================
   CSS CUSTOM PROPERTIES - THEME SYSTEM
   ============================================ */

:root {
    /* Light Theme Colors */
    --bg-primary: #f5f5f5;
    --bg-secondary: #eaeaea;
    --bg-card: #ffffff;
    --bg-card-header: #fafafa;
    --bg-input: #ffffff;

    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --border: #e5e5e5;
    --border-light: #f0f0f0;

    --accent: #0d9488;
    --accent-hover: #0f766e;
    --accent-light: rgba(13, 148, 136, 0.1);

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    /* Type badge colors - Light theme (muted/desaturated) */
    --type-bug-bg: #fecaca;
    --type-bug-text: #991b1b;
    --type-bug-border: #ef4444;

    --type-feature-bg: #d1fae5;
    --type-feature-text: #065f46;
    --type-feature-border: #10b981;

    --type-discovery-bg: #fef3c7;
    --type-discovery-text: #92400e;
    --type-discovery-border: #f59e0b;

    --type-decision-bg: #e0e7ff;
    --type-decision-text: #3730a3;
    --type-decision-border: #6366f1;

    --type-refactor-bg: #cffafe;
    --type-refactor-text: #155e75;
    --type-refactor-border: #06b6d4;

    --type-change-bg: #f3f4f6;
    --type-change-text: #374151;
    --type-change-border: #6b7280;

    --type-optimization-bg: #ecfccb;
    --type-optimization-text: #3f6212;
    --type-optimization-border: #84cc16;

    --type-gotcha-bg: #fce7f3;
    --type-gotcha-text: #9d174d;
    --type-gotcha-border: #ec4899;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;

    color-scheme: light;
}

/* Dark Navy Theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-header: #263348;
    --bg-input: #0f172a;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border: #334155;
    --border-light: #1e293b;

    --accent: #14b8a6;
    --accent-hover: #0d9488;
    --accent-light: rgba(20, 184, 166, 0.15);

    /* Type badge colors - Dark theme */
    --type-bug-bg: rgba(239, 68, 68, 0.2);
    --type-bug-text: #f87171;
    --type-bug-border: #ef4444;

    --type-feature-bg: rgba(16, 185, 129, 0.2);
    --type-feature-text: #34d399;
    --type-feature-border: #10b981;

    --type-discovery-bg: rgba(245, 158, 11, 0.2);
    --type-discovery-text: #fbbf24;
    --type-discovery-border: #f59e0b;

    --type-decision-bg: rgba(99, 102, 241, 0.2);
    --type-decision-text: #a5b4fc;
    --type-decision-border: #6366f1;

    --type-refactor-bg: rgba(6, 182, 212, 0.2);
    --type-refactor-text: #22d3ee;
    --type-refactor-border: #06b6d4;

    --type-change-bg: rgba(107, 114, 128, 0.2);
    --type-change-text: #9ca3af;
    --type-change-border: #6b7280;

    --type-optimization-bg: rgba(132, 204, 22, 0.2);
    --type-optimization-text: #a3e635;
    --type-optimization-border: #84cc16;

    --type-gotcha-bg: rgba(236, 72, 153, 0.2);
    --type-gotcha-text: #f472b6;
    --type-gotcha-border: #ec4899;

    /* Shadows - more prominent for dark theme */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);

    color-scheme: dark;
}

/* System preference detection (when no manual choice) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-card: #1e293b;
        --bg-card-header: #263348;
        --bg-input: #0f172a;

        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
        --text-muted: #64748b;

        --border: #334155;
        --border-light: #1e293b;

        --accent: #14b8a6;
        --accent-hover: #0d9488;
        --accent-light: rgba(20, 184, 166, 0.15);

        --type-bug-bg: rgba(239, 68, 68, 0.2);
        --type-bug-text: #f87171;
        --type-bug-border: #ef4444;

        --type-feature-bg: rgba(16, 185, 129, 0.2);
        --type-feature-text: #34d399;
        --type-feature-border: #10b981;

        --type-discovery-bg: rgba(245, 158, 11, 0.2);
        --type-discovery-text: #fbbf24;
        --type-discovery-border: #f59e0b;

        --type-decision-bg: rgba(99, 102, 241, 0.2);
        --type-decision-text: #a5b4fc;
        --type-decision-border: #6366f1;

        --type-refactor-bg: rgba(6, 182, 212, 0.2);
        --type-refactor-text: #22d3ee;
        --type-refactor-border: #06b6d4;

        --type-change-bg: rgba(107, 114, 128, 0.2);
        --type-change-text: #9ca3af;
        --type-change-border: #6b7280;

        --type-optimization-bg: rgba(132, 204, 22, 0.2);
        --type-optimization-text: #a3e635;
        --type-optimization-border: #84cc16;

        --type-gotcha-bg: rgba(236, 72, 153, 0.2);
        --type-gotcha-text: #f472b6;
        --type-gotcha-border: #ec4899;

        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);

        color-scheme: dark;
    }
}

/* ============================================
   BASE STYLES
   ============================================ */

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ============================================
   NAVBAR
   ============================================ */

.navbar {
    background: var(--bg-card);
    padding: 0.875rem 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 0.875rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
}

.nav-links a:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.nav-links a.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
}

.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

/* Nav Status (right side) */
.nav-status {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-badge {
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.status-badge.gpu {
    background: var(--accent);
    color: #fff;
}

.status-badge.cpu {
    background: var(--warning);
    color: #000;
}

.status-count {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Theme Toggle Button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--accent);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

/* Project Selector */
.project-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-selector label {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
}

.project-selector select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    min-width: 140px;
    transition: border-color var(--transition-fast);
}

.project-selector select:hover,
.project-selector select:focus {
    border-color: var(--accent);
    outline: none;
}

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* ============================================
   DASHBOARD
   ============================================ */

.dashboard {
    max-width: 1200px;
    margin: 0 auto;
}

.dashboard h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    margin-top: 0.375rem;
    font-weight: 500;
}

/* Section Header */
.section-header {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.memory-count {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--border);
}

/* Debug Mode Toggle */
.debug-mode-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
}

/* Auto-refresh Toggle */
.auto-refresh-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-secondary);
    border-radius: 22px;
    border: 1px solid var(--border);
    transition: var(--transition-normal);
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition-normal);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
    background: #fff;
}

.toggle-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.refresh-status {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
    min-width: 50px;
}

.refresh-status.active::before {
    content: "●";
    margin-right: 4px;
    animation: pulse 1.5s infinite;
}

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

/* ============================================
   FILTER BAR
   ============================================ */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.875rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

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

.filter-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Filter Chips */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    align-items: center;
}

.filter-chip {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: capitalize;
}

.filter-chip:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.filter-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

/* Sort Dropdown */
.filter-group select,
.sort-dropdown {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.filter-group select:hover,
.filter-group select:focus,
.sort-dropdown:hover,
.sort-dropdown:focus {
    border-color: var(--accent);
    outline: none;
}

/* Clear filter button */
.btn-clear {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-clear:hover {
    background: var(--error);
    border-color: var(--error);
    color: #fff;
}

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

.filter-status.active {
    color: var(--accent);
    font-weight: 500;
}

/* File filter input */
.file-filter {
    flex: 1;
    max-width: 220px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-filter input {
    flex: 1;
    min-width: 120px;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: 'Consolas', 'Monaco', monospace;
    transition: border-color var(--transition-fast);
}

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

.file-filter input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
}

/* ============================================
   MEMORY CARDS
   ============================================ */

.memory-cards {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.memory-card {
    background: var(--bg-card);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.memory-card:hover {
    box-shadow: var(--shadow-md);
}

/* Card Header */
.memory-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card-header);
    border-bottom: 1px solid var(--border-light);
}

/* Type Badges */
.type-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Type-specific styles */
.memory-card.type-bugfix,
.memory-card.type-bug {
    border-left-color: var(--type-bug-border);
}

.memory-card.type-bugfix .type-badge,
.memory-card.type-bug .type-badge,
.type-badge.type-bugfix,
.type-badge.type-bug {
    background: var(--type-bug-bg);
    color: var(--type-bug-text);
}

.memory-card.type-feature {
    border-left-color: var(--type-feature-border);
}

.memory-card.type-feature .type-badge,
.type-badge.type-feature {
    background: var(--type-feature-bg);
    color: var(--type-feature-text);
}

.memory-card.type-discovery {
    border-left-color: var(--type-discovery-border);
}

.memory-card.type-discovery .type-badge,
.type-badge.type-discovery {
    background: var(--type-discovery-bg);
    color: var(--type-discovery-text);
}

.memory-card.type-decision {
    border-left-color: var(--type-decision-border);
}

.memory-card.type-decision .type-badge,
.type-badge.type-decision {
    background: var(--type-decision-bg);
    color: var(--type-decision-text);
}

.memory-card.type-refactor {
    border-left-color: var(--type-refactor-border);
}

.memory-card.type-refactor .type-badge,
.type-badge.type-refactor {
    background: var(--type-refactor-bg);
    color: var(--type-refactor-text);
}

.memory-card.type-change {
    border-left-color: var(--type-change-border);
}

.memory-card.type-change .type-badge,
.type-badge.type-change {
    background: var(--type-change-bg);
    color: var(--type-change-text);
}

.memory-card.type-optimization {
    border-left-color: var(--type-optimization-border);
}

.memory-card.type-optimization .type-badge,
.type-badge.type-optimization {
    background: var(--type-optimization-bg);
    color: var(--type-optimization-text);
}

.memory-card.type-gotcha {
    border-left-color: var(--type-gotcha-border);
}

.memory-card.type-gotcha .type-badge,
.type-badge.type-gotcha {
    background: var(--type-gotcha-bg);
    color: var(--type-gotcha-text);
}

/* Project Tag */
.project-tag {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border: 1px solid var(--border);
}

/* Memory Date */
.memory-date {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: auto;
}

/* Card Body */
.memory-card-body {
    padding: 1rem 1.25rem;
}

.memory-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    line-height: 1.4;
}

.memory-card-fact {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 0;
}

/* Card Footer - Files */
.memory-card-footer {
    padding: 0.75rem 1.25rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-light);
}

.memory-card-footer-label {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.memory-card-files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.memory-card-files code {
    background: var(--bg-card);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    color: var(--accent);
    border: 1px solid var(--border);
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Clickable file tags */
.memory-card-files code.clickable-file {
    cursor: pointer;
    transition: all var(--transition-fast);
}

.memory-card-files code.clickable-file:hover {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

/* ============================================
   LOADING & EMPTY STATES
   ============================================ */

#loading-indicator {
    display: none;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-top: 0.875rem;
}

#loading-indicator.active {
    display: flex;
}

#loading-indicator::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.625rem;
}

#end-of-list {
    text-align: center;
    padding: 1.25rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-top: 0.875rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.empty-state p {
    margin: 0;
    font-size: 0.9375rem;
}

/* ============================================
   SEARCH PAGE
   ============================================ */

.search-page {
    max-width: 1200px;
    margin: 0 auto;
}

.search-page h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.search-form-container {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.search-form {
    display: flex;
    gap: 0.75rem;
}

.search-input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: border-color var(--transition-fast);
}

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

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

.search-button {
    padding: 0.875rem 1.5rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.search-button:hover {
    background: var(--accent-hover);
}

.search-meta {
    margin-bottom: 1rem;
    padding: 0.625rem 0.875rem;
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

/* Relevance Badge */
.relevance-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: auto;
}

.relevance-badge.good {
    background: var(--type-feature-bg);
    color: var(--type-feature-text);
}

.relevance-badge.ok {
    background: var(--type-discovery-bg);
    color: var(--type-discovery-text);
}

.relevance-badge.low {
    background: var(--type-change-bg);
    color: var(--type-change-text);
}

/* Search Tips */
.search-tips {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    margin-top: 1.5rem;
}

.search-tips h3 {
    margin: 0 0 0.875rem 0;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.search-tips ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-tips li {
    padding: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-light);
}

.search-tips li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.search-tips li::before {
    content: "›";
    color: var(--accent);
    font-weight: 700;
    margin-right: 0.5rem;
}

/* ============================================
   CONFLICTS PAGE
   ============================================ */

.conflicts-page {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.conflicts-page h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.conflicts-page .page-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
}

.conflicts-page .stats-grid {
    grid-template-columns: repeat(4, 1fr);
}

/* Nav Badge */
.nav-conflicts {
    position: relative;
}

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    background: var(--warning);
    color: #000;
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 9px;
}

/* Conflict Tabs */
.conflict-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.conflict-tab {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

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

.conflict-tab.active {
    color: var(--text-primary);
    background: var(--bg-secondary);
    font-weight: 600;
}

.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--warning);
    color: #000;
    font-size: 0.625rem;
    font-weight: 700;
    border-radius: 9px;
}

/* Conflict List */
.conflict-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Conflict Card */
.conflict-card {
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--warning);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast);
}

.conflict-card:hover {
    box-shadow: var(--shadow-md);
}

.conflict-card[data-status="resolved"] {
    border-left-color: var(--success);
    opacity: 0.8;
}

.conflict-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: var(--bg-card-header);
    border-bottom: 1px solid var(--border-light);
}

.conflict-status-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
}

.conflict-status-badge.pending {
    background: var(--type-discovery-bg);
    color: var(--type-discovery-text);
}

.conflict-status-badge.resolved {
    background: var(--type-feature-bg);
    color: var(--type-feature-text);
}

/* Side-by-Side Comparison */
.conflict-comparison {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    padding: 1.25rem;
}

.conflict-side {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border);
}

.conflict-side-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.conflict-side-label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.conflict-new .conflict-side-label {
    background: var(--type-feature-bg);
    color: var(--type-feature-text);
}

.conflict-existing .conflict-side-label {
    background: var(--type-decision-bg);
    color: var(--type-decision-text);
}

.conflict-side-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.conflict-title {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.conflict-fact {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.conflict-files {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.conflict-files code {
    background: var(--bg-card);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.625rem;
    color: var(--accent);
    border: 1px solid var(--border);
}

.conflict-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Resolution Actions */
.conflict-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-light);
}

/* Resolved Conflict Info */
.conflict-resolved-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-light);
}

.resolved-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.resolved-value {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    font-family: 'Consolas', 'Monaco', monospace;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--accent-light);
    color: var(--accent);
    border: 1px solid var(--accent);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

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

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

.btn-resolve {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-resolve:hover {
    border-color: var(--accent);
}

.btn-keep-new:hover {
    background: var(--type-feature-bg);
    border-color: var(--type-feature-border);
    color: var(--type-feature-text);
}

.btn-keep-existing:hover {
    background: var(--type-decision-bg);
    border-color: var(--type-decision-border);
    color: var(--type-decision-text);
}

.btn-keep-both:hover {
    background: var(--type-discovery-bg);
    border-color: var(--type-discovery-border);
    color: var(--type-discovery-text);
}

.btn-sm {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   MODAL
   ============================================ */

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modalFadeIn 0.2s ease-out;
}

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

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

[data-theme="dark"] .modal-backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: auto;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.modal-large {
    max-width: 800px;
    max-height: 85vh;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

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

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

.modal-body {
    padding: 1.25rem;
}

.modal-body label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
}

.modal-body textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
    margin-bottom: 1rem;
}

.modal-body textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(1rem);
    transition: all 0.3s ease;
    z-index: 1100;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: var(--success);
    color: #fff;
}

.toast-error {
    background: var(--error);
    color: #fff;
}

.toast-info {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
    background: var(--bg-card);
}

.footer p {
    margin: 0;
}

.footer strong {
    color: var(--text-secondary);
}

/* ============================================
   CONSOLIDATION PAGE
   ============================================ */

.consolidation-page {
    max-width: 1200px;
    margin: 0 auto;
}

.consolidation-page h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.consolidation-page .page-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
}

/* Auto-Consolidation Settings */
.auto-consolidation-settings {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.875rem 1.25rem;
    margin-bottom: 1.25rem;
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.settings-toggle-row .setting-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.settings-toggle-row .setting-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.settings-toggle-row .mode-select,
.settings-toggle-row .interval-select {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
}

/* Progress Container */
.progress-container {
    background: var(--bg-card);
    border: 2px solid var(--accent);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.progress-phase {
    font-weight: 600;
    color: var(--accent);
}

.progress-time {
    font-family: 'Consolas', monospace;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.progress-bar-wrapper {
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #34d399);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.progress-detail {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* Consolidation Controls */
.consolidation-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 1rem 1.25rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 1.25rem;
    gap: 1.5rem;
    flex-wrap: wrap;
}

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

.control-group label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.control-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 140px;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

#threshold-value {
    font-family: 'Consolas', monospace;
    font-weight: 600;
    color: var(--accent);
}

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

.control-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Tier Summary */
.tier-summary {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.tier-item {
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tier-auto {
    background: var(--type-feature-bg);
    color: var(--type-feature-text);
}

.tier-llm-small {
    background: var(--type-decision-bg);
    color: var(--type-decision-text);
}

.tier-llm-large {
    background: var(--type-discovery-bg);
    color: var(--type-discovery-text);
}

/* Cluster List */
.cluster-list {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.cluster-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.cluster-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: var(--bg-card-header);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.cluster-id {
    font-family: 'Consolas', monospace;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.cluster-size {
    background: var(--accent);
    color: white;
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.cluster-distance {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Consolas', monospace;
}

.btn-expand {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 1.125rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

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

.cluster-memories {
    padding: 1rem;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cluster-memory {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    position: relative;
    border-left: 4px solid var(--accent);
}

.cluster-memory .memory-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
    flex-wrap: wrap;
}

.cluster-memory .memory-id {
    font-family: 'Consolas', monospace;
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.cluster-memory .memory-date {
    font-size: 0.6875rem;
    color: var(--text-muted);
    margin-left: auto;
}

.cluster-memory .memory-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.375rem 0;
}

.cluster-memory .memory-fact {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.cluster-memory .memory-files {
    margin-top: 0.625rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.cluster-memory .memory-files code {
    font-size: 0.6875rem;
    background: var(--bg-secondary);
    color: var(--accent);
    padding: 0.2rem 0.375rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Cluster memory type-specific borders */
.cluster-memory.type-discovery { border-left-color: var(--type-discovery-border); }
.cluster-memory.type-bug,
.cluster-memory.type-bugfix { border-left-color: var(--type-bug-border); }
.cluster-memory.type-feature { border-left-color: var(--type-feature-border); }
.cluster-memory.type-decision { border-left-color: var(--type-decision-border); }
.cluster-memory.type-refactor { border-left-color: var(--type-refactor-border); }
.cluster-memory.type-change { border-left-color: var(--type-change-border); }
.cluster-memory.type-optimization { border-left-color: var(--type-optimization-border); }
.cluster-memory.type-gotcha { border-left-color: var(--type-gotcha-border); }

/* Decision badges in preview modal */
.decision-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.decision-keep_one {
    background: var(--type-decision-bg);
    color: var(--type-decision-text);
}

.decision-merge {
    background: var(--type-refactor-bg);
    color: var(--type-refactor-text);
}

.decision-keep_all {
    background: var(--type-feature-bg);
    color: var(--type-feature-text);
}

/* Preview modal styles */
.preview-summary {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.preview-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 50vh;
    overflow-y: auto;
}

.preview-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.875rem;
}

.preview-item-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
}

.preview-number {
    background: var(--accent);
    color: #fff;
    padding: 0.2rem 0.375rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
}

.preview-cluster-id {
    font-family: 'Consolas', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.preview-reasoning {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.5;
    margin: 0;
}

.decision-detail {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
}

.decision-detail code {
    font-size: 0.6875rem;
    background: var(--bg-secondary);
    padding: 0.15rem 0.375rem;
    border-radius: 4px;
}

.decision-merged {
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: 6px;
    margin-top: 0.5rem;
    border-left: 3px solid var(--accent);
}

.decision-merged p {
    margin: 0.2rem 0;
    font-size: 0.8125rem;
}

.delete-info {
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--error);
    font-weight: 500;
}

.delete-info.keep-all {
    color: var(--success);
}

.delete-count {
    background: var(--error);
    color: white;
    padding: 0.15rem 0.375rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    margin-left: auto;
}

/* Consolidation History */
.consolidation-history {
    margin-top: 1rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.history-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--success);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.history-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: var(--bg-card-header);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.history-status-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--type-feature-bg);
    color: var(--type-feature-text);
}

.history-timestamp {
    font-family: 'Consolas', monospace;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.history-project {
    background: var(--bg-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.history-stats {
    margin-left: auto;
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.stat-badge {
    padding: 0.15rem 0.375rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
}

.stat-badge.stat-clusters {
    background: var(--type-decision-bg);
    color: var(--type-decision-text);
}

.stat-badge.stat-merged {
    background: var(--type-refactor-bg);
    color: var(--type-refactor-text);
}

.stat-badge.stat-kept {
    background: var(--type-feature-bg);
    color: var(--type-feature-text);
}

.stat-badge.stat-deleted {
    background: var(--type-bug-bg);
    color: var(--type-bug-text);
}

.history-card-body {
    padding: 0.875rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-result {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.625rem;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.history-reasoning {
    flex: 1;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.history-merged {
    font-size: 0.75rem;
    color: var(--accent);
    margin-top: 0.375rem;
}

/* Auto-resolve toggle */
.auto-resolve-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    padding: 0.375rem 0.625rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.auto-resolve-toggle .toggle-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.auto-resolve-btn {
    margin-left: 0.375rem;
    padding: 0.375rem 0.75rem;
}

/* Confidence badges */
.confidence-badge {
    display: inline-block;
    padding: 0.2rem 0.375rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
    margin-left: 0.375rem;
}

.confidence-auto {
    background: var(--type-discovery-bg);
    color: var(--type-discovery-text);
}

.confidence-high {
    background: var(--type-feature-bg);
    color: var(--type-feature-text);
}

.confidence-medium {
    background: var(--type-decision-bg);
    color: var(--type-decision-text);
}

.confidence-low {
    background: var(--type-bug-bg);
    color: var(--type-bug-text);
}

/* Distance Badge */
.distance-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.375rem;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .nav-links {
        order: 3;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .nav-status {
        order: 2;
    }

    .project-selector {
        order: 1;
    }

    .container {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .filter-chips {
        justify-content: center;
    }

    .section-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .auto-refresh-toggle {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }

    .conflict-comparison {
        grid-template-columns: 1fr;
    }

    .conflict-arrow {
        transform: rotate(90deg);
        padding: 0.5rem 0;
    }

    .consolidation-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-buttons {
        width: 100%;
    }

    .control-buttons .btn {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .memory-card-header {
        flex-wrap: wrap;
    }

    .memory-date {
        width: 100%;
        margin-left: 0;
        margin-top: 0.375rem;
    }
}

/* ============================================
   ARCHIVE PAGE
   ============================================ */

.archive-page {
    max-width: 1200px;
    margin: 0 auto;
}

.archive-page h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Archive Tabs - mirrors conflict-tabs pattern */
.archive-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.archive-tab {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all var(--transition-fast);
    font-size: 0.875rem;
    font-weight: 500;
}

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

.archive-tab.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
}

/* Archive List */
.archive-list {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

/* Archive Card - mirrors memory-card pattern */
.archive-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--text-muted);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast);
    overflow: hidden;
    opacity: 0.85;
}

.archive-card:hover {
    box-shadow: var(--shadow-md);
    opacity: 1;
}

.archive-card-header {
    padding: 0.75rem 1rem;
    background: var(--bg-card-header);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.archive-title {
    padding: 0.75rem 1.25rem 0.25rem;
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.archive-fact {
    padding: 0.25rem 1.25rem 0.75rem;
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.archive-files {
    padding: 0 1.25rem 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.archive-files code {
    background: var(--bg-card);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    color: var(--accent);
    border: 1px solid var(--border);
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Archive Reason Badge */
.archive-reason-badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.archive-reason-badge.reason-conflict_resolution {
    background: var(--type-discovery-bg);
    color: var(--type-discovery-text);
}

.archive-reason-badge.reason-consolidation {
    background: var(--type-refactor-bg);
    color: var(--type-refactor-text);
}

.archive-reason-badge.reason-manual {
    background: var(--type-change-bg);
    color: var(--type-change-text);
}

/* Archive Metadata */
.archive-metadata {
    padding: 0.5rem 1.25rem 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.archive-metadata .metadata-item {
    display: flex;
    gap: 0.25rem;
}

.archive-metadata .metadata-item strong {
    color: var(--text-secondary);
    font-weight: 500;
}

.archive-metadata .metadata-reasoning {
    flex-basis: 100%;
    padding-top: 0.25rem;
    border-top: 1px dashed var(--border-light);
    margin-top: 0.25rem;
}

/* Archive Actions */
.archive-actions {
    padding: 0.75rem 1.25rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-restore {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}

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

.btn-danger {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

/* Load More */
.load-more {
    text-align: center;
    padding: 1.5rem 0;
}

/* Archive responsive */
@media (max-width: 768px) {
    .archive-tabs {
        gap: 0.5rem;
    }

    .archive-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .archive-actions {
        flex-direction: column;
    }

    .archive-actions .btn {
        width: 100%;
        justify-content: center;
    }
}
