/* ============================================================================
   CNA Study RAG - Styles
   Healthcare-focused design system for CNA exam preparation
   ============================================================================ */

/* ============================================================================
   Design Tokens & CSS Variables
   ============================================================================ */
:root {
    /* Healthcare Colors */
    --primary: #059669;
    --primary-light: #10b981;
    --primary-dark: #047857;
    --primary-surface: rgba(5, 150, 105, 0.08);
    
    --accent: #0891b2;
    --accent-light: #22d3ee;
    --accent-surface: rgba(8, 145, 178, 0.08);
    
    /* Neutral Colors */
    --surface: #ffffff;
    --surface-dim: #f8fafc;
    --surface-container: #f1f5f9;
    --surface-variant: #e2e8f0;
    
    --on-surface: #1e293b;
    --on-surface-variant: #475569;
    --on-surface-muted: #94a3b8;
    
    --outline: #e2e8f0;
    --outline-variant: #cbd5e1;
    
    /* Semantic Colors */
    --success: #22c55e;
    --success-surface: rgba(34, 197, 94, 0.1);
    --warning: #f59e0b;
    --warning-surface: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-surface: rgba(239, 68, 68, 0.1);
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Merriweather', 'Georgia', serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --duration-micro: 100ms;
    --duration-fast: 150ms;
    --duration-base: 200ms;
    --duration-slow: 300ms;
    --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Dark Mode */
[data-theme="dark"] {
    --primary: #10b981;
    --primary-light: #34d399;
    --primary-dark: #059669;
    --primary-surface: rgba(16, 185, 129, 0.12);
    
    --accent: #22d3ee;
    --accent-light: #67e8f9;
    --accent-surface: rgba(34, 211, 238, 0.12);
    
    --surface: #0f172a;
    --surface-dim: #1e293b;
    --surface-container: #334155;
    --surface-variant: #475569;
    
    --on-surface: #f1f5f9;
    --on-surface-variant: #cbd5e1;
    --on-surface-muted: #64748b;
    
    --outline: #334155;
    --outline-variant: #475569;
    
    --success-surface: rgba(34, 197, 94, 0.15);
    --warning-surface: rgba(245, 158, 11, 0.15);
    --error-surface: rgba(239, 68, 68, 0.15);
}

/* ============================================================================
   Base Styles
   ============================================================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--on-surface);
    background: var(--surface-dim);
    min-height: 100vh;
    transition: background-color var(--duration-base) var(--ease-out);
}

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

.main-content {
    flex: 1;
    max-width: 1200px; /* Increased from 900px */
    width: 100%;
    margin: 0 auto;
    padding: var(--space-6) var(--space-4); /* Increased vertical padding */
}

/* ============================================================================
   Header
   ============================================================================ */
.app-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--accent) 100%);
    padding: var(--space-8) var(--space-4); /* Increased padding */
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
    position: relative;
}

.logo-icon {
    font-size: 2.5rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
    position: relative;
}

.header-controls {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    display: flex;
    gap: var(--space-2);
}

.theme-toggle,
.bookmarks-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.theme-toggle:hover,
.bookmarks-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.theme-toggle svg,
.bookmarks-toggle svg {
    width: 20px;
    height: 20px;
}

.bookmarks-toggle .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================================
   Search Section
   ============================================================================ */
.search-section {
    background: var(--surface);
    border-radius: var(--radius-2xl);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-lg);
}

.search-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: var(--space-4);
    color: var(--on-surface-muted);
    pointer-events: none;
    width: 20px;
    height: 20px;
    transition: color var(--duration-fast) var(--ease-out);
}

.search-input {
    width: 100%;
    padding: var(--space-4) var(--space-4) var(--space-4) calc(var(--space-4) + 28px);
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--on-surface);
    background: var(--surface-dim);
    border: 2px solid var(--outline);
    border-radius: var(--radius-xl);
    outline: none;
    transition: all var(--duration-base) var(--ease-out);
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-surface);
}

.search-input:focus ~ .search-icon {
    color: var(--primary);
}

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

/* Search Controls */
.search-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
}

.search-mode {
    display: flex;
    gap: var(--space-2);
    background: var(--surface-dim);
    padding: var(--space-1);
    border-radius: var(--radius-lg);
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--on-surface-variant);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.mode-btn:hover {
    color: var(--on-surface);
    background: var(--surface);
}

.mode-btn.active {
    color: var(--primary);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.mode-btn svg {
    width: 16px;
    height: 16px;
}

/* Module Filter */
.module-filter {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.module-filter-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--on-surface-variant);
}

.module-filter-select {
    padding: var(--space-2) var(--space-4);
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--on-surface);
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    min-width: 180px;
}

.module-filter-select:hover {
    border-color: var(--primary-light);
}

.module-filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-surface);
}

/* Search Button */
.search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--duration-base) var(--ease-bounce);
    box-shadow: 0 4px 12px -2px rgba(5, 150, 105, 0.4);
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px -4px rgba(5, 150, 105, 0.5);
}

.search-btn:active {
    transform: translateY(0);
}

.search-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.search-btn svg {
    width: 18px;
    height: 18px;
}

/* ============================================================================
   Results Section
   ============================================================================ */
.results-section {
    min-height: 200px;
}

/* AI Response */
.ai-response {
    position: relative;
    background: linear-gradient(135deg, var(--primary-surface) 0%, var(--accent-surface) 100%);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    overflow: hidden;
    animation: fadeIn var(--duration-slow) var(--ease-out);
    border: 1px solid rgba(5, 150, 105, 0.2);
}

.ai-response:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.ai-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary);
    margin-bottom: var(--space-3);
}

.ai-header svg {
    width: 16px;
    height: 16px;
}

.ai-content {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.8;
    color: var(--on-surface);
}

.ai-content p { margin-bottom: var(--space-3); }
.ai-content p:last-child { margin-bottom: 0; }

.ai-content strong { 
    font-weight: 600; 
    color: var(--primary);
}

.ai-content ul, .ai-content ol {
    margin: var(--space-3) 0;
    padding-left: var(--space-5);
}

.ai-content li {
    margin-bottom: var(--space-2);
    line-height: 1.6;
}

.ai-content h1, .ai-content h2, .ai-content h3 {
    font-family: var(--font-sans);
    font-weight: 600;
    margin: var(--space-4) 0 var(--space-2) 0;
    color: var(--on-surface);
}

.ai-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: var(--space-3);
    margin: var(--space-3) 0;
    font-style: italic;
    opacity: 0.9;
}

.ai-loading {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--on-surface-variant);
}

.ai-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--primary-surface);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Streaming Cursor */
.ai-cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background-color: var(--primary);
    margin-left: 4px;
    vertical-align: middle;
    animation: blink 1s step-end infinite;
}

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

/* ============================================================================
   Content Cards
   ============================================================================ */
.content-container {
    min-height: 200px;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.content-header h3 {
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    color: var(--on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.content-count {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--on-surface-muted);
    background: var(--surface-container);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
}

.content-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* Content Card */
.content-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius-xl); /* Increased radius */
    padding: var(--space-6); /* Increased padding */
    cursor: pointer;
    transition: all var(--duration-base) var(--ease-out);
    animation: cardAppear var(--duration-slow) var(--ease-out) both;
    box-shadow: var(--shadow-sm); /* Added base shadow */
    margin-bottom: var(--space-4); /* Added margin */
}

.content-card:nth-child(1) { animation-delay: 0ms; }
.content-card:nth-child(2) { animation-delay: 60ms; }
.content-card:nth-child(3) { animation-delay: 120ms; }
.content-card:nth-child(4) { animation-delay: 180ms; }
.content-card:nth-child(5) { animation-delay: 240ms; }

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

.content-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px; /* Thicker accent line */
    background: linear-gradient(180deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
    opacity: 0.8; /* Always visible but subtle */
    transform: scaleY(1); /* Always visible */
    transform-origin: bottom;
    transition: all var(--duration-base) var(--ease-bounce);
}

.content-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl), 0 10px 20px -10px rgba(5, 150, 105, 0.2);
}

.content-card:hover::before {
    opacity: 1;
    width: 8px;
}

.content-card:active {
    transform: translateY(-2px);
}

/* Content Card Header */
.content-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--surface-variant);
}

.content-reference {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.content-module-badge {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    color: white;
    background: var(--primary);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
}

.content-reference-text {
    font-family: var(--font-display);
    font-size: 16px; /* Larger text */
    font-weight: 700;
    color: var(--on-surface);
}

.content-type {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
}

.content-type.lecture {
    background: var(--primary-surface);
    color: var(--primary-dark);
    border: 1px solid rgba(5, 150, 105, 0.2);
}

.content-type.workbook {
    background: var(--accent-surface);
    color: var(--accent);
    border: 1px solid rgba(8, 145, 178, 0.2);
}

.content-text {
    font-family: var(--font-body);
    font-size: 16px; /* Larger text */
    line-height: 1.8;
    color: var(--on-surface-variant);
}

.content-score {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px dashed var(--outline);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    display: inline-block;
}

.content-actions {
    display: flex;
    gap: var(--space-1);
    flex-shrink: 0;
}

/* Action Buttons */
.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: 1px solid var(--outline);
    border-radius: var(--radius-md);
    color: var(--on-surface-muted);
    cursor: pointer;
    transition: all var(--duration-base) var(--ease-bounce);
}

.action-btn:hover {
    background: var(--surface-container);
    border-color: var(--primary-light);
    color: var(--primary);
    transform: scale(1.1);
}

.action-btn:active {
    transform: scale(0.95);
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

.bookmark-btn.active {
    color: var(--accent);
    background: var(--accent-surface);
    border-color: var(--accent-light);
}

/* ============================================================================
   Modal
   ============================================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-base) var(--ease-out);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-2xl);
    max-width: 720px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    transform: translateY(40px) scale(0.9);
    transition: transform var(--duration-slow) var(--ease-bounce);
    overflow: hidden;
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--outline);
    flex-shrink: 0;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.modal-type {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.modal-type.lecture {
    background: var(--primary-surface);
    color: var(--primary);
}

.modal-type.workbook {
    background: var(--accent-surface);
    color: var(--accent);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    color: var(--on-surface-muted);
    cursor: pointer;
    transition: all var(--duration-base) var(--ease-out);
}

.modal-close:hover {
    background: var(--error-surface);
    color: var(--error);
    transform: rotate(90deg);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
}

.modal-content-text {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.8;
    color: var(--on-surface);
    padding: var(--space-5);
    background: linear-gradient(135deg, var(--primary-surface) 0%, var(--surface-dim) 100%);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--primary);
    margin-bottom: var(--space-6);
}

.modal-section {
    margin-bottom: var(--space-6);
}

.modal-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--on-surface-variant);
    margin-bottom: var(--space-4);
}

/* Module Navigation */
.module-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.module-nav-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    color: var(--on-surface-variant);
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-4);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.module-nav-btn:hover:not(:disabled) {
    background: var(--surface-container);
    border-color: var(--primary-light);
    color: var(--primary);
}

.module-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.module-indicator {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--on-surface);
}

.module-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-height: 360px;
    overflow-y: auto;
}

.module-section-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    color: var(--on-surface-variant);
    margin-top: var(--space-3);
    margin-bottom: var(--space-2);
}

.module-item {
    padding: var(--space-3) var(--space-4);
    background: var(--surface-dim);
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-out);
}

.module-item:hover {
    background: var(--surface-container);
}

.module-item-text {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.7;
    color: var(--on-surface);
}

/* ============================================================================
   Bookmarks Panel
   ============================================================================ */
.bookmarks-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: var(--surface);
    box-shadow: var(--shadow-xl);
    z-index: 1001;
    transition: right var(--duration-slow) var(--ease-out);
    display: flex;
    flex-direction: column;
}

.bookmarks-panel.active {
    right: 0;
}

.bookmarks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--outline);
}

.bookmarks-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--on-surface);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.bookmarks-close {
    background: transparent;
    border: none;
    color: var(--on-surface-muted);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-out);
}

.bookmarks-close:hover {
    background: var(--error-surface);
    color: var(--error);
}

.bookmarks-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
}

.bookmark-item {
    background: var(--surface-dim);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.bookmark-item:hover {
    background: var(--surface-container);
    transform: translateX(-4px);
}

.bookmark-reference {
    font-weight: 600;
    color: var(--primary);
    font-size: 14px;
    margin-bottom: var(--space-2);
}

.bookmark-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--on-surface-variant);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bookmarks-empty {
    text-align: center;
    padding: var(--space-8);
    color: var(--on-surface-muted);
}

.bookmarks-empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
}

/* ============================================================================
   Footer
   ============================================================================ */
.app-footer {
    background: var(--surface);
    border-top: 1px solid var(--outline);
    padding: var(--space-4);
    text-align: center;
}

.footer-content {
    max-width: 900px;
    margin: 0 auto;
}

.footer-note {
    font-size: 0.875rem;
    color: var(--on-surface-muted);
}

/* ============================================================================
   Loading States
   ============================================================================ */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--primary-surface);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: var(--space-4);
    color: var(--on-surface-muted);
    font-size: 0.875rem;
}

/* ============================================================================
   Empty States
   ============================================================================ */
.empty-state {
    text-align: center;
    padding: var(--space-12);
    color: var(--on-surface-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--on-surface-variant);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    font-size: 0.875rem;
}

/* ============================================================================
   Toast Notifications
   ============================================================================ */
.toast-container {
    position: fixed;
    bottom: var(--space-4);
    right: var(--space-4);
    z-index: 2000;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    margin-top: var(--space-2);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    animation: toastIn var(--duration-base) var(--ease-bounce);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.toast.success {
    border-color: var(--success);
    color: var(--success);
}

.toast.error {
    border-color: var(--error);
    color: var(--error);
}

/* ============================================================================
   Responsive Design
   ============================================================================ */
@media (max-width: 768px) {
    .main-content {
        padding: var(--space-3);
    }

    .search-section {
        padding: var(--space-4);
    }

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

    .module-filter {
        width: 100%;
    }

    .module-filter-select {
        width: 100%;
    }

    .content-header-row {
        flex-direction: column;
        gap: var(--space-2);
    }

    .content-actions {
        align-self: flex-end;
    }

    .modal {
        max-height: 90vh;
        margin: var(--space-2);
    }

    .bookmarks-panel {
        width: 100%;
        right: -100%;
    }

    .header-controls {
        position: static;
        justify-content: center;
        margin-top: var(--space-4);
    }
}

@media (max-width: 480px) {
    .logo-text {
        font-size: 1.5rem;
    }

    .search-mode {
        flex-direction: column;
        width: 100%;
    }

    .mode-btn {
        justify-content: center;
    }

    .action-btn {
        width: 40px;
        height: 40px;
    }
}

/* ============================================================================
   Print Styles
   ============================================================================ */
@media print {
    .app-header,
    .search-section,
    .header-controls,
    .content-actions,
    .modal-overlay,
    .bookmarks-panel,
    .toast-container,
    .app-footer {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .content-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ============================================================================
   Accessibility
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ============================================================================
   High Contrast Mode
   ============================================================================ */
@media (prefers-contrast: high) {
    :root {
        --outline: #000;
        --outline-variant: #333;
    }

    [data-theme="dark"] {
        --outline: #fff;
        --outline-variant: #ccc;
    }
}
