/* CSS Variables for theming */
:root {
    /* Light theme colors */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;    /* Darker for better contrast */
    --text-secondary: #475569;  /* Slightly darker gray-blue */
    --text-muted: #64748b;      /* Keep this tone for subtle info */
    --border-color: #cbd5e1;    /* Slightly darker for separation */
    --border-light: #f1f5f9;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* Magical theme colors */
    --arcane-purple: #756AA2;
    --arcane-glow: rgba(117, 106, 162, 0.1);
    --arcane-shimmer: rgba(117, 106, 162, 0.2);
    --magical-gradient: radial-gradient(circle at top center, rgba(117, 106, 162, 0.15) 0%, transparent 70%);
}

[data-theme="dark"] {
    /* Dark theme colors - lightened for less fatigue */
    --bg-primary: #1a2433;
    --bg-secondary: #253447;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: #475569;
    --border-light: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
    --gradient-primary: linear-gradient(135deg, #4c1d95 0%, #7c3aed 100%);
    --gradient-secondary: linear-gradient(135deg, #4c1d95 0%, #7c3aed 100%);
    
    /* Magical theme colors for dark mode */
    --arcane-purple: #9F7AEA;
    --arcane-glow: rgba(159, 122, 234, 0.15);
    --arcane-shimmer: rgba(159, 122, 234, 0.25);
    --magical-gradient: radial-gradient(circle at top center, rgba(159, 122, 234, 0.2) 0%, transparent 70%);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    background-image: var(--magical-gradient);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    margin-bottom: 40px;
    padding: 40px 0;
    background: var(--gradient-primary);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px var(--shadow);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-text {
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Fixed theme toggle in bottom corner */
.theme-toggle-fixed {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.theme-toggle-fixed .btn {
    background: rgba(255, 255, 255, 0.95);
    color: #1e293b;
    border: 2px solid var(--accent);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 12px 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    font-weight: 600;
}

[data-theme="dark"] .theme-toggle-fixed .btn {
    background: rgba(30, 41, 59, 0.95);
    color: #f1f5f9;
    border: 2px solid var(--accent);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4), 0 0 30px rgba(124, 58, 237, 0.2);
}

.theme-toggle-fixed .btn:hover {
    background: var(--accent);
    color: var(--text-primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border: 2px solid var(--accent);
}

[data-theme="light"] .theme-toggle-fixed .btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6), 0 0 30px rgba(102, 126, 234, 0.3);
    border: 2px solid #667eea;
}

[data-theme="dark"] .theme-toggle-fixed .btn:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: #1e293b;
    box-shadow: 0 8px 25px rgba(248, 250, 252, 0.6), 0 0 30px rgba(248, 250, 252, 0.3);
    border: 2px solid #f8fafc;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-hover), 0 0 20px var(--arcane-shimmer);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%), var(--arcane-glow);
}

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

.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

/* Upload Section */
.upload-section {
    margin-bottom: 40px;
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    padding: 60px 40px;
    text-align: center;
    background: var(--bg-secondary);
    box-shadow: inset 0 0 8px var(--arcane-glow);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #667eea;
    background: var(--bg-primary);
}

.upload-area.dragover {
    border-color: #667eea;
    background: var(--bg-tertiary);
    transform: scale(1.02);
}

.upload-content {
    max-width: 400px;
    margin: 0 auto;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 20px;
}

.upload-area h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 15px;
}

/* Upload buttons */
.upload-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
}

.upload-buttons .btn {
    min-width: 150px;
}

/* Selected Files List */
.selected-files-list {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    text-align: left;
}

.selected-files-list h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
}

.selected-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.selected-file:last-child {
    margin-bottom: 0;
}

.file-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.file-name {
    font-size: 0.95rem;
    color: var(--text-primary);
    flex: 1;
}

.file-size {
    font-size: 0.85rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

#files-list-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.file-item-name {
    font-size: 0.95rem;
    color: var(--text-primary);
    flex: 1;
}

.file-item-remove {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 8px;
    transition: color 0.2s ease;
}

.file-item-remove:hover {
    color: #dc2626;
}

/* Context Awareness Panel */
.context-section {
    margin-bottom: 30px;
}

.context-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow), inset 0 0 10px var(--arcane-glow);
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Light theme: Add subtle shadows for hierarchy */
[data-theme="light"] .context-panel {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    border: 2px solid #e5e7eb;
}

.context-header {
    display: flex;
    align-items: center;
    padding: 20px;
    cursor: pointer;
    background: var(--bg-tertiary);
    transition: background 0.2s ease;
    gap: 12px;
}

/* Light theme: Add subtle gradient to header */
[data-theme="light"] .context-header {
    background: linear-gradient(135deg, #f6f8fa 0%, #eceff3 100%);
}

.context-header:hover {
    background: var(--bg-primary);
}

.context-toggle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
    flex-shrink: 0;
    transform: rotate(-90deg); /* Start pointing right (collapsed) */
}

.context-toggle.expanded {
    transform: rotate(0deg); /* Point down when expanded */
}

.context-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.context-title h3 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin: 0;
}

#context-icon {
    font-size: 1.5rem;
}

.context-header-badge {
    padding: 6px 12px;
    border-radius: 16px;
    font-weight: 600;
    font-size: 0.85rem;
    margin-left: auto;
    flex-shrink: 0;
}

.context-header-badge.complete {
    background: #10b981;
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .context-header-badge.complete {
    background: #059669;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.4);
}

.context-header-badge.partial {
    background: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(234, 88, 12, 0.4);
    animation: soft-pulse 3s ease-in-out infinite;
}

@keyframes soft-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.9; }
}

[data-theme="dark"] .context-header-badge.partial {
    background: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(249, 115, 22, 0.5);
}

.context-content {
    padding: 20px;
    max-height: 600px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.context-content.collapsed {
    max-height: 0;
    padding: 0 20px;
    overflow: hidden;
}

/* New UX-focused styling */
.context-files {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

/* Dark theme: Add subtle glow between sections */
[data-theme="dark"] .context-files,
[data-theme="dark"] .context-missing {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.context-files h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}

/* Dark theme: Add subtle separator for section headers */
[data-theme="dark"] .context-files h4,
[data-theme="dark"] .context-missing h4,
[data-theme="dark"] .context-impact h4 {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.context-files ul {
    list-style: none;
    padding: 0;
}

.context-files li {
    padding: 6px 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Dark theme: Improve file list contrast for WCAG compliance */
[data-theme="dark"] .context-files li {
    color: #e0e6ef;
}

.context-missing {
    margin-bottom: 20px;
    padding-bottom: 20px;
}

.context-missing h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}

.context-missing-items {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.context-missing-item {
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.context-missing-item.required {
    background: #dc2626;
    color: #fecaca;
    border: 2px solid #b91c1c;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
}

/* Light theme: Desaturate red chips for less strain */
[data-theme="light"] .context-missing-item.required {
    background: #e85a5a;
    border-color: #d14545;
    color: #fff5f5;
}

[data-theme="dark"] .context-missing-item.required {
    background: #ef4444;
    color: #fee2e2;
    border: 2px solid #f87171;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
}

.context-impact {
    margin-top: 20px;
    margin-bottom: 12px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border-left: 4px solid #ef4444;
}

/* Light theme: Darken panel and add accent shadow */
[data-theme="light"] .context-impact {
    background: #e7ecf3;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.1);
}

.context-impact h4 {
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}

.context-impact-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
    font-style: italic;
}

.context-impact-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.context-impact-item {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-left: 12px;
    font-size: 0.9rem;
}

/* Light theme: Add subtle shadow for depth */
[data-theme="light"] .context-impact-item {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.context-impact-item strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 4px;
}

.context-impact-item span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.context-tip {
    margin-top: 20px;
    padding: 16px;
    background: #eff6ff;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

[data-theme="dark"] .context-tip {
    background: #1e3a8a;
}

.context-tip p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
}

.context-tip strong {
    color: var(--text-primary);
}

/* Configuration Selection Styles */
.config-selection {
    margin-top: 30px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.config-selection h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--text-primary);
    text-align: center;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    max-width: 800px;
    margin: 0 auto;
}

.config-option {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    box-shadow: inset 0 0 6px var(--arcane-glow);
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
}

.config-option:hover {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.25);
}

/* Light mode selected config */
[data-theme="light"] .config-option.selected,
:not([data-theme]) .config-option.selected {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    outline: 2px solid #4f46e5;
    outline-offset: 0;
    box-shadow: 0 0 10px rgba(79, 70, 229, 0.4);
}

/* Dark mode selected config */
[data-theme="dark"] .config-option.selected {
    border-color: #a5b4fc;
    background: linear-gradient(135deg, #4f46e5 0%, #818cf8 100%);
    outline: 2px solid #a5b4fc;
    outline-offset: 0;
    box-shadow: 0 0 10px rgba(129, 140, 248, 0.5);
    color: #ffffff; /* primary text always white */
}

/* Secondary sentence text inside selected config */
[data-theme="dark"] .config-option.selected .config-description {
    color: #f3f4f6;   /* light gray, strong enough to read over indigo */
}

/* Rule count + performance badges inside selected config */
[data-theme="dark"] .config-option.selected .config-rules-count,
[data-theme="dark"] .config-option.selected .config-performance,
[data-theme="dark"] .config-option.selected .badge {
    color: #f9fafb;  
    font-weight: 500;
}

.config-option.selected .config-name {
    color: #1e1b4b;
    font-weight: 700;
}

.config-option.selected .config-description {
    color: #3730a3;
}

.config-option.selected .config-meta {
    color: #1e1b4b;
}

.config-option.selected .config-rules-count {
    background: rgba(79, 70, 229, 0.1);
    color: #1e1b4b;
    font-weight: 600;
}


.config-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.config-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.3;
}

.config-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Light mode rule counter chips */
[data-theme="light"] .config-rules-count,
:not([data-theme]) .config-rules-count {
    background: #f1f5f9;   /* light gray */
    color: #1e293b;        /* dark text */
}

/* Dark mode rule counter chips */
[data-theme="dark"] .config-rules-count {
    background: #1e293b;   /* slightly lighter than card background */
    color: #e0e7ff;        /* soft indigo text for contrast */
}


.config-performance {
    font-weight: 500;
}

.config-performance.fast {
    color: #10b981;
}

.config-performance.balanced {
    color: #f59e0b;
}

.config-performance.thorough {
    color: #ef4444;
}

/* Configuration Type Indicators */
.config-type {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px;
    text-transform: uppercase;
}

.config-type.built-in {
    background: #e0e7ff;
    color: #3730a3;
}

.config-type.team {
    background: #dcfce7;
    color: #166534;
}

.config-type.personal {
    background: #fef3c7;
    color: #92400e;
}

/* Configuration Grid Grouping */
.config-section {
    margin-bottom: 15px;
}

.config-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-left: 6px;
    border-left: 2px solid #667eea;
}

.config-section .config-grid {
    margin-bottom: 0;
}

/* Configuration Actions (inline in selected cards) */
.config-actions {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.config-option.selected .config-actions {
    opacity: 1;
    transform: translateY(0);
}

.config-details-btn {
    font-size: 0.8rem;
    padding: 6px 12px;
    min-width: auto;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    max-width: 90%;
    max-height: 90%;
    width: 800px;
    box-shadow: 0 20px 40px var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-tertiary);
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

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

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
    background: var(--bg-secondary);
}

/* Configuration Breakdown Styles */
.config-breakdown-section {
    margin-bottom: 24px;
}

.config-breakdown-section h4 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.rule-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.rule-item {
    padding: 12px;
    padding-bottom: 40px; /* Extra space for badge at bottom */
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    transition: all 0.2s ease;
    position: relative; /* For absolute positioning of badge */
}

.rule-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow);
}

/* Accessibility: Using blue/orange instead of green/red for colorblind users */
/* Solid vs dashed borders provide additional visual differentiation */
.rule-item.enabled {
    border-left: 4px solid #0284c7; /* Blue (solid border) for enabled */
    border-style: solid;
}

.rule-item.disabled {
    border-left: 4px dashed #d97706; /* Orange (dashed border) for disabled */
    /* Removed opacity - badges now handle their own styling */
}

.rule-item.disabled .rule-description {
    opacity: 0.7; /* Subtle dimming only on description text */
}

.rule-header-row {
    margin-bottom: 4px;
}

.rule-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    padding-right: 10px; /* Prevent wrapping too close to edge */
}

.rule-status-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.rule-status-badge.enabled {
    background: #0284c7;
    color: #ffffff;
    border: 2px solid #0369a1;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.2);
}

.rule-status-badge.disabled {
    background: #ea580c;
    color: #ffffff;
    border: 2px solid #c2410c;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(234, 88, 12, 0.2);
}

/* Theme-specific status badge colors */
[data-theme="dark"] .rule-status-badge.enabled {
    background: #0284c7;
    color: #ffffff;
    border: 2px solid #0ea5e9;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.4);
}

[data-theme="dark"] .rule-status-badge.disabled {
    background: #f97316;
    color: #ffffff;
    border: 2px solid #fb923c;
    box-shadow: 0 2px 8px rgba(251, 146, 60, 0.5);
}

.rule-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.rule-settings {
    margin-top: 8px;
}

.settings-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.settings-json {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-light);
    font-family: 'Courier New', 'Consolas', monospace;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
    overflow-x: auto;
    line-height: 1.4;
}

/* Theme-specific JSON styling */
[data-theme="light"] .settings-json {
    background: #f8f9fa;
    border-color: #e9ecef;
    color: #495057;
}

[data-theme="dark"] .settings-json {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

/* Configuration Summary Grid */
.config-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.summary-card {
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow);
}

.summary-card.enabled {
    border-left: 4px solid #0284c7; /* Blue instead of green */
}

.summary-card.disabled {
    border-left: 4px dashed #d97706; /* Orange dashed instead of red solid */
}

.summary-card.total {
    border-left: 4px solid #667eea;
}

.summary-number {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.summary-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Theme-specific modal overlay */
[data-theme="light"] .modal {
    background: rgba(0, 0, 0, 0.4);
}

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

/* Theme-specific rule item colors */
[data-theme="light"] .rule-item.enabled,
[data-theme="light"] .summary-card.enabled {
    border-left-color: #0369a1; /* Darker blue for light mode */
}

[data-theme="dark"] .rule-item.enabled,
[data-theme="dark"] .summary-card.enabled {
    border-left-color: #38bdf8; /* Lighter blue for dark mode */
}

[data-theme="light"] .rule-item.disabled,
[data-theme="light"] .summary-card.disabled {
    border-left-color: #c2410c; /* Darker orange for light mode */
}

[data-theme="dark"] .rule-item.disabled,
[data-theme="dark"] .summary-card.disabled {
    border-left-color: #fb923c; /* Lighter orange for dark mode */
}

[data-theme="light"] .summary-card.total {
    border-left-color: #4f46e5;
}

[data-theme="dark"] .summary-card.total {
    border-left-color: #667eea;
}

/* Loading Section */
.loading-section {
    text-align: center;
    padding: 60px 40px;
}

.loading-content {
    max-width: 400px;
    margin: 0 auto;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Error Section */
.error-section {
    text-align: center;
    padding: 60px 40px;
    background: white;
    border-radius: 12px;
    border-left: 4px solid #ef4444;
}

.error-content h3 {
    color: #dc2626;
    margin-bottom: 15px;
}

.error-content p {
    color: #64748b;
    margin-bottom: 20px;
}

/* Results Section */
.results-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 6px var(--shadow);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}

.results-header h3 {
    font-size: 1.8rem;
    color: var(--text-primary);
}

.results-actions {
    display: flex;
    gap: 12px;
}

/* Summary */
.summary {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
}

.summary h4 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.summary-item {
    text-align: center;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
    position: relative;
}

/* ⚡️ ARCANE MODE: THE GRAND RITUAL EDITION ⚡️ */
/* Magical color palette */
:root {
    --arcane-purple: #756AA2;
    --arcane-gold: #EAA342;
    --arcane-green: #98C83C;
    --arcane-shadow: rgba(117, 106, 162, 0.3);
    --arcane-glow: rgba(234, 163, 66, 0.4);
}

/* Summoning Circle Background */
.magic-mode::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(2px 2px at 20px 30px, var(--arcane-gold), transparent),
        radial-gradient(2px 2px at 40px 70px, var(--arcane-purple), transparent),
        radial-gradient(1px 1px at 90px 40px, var(--arcane-green), transparent),
        radial-gradient(1px 1px at 130px 80px, var(--arcane-gold), transparent),
        radial-gradient(2px 2px at 160px 30px, var(--arcane-purple), transparent),
        radial-gradient(1px 1px at 200px 60px, var(--arcane-green), transparent),
        radial-gradient(2px 2px at 240px 20px, var(--arcane-gold), transparent),
        radial-gradient(1px 1px at 280px 70px, var(--arcane-purple), transparent),
        radial-gradient(2px 2px at 320px 40px, var(--arcane-green), transparent),
        radial-gradient(1px 1px at 360px 80px, var(--arcane-gold), transparent),
        radial-gradient(2px 2px at 400px 30px, var(--arcane-purple), transparent),
        radial-gradient(1px 1px at 440px 60px, var(--arcane-green), transparent),
        radial-gradient(2px 2px at 480px 20px, var(--arcane-gold), transparent),
        radial-gradient(1px 1px at 520px 70px, var(--arcane-purple), transparent),
        radial-gradient(2px 2px at 560px 40px, var(--arcane-green), transparent),
        radial-gradient(1px 1px at 600px 80px, var(--arcane-gold), transparent),
        radial-gradient(2px 2px at 640px 30px, var(--arcane-purple), transparent),
        radial-gradient(1px 1px at 680px 60px, var(--arcane-green), transparent),
        radial-gradient(2px 2px at 720px 20px, var(--arcane-gold), transparent),
        radial-gradient(1px 1px at 760px 70px, var(--arcane-purple), transparent),
        radial-gradient(2px 2px at 800px 40px, var(--arcane-green), transparent),
        radial-gradient(1px 1px at 840px 80px, var(--arcane-gold), transparent),
        radial-gradient(2px 2px at 880px 30px, var(--arcane-purple), transparent),
        radial-gradient(1px 1px at 920px 60px, var(--arcane-green), transparent),
        radial-gradient(2px 2px at 960px 20px, var(--arcane-gold), transparent),
        radial-gradient(1px 1px at 1000px 70px, var(--arcane-purple), transparent),
        radial-gradient(2px 2px at 1040px 40px, var(--arcane-green), transparent),
        radial-gradient(1px 1px at 1080px 80px, var(--arcane-gold), transparent),
        radial-gradient(2px 2px at 1120px 30px, var(--arcane-purple), transparent),
        radial-gradient(1px 1px at 1160px 60px, var(--arcane-green), transparent),
        radial-gradient(2px 2px at 1200px 20px, var(--arcane-gold), transparent);
    background-size: 1200px 100px;
    opacity: 0.15;
    animation: constellationDrift 120s linear infinite;
    pointer-events: none;
    z-index: 0;
}

.magic-mode::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(1px 1px at 50px 50px, var(--arcane-gold), transparent),
        radial-gradient(1px 1px at 150px 150px, var(--arcane-purple), transparent),
        radial-gradient(1px 1px at 250px 100px, var(--arcane-green), transparent),
        radial-gradient(1px 1px at 350px 200px, var(--arcane-gold), transparent),
        radial-gradient(1px 1px at 450px 80px, var(--arcane-purple), transparent),
        radial-gradient(1px 1px at 550px 180px, var(--arcane-green), transparent),
        radial-gradient(1px 1px at 650px 120px, var(--arcane-gold), transparent),
        radial-gradient(1px 1px at 750px 220px, var(--arcane-purple), transparent),
        radial-gradient(1px 1px at 850px 60px, var(--arcane-green), transparent),
        radial-gradient(1px 1px at 950px 160px, var(--arcane-gold), transparent),
        radial-gradient(1px 1px at 1050px 140px, var(--arcane-purple), transparent),
        radial-gradient(1px 1px at 1150px 240px, var(--arcane-green), transparent);
    background-size: 1200px 300px;
    opacity: 0.08;
    animation: constellationDrift 180s linear infinite reverse;
    pointer-events: none;
    z-index: 0;
}

@keyframes constellationDrift {
    from { transform: translateX(0) translateY(0); }
    to { transform: translateX(-1200px) translateY(-100px); }
}

/* 🌠 Particle Wisps of Energy */
.arcane-spark {
    position: fixed;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--arcane-gold), var(--arcane-purple));
    opacity: 0.5;
    animation: floatSpark 8s linear;
    pointer-events: none;
    z-index: 1;
}

@keyframes floatSpark {
    from { transform: translateY(0); opacity: 0.7; }
    to { transform: translateY(-100px) scale(1.5); opacity: 0; }
}

/* 🧩 Glowing Borders and Pulsing Buttons */
.magic-mode button {
    border: 1px solid rgba(117, 106, 162, 0.6);
    background: linear-gradient(90deg, var(--arcane-purple), var(--arcane-gold));
    color: white;
    box-shadow: 0 0 8px var(--arcane-shadow), inset 0 0 8px var(--arcane-glow);
    text-shadow: 0 0 4px var(--arcane-gold);
    animation: glowPulse 3s infinite alternate ease-in-out;
    position: relative;
    overflow: hidden;
}

.magic-mode button::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes glowPulse {
    0% { box-shadow: 0 0 8px var(--arcane-shadow); }
    100% { box-shadow: 0 0 20px var(--arcane-glow); }
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* 🌀 Animated Text Glyphs / Glimmer Runewords */
.magic-mode h1, 
.magic-mode h2, 
.magic-mode h3 {
    background: linear-gradient(90deg, var(--arcane-gold), var(--arcane-purple), var(--arcane-green), var(--arcane-gold));
    background-size: 300% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: textShimmer 5s linear infinite;
    text-shadow: 0 0 10px var(--arcane-glow);
}

@keyframes textShimmer {
    to { background-position: 300% center; }
}

/* 🌈 Arcane Cursor Trail */
.wisp {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--arcane-green), transparent);
    pointer-events: none;
    opacity: 0.6;
    animation: fadeWisp 1s ease-out;
    z-index: 9999;
}

@keyframes fadeWisp {
    from { transform: scale(1); opacity: 0.6; }
    to { transform: scale(3); opacity: 0; }
}

/* Arcane Achievement Toast */
.arcane-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--arcane-purple), var(--arcane-gold));
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 8px 25px var(--arcane-shadow);
    z-index: 10001;
    animation: toastAppear 0.5s ease-out, toastDisappear 0.5s ease-in 2.5s forwards;
    text-align: center;
    font-weight: bold;
}

@keyframes toastAppear {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastDisappear {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* Theme-specific WCAG compliant colors */
:root {
    /* Shared colors - work well in both themes */
    --color-issue: #3B82F6;  /* 5.2:1 light, 5.9:1 dark - perfect in both */
    --focus-ring: #7C3AED;    /* Strong indigo for focus states */
}

[data-theme="light"] {
    /* Light theme - systematic tonal hierarchy */
    --bg-page: #F9FAFB;        /* Neutral base */
    --bg-card: #F3F6FB;        /* Primary surface (+8% luminance) */
    --bg-filter: #E9EEF6;      /* Nested context (+4% luminance) */
    --border-accent: #C5B3F8;  /* Visual separation */
    --hover-accent: rgba(147,51,234,0.1); /* Subtle glow, not tone shift */
    
    /* Vibrant accent colors for light mode */
    --color-action: #B45309;   /* 5.3:1 contrast vs #F8FAFC */
    --color-advice: #0284C7;   /* 5.5:1 contrast vs #F8FAFC */
    --color-rule: #7C3AED;     /* 4.9:1 contrast vs #F8FAFC */
    --focus-ring: #7C3AED;     /* 5.1:1 contrast vs #F8FAFC */
    
    /* Legacy variables for compatibility */
    --accent-action: #B45309;
    --accent-advice: #0284C7;
    --accent-purple: #7C3AED;
}

[data-theme="dark"] {
    /* Dark theme - systematic tonal hierarchy */
    --bg-page: #0F172A;        /* Deep slate base */
    --bg-card: #1E293B;        /* Primary surface */
    --bg-filter: #2A3441;      /* Lighter still - subtle, non-competing */
    --border-accent: rgba(147, 51, 234, 0.25); /* Reduced strength */
    --hover-accent: rgba(147, 51, 234, 0.07); /* Soft glow */
    
    /* Vibrant accent colors for dark mode */
    --color-action: #F59E0B;   /* Golden warmth - brighter orange */
    --color-advice: #38BDF8;   /* Bright cyan - matches blue energy */
    --color-rule: #C084FC;     /* Luminous purple */
    --color-issue: #60A5FA;    /* Brighter blue pop */
    --focus-ring: #C084FC;     /* Focus ring color */
    
    /* Text contrast ladder */
    --text-heading: #FFFFFF;   /* Pure white headings */
    --text-body: #E2E8F0;       /* Slate-200 body text */
    --text-muted: #94A3B8;      /* Slate-400 muted labels */
    
    /* Legacy variables for compatibility */
    --accent-action: #F59E0B;
    --accent-advice: #38BDF8;
    --accent-purple: #C084FC;
}

/* Summary cards with inline icons */
.magic-summary-card {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 20px;
    position: relative;
    text-align: center;
    box-shadow: 0 2px 4px var(--shadow);
}

.magic-summary-card .count {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.magic-summary-card .label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.magic-summary-card .icon {
    font-size: 1rem;
}

/* Accent colors for icons and borders */
.magic-summary-card.action .icon { 
    color: var(--accent-action); 
}

.magic-summary-card.advice .icon { 
    color: var(--accent-advice); 
}

.magic-summary-card.action { 
    border-bottom: 2px solid var(--accent-action); 
}

.magic-summary-card.advice { 
    border-bottom: 2px solid var(--accent-advice); 
}

.summary-number,
.summary-number-blue,
.summary-number-purple,
.summary-number-orange {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.summary-number-blue { color: var(--color-issue); }   /* Perfect in both themes */
.summary-number-purple { color: var(--color-rule); }  /* Theme-specific WCAG compliant */
.summary-number-orange { color: var(--color-action); } /* Theme-specific WCAG compliant */

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

.summary-filename-section {
    text-align: center;
    margin-bottom: 25px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 2px solid #e2e8f0;
}

.summary-filename {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.summary-filename-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.severity-section {
    margin-top: 20px;
}

.severity-section h5 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.severity-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.severity-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    font-size: 0.9rem;
}

.severity-count {
    font-weight: 600;
    color: #1e293b;
}

.severity-name {
    color: #64748b;
    text-transform: capitalize;
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Findings */
.findings {
    margin-top: 0;  /* Remove gap - controls sit directly on top */
}

/* Light mode file group row (unchanged) */
[data-theme="light"] .file-group,
:not([data-theme]) .file-group {
    background: #f9fafb;
    border: 1px solid #e2e8f0;
}

/* Dark mode file group row */
[data-theme="dark"] .file-group {
    background: #1e293b;   /* dark slate, matches your cards */
    border: 1px solid #334155;
}

/* Ensure key text stays readable in dark headers */
[data-theme="dark"] .file-header,
[data-theme="dark"] .file-name,
[data-theme="dark"] .file-path {
  color: #f1f5f9;
}

.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: background 0.2s ease;
}

.file-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0; /* Allow flex item to shrink */
}

.file-info {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Allow flex item to shrink */
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-path {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.file-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0; /* Don't shrink the right side */
}

.file-count-badge {
    background: #3b82f6;
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.severity-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.severity-count-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.severity-count-badge.action {
    background: #ea580c;
    color: #ffffff;
    border: 2px solid #c2410c;
    border-style: solid;
    font-weight: 700;
}

.severity-count-badge.action::before {
    content: "■";
    font-size: 0.9em;
}

.severity-count-badge.advice {
    background: #756AA2;
    color: #ffffff;
    border: 2px dashed #6B5E94;
    font-weight: 700;
}

.severity-count-badge.advice::before {
    content: "◆";
    font-size: 0.9em;
}

/* Theme-specific severity badge colors */
[data-theme="dark"] .severity-count-badge.action {
    background: #f97316;
    color: #ffffff;
    border: 2px solid #fb923c;
}

[data-theme="dark"] .severity-count-badge.advice {
    background: #9F7AEA;
    color: #ffffff;
    border: 2px dashed #B794F4;
}

.file-findings {
    padding: 0 20px 20px;
    background: var(--bg-secondary);
}

.finding {
    padding: 15px 0;
    border-bottom: 1px solid var(--border-light);
}

.finding:last-child {
    border-bottom: none;
}

.finding-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.finding-details {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-left: 30px;
}

.finding-snippet {
    position: relative; /* anchor for offsetTop measurement in scroll-to-highlight */
    margin: 8px 0 4px 30px;
    border-radius: 6px;
    max-height: 220px;
    overflow: auto;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    transition: border-color 0.2s;
    /* Hide scrollbar by default, show on hover */
    scrollbar-width: none; /* Firefox */
}

.finding-snippet::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Edge */
}

.finding-snippet:hover {
    border-color: var(--text-secondary);
    scrollbar-width: thin; /* Firefox: show on hover */
}

.finding-snippet:hover::-webkit-scrollbar {
    display: block;
    width: 6px;
}

.finding-snippet:hover::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

.finding-snippet:hover::-webkit-scrollbar-track {
    background: transparent;
}

.finding-snippet pre {
    margin: 0;
    padding: 8px 0;
    font-size: 0.8rem;
    line-height: 1.5;
    background: transparent;
}

.finding-snippet code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background: transparent;
}

.snippet-line {
    display: block;
    padding: 0 12px 0 0;
    white-space: pre;
}

.snippet-lineno {
    display: inline-block;
    width: 3.5em;
    text-align: right;
    padding-right: 1em;
    color: var(--text-secondary);
    opacity: 0.5;
    user-select: none;
    border-right: 1px solid var(--border-color);
    margin-right: 1em;
}

.snippet-highlight {
    background: rgba(255, 220, 100, 0.2);
    border-left: 3px solid #f59e0b;
}

.snippet-highlight .snippet-lineno {
    opacity: 0.8;
    color: #f59e0b;
}

[data-theme="dark"] .snippet-highlight {
    background: rgba(255, 220, 100, 0.08);
}

/* Inline AI Explanation (per-finding)
   Visually distinct from deterministic findings above —
   dashed border, tinted background, AI label, subtle shadow */
.finding-explanation {
    margin: 10px 0 4px 30px;
    padding: 10px 14px 10px 12px;
    border: 1px dashed var(--arcane-purple);
    border-left: 3px solid var(--arcane-purple);
    background: linear-gradient(135deg, var(--arcane-glow) 0%, transparent 100%);
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
    box-shadow: 0 1px 4px rgba(117, 106, 162, 0.15);
    position: relative;
}

.finding-explanation.action {
    border-color: #b91c1c;
    border-left-color: #dc2626;
    background: linear-gradient(135deg, rgba(185, 28, 28, 0.08) 0%, transparent 100%);
    box-shadow: 0 1px 4px rgba(185, 28, 28, 0.12);
}

[data-theme="dark"] .finding-explanation {
    box-shadow: 0 1px 6px rgba(159, 122, 234, 0.2);
}

[data-theme="dark"] .finding-explanation.action {
    border-color: rgba(239, 68, 68, 0.5);
    border-left-color: #ef4444;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, transparent 100%);
    box-shadow: 0 1px 6px rgba(239, 68, 68, 0.2);
}

/* "AI" label in top-right corner */
.finding-explanation-ai-label {
    position: absolute;
    top: -1px;
    right: -1px;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 8px;
    background: var(--arcane-purple);
    color: #fff;
    border-radius: 0 8px 0 6px;
    letter-spacing: 0.08em;
    opacity: 0.85;
}

.finding-explanation.action .finding-explanation-ai-label {
    background: #b91c1c;
}

[data-theme="dark"] .finding-explanation.action .finding-explanation-ai-label {
    background: #dc2626;
}

.finding-explanation-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.finding-explanation-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.finding-explanation-badge.action {
    background: #dc2626;
    color: #fff;
}

.finding-explanation-badge.advice {
    background: #d97706;
    color: #fff;
}

[data-theme="dark"] .finding-explanation-badge.action {
    background: #ef4444;
}

[data-theme="dark"] .finding-explanation-badge.advice {
    background: #f59e0b;
    color: #1a1a1a;
}

.finding-explanation-text {
    margin: 0 0 4px 0;
}

.finding-explanation-suggestion {
    margin: 4px 0 0 0;
    color: var(--text-primary);
    font-style: italic;
}

/* AI loading pill — mirrors .theme-toggle-fixed on the left */
.ai-loading-fab {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
}

.ai-loading-fab .btn {
    background: rgba(255, 255, 255, 0.95);
    color: #1e293b;
    border: 2px solid var(--accent);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 12px 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    font-weight: 600;
    cursor: default;
    opacity: 1;
}

[data-theme="dark"] .ai-loading-fab .btn {
    background: rgba(30, 41, 59, 0.95);
    color: #f1f5f9;
    border: 2px solid var(--accent);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4), 0 0 30px rgba(124, 58, 237, 0.2);
}

/* Crystal ball — inline icon size inside the pill */
.crystal-ball {
    position: relative;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.crystal-ball-inner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #c4b5fd 0%, #7c3aed 40%, #4c1d95 80%, #2e1065 100%);
    position: relative;
    overflow: hidden;
    box-shadow:
        0 0 6px rgba(124, 58, 237, 0.5),
        0 0 12px rgba(124, 58, 237, 0.25),
        inset 0 0 4px rgba(196, 181, 253, 0.3);
    animation: orb-pulse 3s ease-in-out infinite;
}

/* Swirling wisps inside the orb */
.crystal-ball-wisp {
    position: absolute;
    border-radius: 50%;
    filter: blur(1.5px);
    opacity: 0.6;
}

.wisp-1 {
    width: 8px;
    height: 5px;
    background: radial-gradient(ellipse, rgba(196, 181, 253, 0.8), transparent);
    top: 3px;
    left: 2px;
    animation: wisp-drift-1 2.5s ease-in-out infinite;
}

.wisp-2 {
    width: 5px;
    height: 5px;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.7), transparent);
    top: 7px;
    left: 8px;
    animation: wisp-drift-2 3.2s ease-in-out infinite;
}

.wisp-3 {
    width: 6px;
    height: 4px;
    background: radial-gradient(ellipse, rgba(221, 214, 254, 0.6), transparent);
    top: 10px;
    left: 3px;
    animation: wisp-drift-3 2.8s ease-in-out infinite;
}

@keyframes wisp-drift-1 {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.5; }
    33% { transform: translate(4px, 3px) scale(1.3); opacity: 0.8; }
    66% { transform: translate(1px, -1px) scale(0.8); opacity: 0.4; }
}

@keyframes wisp-drift-2 {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.4; }
    50% { transform: translate(-4px, -2px) scale(1.4); opacity: 0.7; }
}

@keyframes wisp-drift-3 {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.5; }
    40% { transform: translate(4px, -3px) scale(1.2); opacity: 0.7; }
    80% { transform: translate(-1px, 1px) scale(0.9); opacity: 0.3; }
}

/* Glass highlight */
.crystal-ball-shine {
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 3px;
    background: radial-gradient(ellipse, rgba(255, 255, 255, 0.55), transparent);
    border-radius: 50%;
    pointer-events: none;
}

@keyframes orb-pulse {
    0%, 100% { box-shadow: 0 0 6px rgba(124, 58, 237, 0.5), 0 0 12px rgba(124, 58, 237, 0.25), inset 0 0 4px rgba(196, 181, 253, 0.3); }
    50% { box-shadow: 0 0 10px rgba(124, 58, 237, 0.7), 0 0 20px rgba(124, 58, 237, 0.35), inset 0 0 6px rgba(196, 181, 253, 0.5); }
}

#ai-loading-text {
    font-size: 0.85rem;
}

.no-issues {
    text-align: center;
    padding: 60px 40px;
    background: #f0fdf4;
    border-radius: 8px;
    color: #16a34a;
    font-size: 1.1rem;
}

/* Light mode hover effects */
[data-theme="light"] .config-option:hover,
:not([data-theme]) .config-option:hover {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.25);
}

/* Light-mode hover */
[data-theme="light"] .file-header:hover,
:not([data-theme]) .file-header:hover {
  background-color: #f9fafb;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

[data-theme="light"] {
    --bg-tertiary: #f0f4f8; /* improved separation only in light mode */
}

/* Dark-mode header base & hover */
[data-theme="dark"] .file-header {
  background: var(--bg-tertiary);           /* #334155 from your tokens */
}

[data-theme="dark"] .file-header:hover {
  background: #2a3647;                      /* subtle lift, still dark */
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
  transform: translateY(-2px);
}

/* Dark-mode collapsed group header: ensure it never goes light */
[data-theme="dark"] .file-group.collapsed .file-header {
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  color: #e5e7eb;
}

/* === Dark Mode File Group Borders Enhancements === */
[data-theme="dark"] .file-group,
[data-theme="dark"] .file-header {
border: 1px solid #475569; /* medium slate border for contrast */
border-radius: 6px;
}

[data-theme="dark"] .file-group + .file-group {
margin-top: 4px;
}

[data-theme="dark"] .file-group:hover {
border-color: #818cf8; /* indigo hover accent */
box-shadow: 0 2px 6px rgba(129, 140, 248, 0.25);
}  

/* Dark mode hover for config blocks */
[data-theme="dark"] .config-option:hover {
    border-color: #818cf8;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    box-shadow: 0 4px 15px rgba(129, 140, 248, 0.3);
}

/* Dark mode hover text colors */
[data-theme="dark"] .config-option:hover .config-name {
    color: #ffffff;
}

[data-theme="dark"] .config-option:hover .config-description {
    color: #e2e8f0;
}

[data-theme="dark"] .config-option:hover .config-meta {
    color: #f1f5f9;
}

[data-theme="dark"] .config-option:hover .config-rules-count {
    background: rgba(129, 140, 248, 0.2);
    color: #f1f5f9;
}

[data-theme="dark"] .config-option:hover .config-performance {
    color: #f1f5f9;
}


/* === Color-blind friendly cues === */
.config-performance.fast::before {
    content: "⚡ ";
}

.config-performance.balanced::before {
    content: "⚖️ ";
}

.config-performance.thorough::before {
    content: "🔍 ";
}

/* === Reduced motion support === */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}

/* ===  High contrast mode support (Windows / system setting) === */
@media (forced-colors: active) {
    .btn, .config-option, .file-group, .upload-area, .results-section, header {
        border: 1px solid CanvasText;
    }
    .btn { background: ButtonFace; color: ButtonText; }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .results-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .results-actions {
        justify-content: center;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .file-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .file-header-left {
        flex: none;
    }
    
    .file-header-right {
        justify-content: space-between;
        flex-wrap: wrap;
    }
    
    .file-count-badge {
        order: -1; /* Show total count first on mobile */
    }
    
    /* Adjust theme toggle for mobile */
    .theme-toggle-fixed {
        bottom: 15px;
        right: 15px;
    }
    
    .theme-toggle-fixed .btn {
        padding: 10px 14px;
        font-size: 0.9rem;
        font-weight: 600;
        border-width: 2px;
    }

    /* Adjust AI loading pill for mobile */
    .ai-loading-fab {
        bottom: 15px;
        left: 15px;
    }

    .ai-loading-fab .btn {
        padding: 10px 14px;
        font-size: 0.9rem;
        font-weight: 600;
        border-width: 2px;
    }
}

/* Arcane Control Bar - Theme-Specific WCAG 2.2 AA Compliant Palette
 * 
 * Light Theme Contrast Ratios vs #F8FAFC background:
 * - Blue (#3B82F6): 5.2:1 ✅ Pass (AA+AAA)
 * - Purple (#7C3AED): 4.9:1 ✅ Pass (AA)
 * - Orange (#B45309): 5.3:1 ✅ Pass (AA+AAA)
 * - Cyan (#0284C7): 5.5:1 ✅ Pass (AA+AAA)
 * 
 * Dark Theme Contrast Ratios vs #1E293B background:
 * - Blue (#3B82F6): 5.9:1 ✅ Pass (AA+AAA)
 * - Purple (#C084FC): 4.5:1 ✅ Pass (AA)
 * - Orange (#EAB308): 4.8:1 ✅ Pass (AA)
 * - Cyan (#38BDF8): 5.7:1 ✅ Pass (AA+AAA)
 */
.filter-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--bg-filter);
    border: 1px solid var(--border-accent);
    border-radius: 12px;
    margin: auto auto 20px auto;
    backdrop-filter: blur(15px);
    transition: box-shadow 0.2s ease;
}

.filter-bar:hover {
    box-shadow: 0 0 8px var(--hover-accent);
    transform: translateY(-1px);
}


/* Nested Filters - Clean, Subtle Design (now inline) */

.findings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;          /* No gap at all */
    padding-bottom: 0.5rem;     /* Just enough for the border */
    border-bottom: 1px solid var(--border-subtle);
    margin-top: 1.25rem;       /* Add spacing from summary section */
}

.expand-collapse-buttons {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0; /* Prevent shrinking */
    margin-top: 0.75rem;        /* Separate from summary */
    margin-bottom: 0.75rem;     /* Space before filters */
}

.expand-collapse-buttons::after {
    content: "";
    display: block;
    border-top: 1px solid rgba(255,255,255,0.08); /* Subtle divider */
    margin-top: 0.75rem;
}

.filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0; /* Prevent shrinking */
}

.filter-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 0;
}

.micro-label {
    text-transform: uppercase;
    font-size: 0.7rem;         /* 11px - dev tools style */
    font-weight: 600;
    letter-spacing: 0.03em;     /* Tighter letter spacing */
    margin-bottom: 2px;
    text-align: center;
    white-space: nowrap;
    color: #F8FAFC;             /* Off-white like the summary cards */
}

/* Light theme micro-label - high contrast */
[data-theme="light"] .micro-label {
    color: #374151;            /* slate-700 - better contrast on light bg */
}

/* Button hover improvements for better accessibility */
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid var(--color-rule);
}

/* Dark theme micro-label - improved contrast */
[data-theme="dark"] .micro-label {
    color: #C7D2FE;             /* Better contrast - indigo-200 */
}

.filter-group select {
    padding: 0.35rem 0.75rem;  /* Compact dev tools style */
    border: 1px solid rgba(255, 255, 255, 0.15); /* Better contrast */
    border-radius: 6px;
    background-color: #1E293B;  /* Dark theme default */
    color: #CBD5E1;             /* Softer white text */
    font-size: 0.85rem;
    min-width: 100px;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.filter-group select:hover {
    border-color: var(--color-rule);
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.2);
    background: rgba(240,245,255,0.95);
    transform: translateY(-1px);
}

.filter-group select:focus {
    outline: 2px solid #C084FC;  /* Solid purple border instead of glow */
    outline-offset: 2px;
    border-color: var(--color-rule);
    background: rgba(240,245,255,0.98);
}

.filter-group select option {
    background: rgba(240,245,255,0.98);
    color: #374151;
    padding: 8px 12px;
}

.filter-group select option:hover,
.filter-group select option:focus {
    background-color: #EDE9FE;  /* indigo-100 for light theme */
    color: #1E1B4B;
}

/* Dark theme select elements with proper contrast */
[data-theme="dark"] .filter-group select {
    background-color: #1B2433;  /* Darker than filter panel for clarity */
    color: #F1F5F9;             /* Light neutral text */
    border: 1px solid rgba(147,51,234,0.3);
}

[data-theme="dark"] .filter-group select:hover {
    background-color: #222C3E;  /* Slight lift for feedback */
    border-color: rgba(167,139,250,0.8);
    box-shadow: 0 0 4px rgba(147,51,234,0.3);
}

[data-theme="dark"] .filter-group select:focus {
    background-color: #222C3E;  /* Slight lift for feedback */
    border-color: rgba(167,139,250,0.8);
    box-shadow: 0 0 4px rgba(147,51,234,0.3);
    outline: 2px solid #C084FC;  /* Solid purple border instead of glow */
    outline-offset: 2px;
}

[data-theme="dark"] .filter-group select option {
    background-color: #1B2433;
    color: #F1F5F9;
}

[data-theme="dark"] .filter-group select option:hover,
[data-theme="dark"] .filter-group select option:focus {
    background-color: #222C3E;
    color: var(--text-heading);
}

[data-theme="dark"] .filter-group select option:disabled {
    color: #64748B;             /* Mid-gray, still readable on dark background */
}

/* Light theme select elements */
[data-theme="light"] .filter-group select {
    background-color: #F8FAFC;  /* Light background */
    color: #1E293B;             /* Dark text */
    border: 1px solid rgba(0, 0, 0, 0.15); /* Better contrast */
}

[data-theme="light"] .filter-group select:hover {
    border-color: var(--color-rule);
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.2);
    background-color: #F1F5F9;
}

[data-theme="light"] .filter-group select:focus {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
    border-color: var(--color-rule);
    background-color: #F1F5F9;
}

[data-theme="light"] .filter-group select option {
    background-color: #F8FAFC;
    color: #1E293B;
}

[data-theme="light"] .filter-group select option:hover,
[data-theme="light"] .filter-group select option:focus {
    background-color: #EDE9FE;
    color: #1E1B4B;
}

/* Light theme filter bar with proper luminance separation */
[data-theme="light"] .filter-bar {
    background: #E8EEF5;        /* Cooler, darker than page background */
    border: 1px solid #E2E8F0;   /* Subtle border for definition */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); /* Soft shadow for depth */
}

[data-theme="light"] .filter-bar:hover {
    border-color: var(--color-rule);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.15);
}


[data-theme="light"] .divider {
    background: linear-gradient(to bottom, transparent, var(--color-rule), transparent);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .filter-bar {
        padding: 1rem 1.5rem;
    }
    
    .filter-row {
        flex-direction: column;
        gap: 1rem;
    }
    
    .divider {
        width: 100%;
        height: 1px;
        background: linear-gradient(to right, transparent, var(--color-rule), transparent);
    }
    
    .filter-group select {
        min-width: 140px;
    }
}

/* Context Impact Styles */
.context-impact {
    margin: 16px 0;
    padding: 16px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border-left: 4px solid #dc2626; /* Red border for not invoked */
}

.context-impact-partial {
    border-left: 4px solid #eab308; /* Yellow border for partially invoked */
    background: rgba(234, 179, 8, 0.05); /* Subtle yellow background */
}

.context-impact h4 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.context-impact-subtitle {
    margin: 0 0 12px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.context-impact-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.context-impact-item {
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.context-impact-item strong {
    color: var(--text-primary);
    margin-right: 8px;
}

.context-impact-item span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Context Config Styles */
.context-config {
    margin: 16px 0;
    padding: 16px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border-left: 4px solid var(--color-rule);
}

.context-config h4 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.context-config-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

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

.config-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

/* Context Files Styles */
.context-files {
    margin: 16px 0;
    padding: 16px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border-left: 4px solid var(--color-rule);
}

.context-files h4 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.context-files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.context-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

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

.file-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

/* Configuration Breakdown Modal Styles */
#config-breakdown-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: 12px 12px 0 0;
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

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

.modal-body {
    padding: 24px;
}

.config-breakdown-section {
    margin-bottom: 24px;
}

.config-breakdown-section:last-child {
    margin-bottom: 0;
}

.config-breakdown-section h4 {
    margin: 0 0 16px 0;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.config-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.summary-card {
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.summary-card.enabled {
    border-left: 4px solid #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.summary-card.disabled {
    border-left: 4px solid #64748b;
    background: rgba(100, 116, 139, 0.05);
}

/* Light mode disabled summary cards - orange theme */
[data-theme="light"] .summary-card.disabled {
    border-left: 4px solid #ea580c;
    background: rgba(251, 146, 60, 0.05);
}

.summary-card.total {
    border-left: 4px solid #64748b;
    background: rgba(100, 116, 139, 0.05);
}

.summary-number {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 4px;
}

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

.rule-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
}

.rule-item {
    padding: 16px;
    padding-bottom: 2.5rem; /* space for bottom badges */
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.rule-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.rule-item.enabled {
    border-left: 4px solid #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.rule-item.disabled {
    border-left: 4px solid #64748b;
    background: rgba(100, 116, 139, 0.05);
}

/* Light mode disabled rule items - orange theme */
[data-theme="light"] .rule-item.disabled {
    border-left: 4px solid #ea580c;
    background: rgba(251, 146, 60, 0.05);
}

.rule-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 12px;
    flex-wrap: wrap;
}

.rule-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.rule-status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Prevent rule status badges from overlapping config settings */
.rule-item .rule-status-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
}

.rule-status-badge.enabled {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.rule-status-badge.disabled {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
    border: 1px solid rgba(100, 116, 139, 0.2);
}

/* Light mode disabled badges - orange theme */
[data-theme="light"] .rule-status-badge.disabled {
    background: rgba(251, 146, 60, 0.1);
    color: #ea580c;
    border: 1px solid rgba(251, 146, 60, 0.2);
}

.rule-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 8px;
}

/* Ensure disabled rules have the same text color as enabled rules */
.rule-item.disabled .rule-name {
    color: var(--text-primary);
}

.rule-item.disabled .rule-description {
    color: var(--text-secondary);
}

.rule-settings {
    margin-top: 12px;
    margin-bottom: 20px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

/* All badges should be positioned in the bottom corner */
.rule-item .rule-status-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
}

.settings-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 8px;
}

.settings-json {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Responsive adjustments for modal */
@media (max-width: 1024px) {
    .rule-breakdown {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

@media (max-width: 768px) {
    #config-breakdown-modal {
        padding: 10px;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 16px 20px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .config-summary-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .rule-breakdown {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .rule-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .rule-name {
        flex: none;
        width: 100%;
        margin-bottom: 4px;
    }
    
    .rule-status-badge {
        align-self: flex-start;
    }
}

/* ── AI Explanation Section ───────────────────────────── */

.explain-section {
    margin-top: 24px;
}

.explain-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px var(--shadow);
}

.explain-header h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
}

.explain-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 0;
    color: var(--text-secondary);
}

.explain-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    color: #ef4444;
}

.explain-content {
    line-height: 1.7;
    color: var(--text-primary);
}

.explain-content h1,
.explain-content h2,
.explain-content h3,
.explain-content h4 {
    margin-top: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.explain-content h1 { font-size: 1.5em; }
.explain-content h2 { font-size: 1.3em; }
.explain-content h3 { font-size: 1.15em; }
.explain-content h4 { font-size: 1.05em; }

.explain-content p {
    margin-bottom: 10px;
}

.explain-content ul,
.explain-content ol {
    margin: 8px 0 12px 20px;
}

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

.explain-content li.md-depth-1 {
    margin-left: 20px;
}

.explain-content li.md-depth-2 {
    margin-left: 40px;
}

.explain-content code {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.9em;
    font-family: 'Courier New', monospace;
}

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

.explain-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.85em;
}

.explain-content strong {
    color: var(--text-primary);
}

.explain-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

.explain-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.95em;
}

.explain-content th,
.explain-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.explain-content th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.explain-content tr:nth-child(even) {
    background: var(--bg-tertiary);
}

.explain-content tr:hover {
    background: var(--arcane-glow);
}

/* Explain cards — matches file-group hover pattern */
.explain-card {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.explain-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--shadow-hover);
}

[data-theme="light"] .explain-card:hover,
:not([data-theme]) .explain-card:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .explain-card {
    background: #1e293b;
    border-color: #475569;
}

[data-theme="dark"] .explain-card:hover {
    background: #2a3647;
    border-color: #818cf8;
    box-shadow: 0 2px 6px rgba(129, 140, 248, 0.25);
}

.explain-card-summary {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .explain-card-summary {
    background: #253447;
}

/* Card heading — remove top margin for first heading in card */
.explain-card > h1:first-child,
.explain-card > h2:first-child,
.explain-card > h3:first-child,
.explain-card > h4:first-child {
    margin-top: 0;
}

/* Copy button */
.explain-copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.8em;
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.15s ease, color 0.15s ease;
    opacity: 0;
    z-index: 1;
}

.explain-card:hover .explain-copy-btn {
    opacity: 1;
}

.explain-copy-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--arcane-purple);
}

[data-theme="dark"] .explain-copy-btn {
    background: #334155;
    border-color: #475569;
}

[data-theme="dark"] .explain-copy-btn:hover {
    background: #475569;
    color: #f1f5f9;
}

.explain-content blockquote {
    border-left: 3px solid var(--arcane-purple);
    padding: 8px 16px;
    margin: 8px 0;
    color: var(--text-secondary);
    background: var(--arcane-glow);
    border-radius: 0 6px 6px 0;
}