:root {
    /* Light Theme Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    --accent-primary: #3b82f6;
    --accent-secondary: #8b5cf6;
    --accent-hover: #2563eb;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Z-index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 1000;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #64748b;
    --border-color: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.4);
}

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

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-base), color var(--transition-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

/* ===========================
   Header
   =========================== */
.header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.8);
    transition: all var(--transition-base);
}

[data-theme="dark"] .header {
    background-color: rgba(15, 23, 42, 0.8);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg) 0;
    gap: var(--spacing-md);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo-icon {
    font-size: 2rem;
    line-height: 1;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
    color: var(--accent-primary);
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    width: 40px;
    height: 40px;
}

.theme-toggle:hover {
    background-color: var(--bg-tertiary);
    transform: rotate(15deg);
}

.moon-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: none;
}

[data-theme="dark"] .moon-icon {
    display: block;
}

/* ===========================
   Hero Section
   =========================== */
.hero {
    padding: var(--spacing-2xl) 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::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%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    margin-bottom: var(--spacing-md);
    background: linear-gradient(to right, #fff, #f0f0f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeInUp 0.6s ease-out;
}

.hero-subtitle {
    font-size: clamp(1rem, 2vw, 1.25rem);
    margin-bottom: var(--spacing-xl);
    opacity: 0.9;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: var(--spacing-2xl);
    margin-bottom: var(--spacing-xl);
    flex-wrap: wrap;
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.stat-number {
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: 800;
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-top: var(--spacing-xs);
}

.hero-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
    animation: fadeInUp 0.6s ease-out 0.3s both;
}

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

/* ===========================
   Buttons
   =========================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-xl);
    border-radius: var(--radius-md);
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-base);
    cursor: pointer;
    border: none;
    font-size: 1rem;
    white-space: nowrap;
}

.btn-primary {
    background-color: white;
    color: #667eea;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background-color: transparent;
    color: white;
    border: 2px solid white;
}

.btn-secondary:hover {
    background-color: white;
    color: #667eea;
}

.btn-small {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.875rem;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

/* ===========================
   Filters Section
   =========================== */
.filters {
    padding: var(--spacing-xl) 0;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.filters-content {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: var(--spacing-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-md) var(--spacing-md) calc(var(--spacing-md) * 3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

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

.filter-select {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    min-width: 180px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.results-info {
    width: 100%;
    margin-top: var(--spacing-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.active-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    min-height: 20px;
}

.active-tags:empty {
    display: none;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--accent-primary);
    color: white;
    border-radius: 16px;
    font-size: 0.875rem;
    font-weight: 500;
    animation: tagSlideIn 0.2s ease;
}

@keyframes tagSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tag-remove {
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
    margin-left: 0.25rem;
}

.tag-remove:hover {
    opacity: 1;
}

/* ===========================
   Gallery Section
   =========================== */
.gallery {
    padding: var(--spacing-2xl) 0;
    min-height: 60vh;
}

.gallery-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.section-title {
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: 800;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

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

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--spacing-xl);
}

.template-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-base);
    cursor: pointer;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px var(--shadow-lg);
    border-color: var(--accent-primary);
}

.template-category-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(99, 102, 241, 0.95);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 2;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.template-preview-image {
    width: 100%;
    position: relative;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.template-preview-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
    display: block;
}

.template-card:hover .template-preview-image img {
    transform: scale(1.05);
}

.template-preview {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--text-tertiary);
}

.template-content {
    padding: var(--spacing-lg);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.template-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    line-height: 1.3;
}

.template-category {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    background-color: var(--accent-primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    margin-top: var(--spacing-xs);
}

.template-description {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    font-size: 0.875rem;
    line-height: 1.5;
}

.template-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
    min-height: 28px;
}

.template-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    color: var(--accent-primary);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    white-space: nowrap;
}

.template-tag:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .template-tag {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border-color: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}

[data-theme="dark"] .template-tag:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(139, 92, 246, 0.25) 100%);
    border-color: #60a5fa;
}

.template-footer {
    margin-top: auto;
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.template-difficulty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.difficulty-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.difficulty-dot.difficulty-beginner {
    background-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.difficulty-dot.difficulty-intermediate {
    background-color: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.difficulty-dot.difficulty-advanced {
    background-color: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.template-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.template-action {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.template-action:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.template-action svg {
    width: 16px;
    height: 16px;
}

.template-author {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.template-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    transition: color var(--transition-fast);
}

.template-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ===========================
   Loading & No Results
   =========================== */
.loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
    color: var(--text-secondary);
}

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

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

.no-results {
    text-align: center;
    padding: var(--spacing-2xl);
    grid-column: 1 / -1;
}

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

.no-results-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.no-results h4 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.no-results p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

/* ===========================
   About Section
   =========================== */
.about {
    padding: var(--spacing-2xl) 0;
    background-color: var(--bg-secondary);
}

.about-content {
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
}

.about-text {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
    line-height: 1.8;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
}

.feature-card {
    padding: var(--spacing-lg);
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px var(--shadow);
    border-color: var(--accent-primary);
}

.feature-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: var(--spacing-md);
}

.feature-card h4 {
    font-size: 1.125rem;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===========================
   Contribute Section
   =========================== */
.contribute {
    padding: var(--spacing-2xl) 0;
}

.cta {
    padding: var(--spacing-xl);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--radius-xl);
    color: white;
    text-align: center;
}

.cta h3 {
    font-size: 1.75rem;
    margin-bottom: var(--spacing-sm);
}

.cta p {
    margin-bottom: var(--spacing-lg);
    opacity: 0.9;
    font-size: 1.125rem;
}

.cta-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* ===========================
   Footer
   =========================== */
.footer {
    background-color: var(--bg-secondary);
    padding: var(--spacing-2xl) 0 var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.footer-section h4 {
    font-size: 1.125rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.footer-section h5 {
    font-size: 1rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
    font-weight: 600;
}

.footer-section p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
}

.footer-section a {
    display: block;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: var(--spacing-sm);
    font-size: 0.875rem;
    transition: color var(--transition-fast);
}

.footer-section a:hover {
    color: var(--accent-primary);
}

.social-links {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.social-links a {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.social-links a:hover {
    background-color: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
}

.footer-bottom {
    text-align: center;
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-bottom p {
    margin-bottom: var(--spacing-xs);
}

.footer-bottom a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-bottom a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ===========================
   Modal
   =========================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background-color: var(--bg-primary);
    border-radius: var(--radius-xl);
    max-width: 1000px;
    width: calc(100% - var(--spacing-xl) * 2);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px var(--shadow-lg);
    z-index: 1;
    animation: modalSlideUp 0.3s ease-out;
    overflow: hidden;
}

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

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

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

.modal-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

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

.modal-tabs {
    display: flex;
    gap: 0;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 var(--spacing-lg);
}

.tab-btn {
    padding: var(--spacing-md) var(--spacing-lg);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.modal-body {
    max-height: calc(90vh - 140px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
    padding: var(--spacing-lg);
    height: 100%;
    overflow: visible;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

.code-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--spacing-md);
}

#codeContent {
    position: relative;
    flex: 1;
    overflow: hidden;
    padding: 24px;
}

#codeContent pre {
    background: #f6f8fa;
    border-radius: var(--border-radius);
    padding: 20px;
    overflow: auto;
    margin: 0;
    height: 100%;
    box-sizing: border-box;
}

.hljs
 {
    color: #24292e;
    background: #fff;
}

.hljs {
    background: #f6f8fa !important;
}

#previewContent {
    background: white;
    border-radius: 0;
    flex: 1;
    overflow: hidden;
    padding: 0;
}

#previewContent .loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-secondary);
}

#previewContent iframe {
    width: 100%;
    border: none;
    border-radius: var(--radius-md);
    display: block;
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 768px) {
    .container {
        padding: 0 var(--spacing-md);
    }
    
    .header-content {
        flex-direction: column;
        gap: var(--spacing-md);
        padding: var(--spacing-md) 0;
    }
    
    .logo {
        flex-direction: column;
        text-align: center;
        gap: var(--spacing-sm);
    }
    
    .logo h1 {
        font-size: 0.95rem;
        white-space: normal;
        line-height: 1.3;
    }
    
    .nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--spacing-sm);
        width: 100%;
    }
    
    .nav-link {
        font-size: 0.875rem;
        padding: var(--spacing-xs);
    }
    
    .theme-toggle {
        width: 36px;
        height: 36px;
    }
    
    .hero {
        padding: var(--spacing-xl) 0;
    }
    
    .hero-title {
        font-size: 1.75rem;
        line-height: 1.2;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-stats {
        gap: var(--spacing-md);
    }
    
    .stat-number {
        font-size: 1.75rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .header-actions {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .btn-header {
        padding: 8px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    
    .btn-header svg {
        width: 14px;
        height: 14px;
    }
    
    .filters-content {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-md);
    }
    
    .search-box {
        min-width: 100%;
    }
    
    .search-input {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 12px 12px 12px 40px;
    }
    
    .filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-xs);
    }
    
    .filter-select {
        width: 100%;
        font-size: 16px; /* Prevent iOS zoom */
        padding: 12px var(--spacing-md);
        min-width: 100%;
    }
    
    .btn-small {
        width: 100%;
        justify-content: center;
    }
    
    .active-tags {
        padding: var(--spacing-sm);
    }
    
    .templates-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .template-card {
        border-radius: var(--radius-md);
    }
    
    .template-preview-image img,
    .template-preview {
        height: 180px;
    }
    
    .template-content {
        padding: var(--spacing-md);
    }
    
    .template-title {
        font-size: 1.125rem;
    }
    
    .template-tags {
        gap: 0.4rem;
    }
    
    .template-tag {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
    
    .template-footer {
        flex-direction: column;
        gap: var(--spacing-sm);
        align-items: flex-start;
    }
    
    .template-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .feature-card {
        padding: var(--spacing-md);
    }
    
    .cta {
        padding: var(--spacing-lg);
    }
    
    .cta h3 {
        font-size: 1.5rem;
    }
    
    .cta p {
        font-size: 1rem;
    }
    
    .cta-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cta-actions .btn {
        width: 100%;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: var(--spacing-xl);
    }
    
    .footer-section a {
        display: inline-block;
        margin: 0 var(--spacing-sm) var(--spacing-sm) 0;
    }
    
    .social-links {
        justify-content: center;
    }
    
    .modal-content {
        width: calc(100% - var(--spacing-sm) * 2);
        max-height: 95vh;
        border-radius: var(--radius-md);
    }
    
    .modal-header-bar {
        padding: var(--spacing-md);
        flex-wrap: wrap;
    }
    
    .modal-header-bar h2 {
        font-size: 1.125rem;
        flex: 1;
    }
    
    .modal-tabs {
        padding: 0 var(--spacing-sm);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-btn {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 0.875rem;
        white-space: nowrap;
    }
    
    .tab-content {
        padding: var(--spacing-md);
    }
    
    #codeContent pre {
        padding: var(--spacing-md);
        font-size: 0.8rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    
    .copy-btn {
        position: static;
        width: 100%;
        margin-top: var(--spacing-md);
    }
    
    .scroll-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 480px) {
    .hero-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn {
        padding: 14px var(--spacing-lg);
        min-height: 44px; /* Touch target size */
    }
    
    .hero-title {
        font-size: 1.5rem;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .section-subtitle {
        font-size: 0.95rem;
    }
    
    .modal-content {
        width: calc(100% - 16px);
        max-height: 98vh;
    }
    
    .template-card:hover {
        transform: none; /* Disable hover transform on small touch devices */
    }
}

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

/* Focus styles for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ===========================
   Utility Classes
   =========================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

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

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

/* ===========================
   Template Card Enhancements
   =========================== */
.template-meta {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0.75rem 0;
    gap: 1rem;
}

.template-actions {
    display: flex;
    gap: 0.5rem;
}

.template-actions .btn-small {
    flex: 1;
    text-align: center;
    justify-content: center;
}

.template-actions button {
    flex: 1;
}

/* Loading and Error States */
.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--error-color);
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
}

.no-results h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.no-results p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}


.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.btn-header:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    z-index: 999;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top:hover {
    background: var(--accent-hover);
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
}

.scroll-to-top svg {
    transition: var(--transition);
}

.scroll-to-top:hover svg {
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .scroll-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
    }
}


.copy-btn {
    position: absolute;
    top: 32px;
    right: 32px;
    background: #0066cc;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.copy-btn:hover {
    background: #005bb5;
}
