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

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --bg-color: #ffffff;
    --bg-gray: #f9fafb;
    --border-color: #e5e7eb;
    --success-color: #10b981;
    --error-color: #ef4444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-gray);
}

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

/* Header */
.site-header {
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.site-title a {
    color: var(--text-color);
    text-decoration: none;
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.main-nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.main-nav a:hover {
    color: var(--primary-color);
}

/* Main Content */
.site-main {
    min-height: calc(100vh - 200px);
    padding: 3rem 0;
}

/* Posts List */
.posts-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: 1fr; /* All rows have equal height */
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.post-card {
    background: var(--bg-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 250px; /* Minimum height for consistency */
}

.post-card:hover {
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.post-thumbnail {
    width: 280px;
    min-width: 280px;
    align-self: stretch; /* Stretch to match parent height */
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-gray);
    position: relative;
}

.post-thumbnail a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.post-thumbnail img,
.post-thumbnail > a > div {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.post-card:hover .post-thumbnail img {
    transform: scale(1.05);
}

.post-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.post-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.post-title a {
    color: var(--text-color);
    text-decoration: none;
}

.post-title a:hover {
    color: var(--primary-color);
}

.post-meta {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.post-meta time {
    display: inline;
}

.post-excerpt {
    color: var(--text-color);
    margin-bottom: 1rem;
    line-height: 1.6;
    flex-grow: 1;
}

.read-more {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.read-more:hover {
    text-decoration: underline;
}

/* Single Post */
.single-post {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.post-hero {
    margin: -2rem -2rem 2rem;
    max-height: 420px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-gray);
}

.post-hero img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 420px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.post-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.post-header .post-title {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.post-content {
    font-size: 1.1rem;
    line-height: 1.8;
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content h2,
.post-content h3,
.post-content h4 {
    margin: 2rem 0 1rem;
}

.post-updated {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-top: 3rem;
}

.pagination a {
    padding: 0.5rem 1rem;
    background: var(--bg-color);
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.pagination a:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-info {
    color: var(--text-light);
}

/* Post Navigation */
.post-navigation {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.back-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

/* Error Pages */
.error-404, .no-posts {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-color);
    border-radius: 8px;
}

.error-404 h2, .no-posts h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.error-404 p, .no-posts p {
    color: var(--text-light);
    margin-bottom: 2rem;
}

.button {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.2s;
}

.button:hover {
    background: var(--primary-dark);
}

/* Footer */
.site-footer {
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
    color: var(--text-light);
}

/* Categories Page */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.category-card {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

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

.category-name {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.category-name a {
    color: var(--text-color);
    text-decoration: none;
}

.category-name a:hover {
    color: var(--primary-color);
}

.category-description {
    color: var(--text-light);
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.9rem;
}

.category-count {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-gray);
    color: var(--text-light);
    border-radius: 20px;
    font-size: 0.875rem;
}

.category-header {
    margin-bottom: 2rem;
    text-align: center;
}

.category-header .page-title {
    margin-bottom: 0.5rem;
}

.category-header .category-description {
    max-width: 600px;
    margin: 0 auto 1rem;
}

.back-to-categories {
    display: inline-block;
    margin-top: 1rem;
    color: var(--primary-color);
    text-decoration: none;
}

.back-to-categories:hover {
    text-decoration: underline;
}

/* Search Page */
.search-section {
    background: var(--bg-color);
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.search-form {
    margin: 1.5rem 0;
}

.search-input-group {
    display: flex;
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

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

.search-button {
    padding: 0.75rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

.search-results-info {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-light);
}

.search-results-info strong {
    color: var(--text-color);
}

.post-excerpt mark {
    background: yellow;
    padding: 0 2px;
}

.page-title {
    font-size: 2rem;
    text-align: center;
    margin-bottom: 1rem;
}

.main-nav a.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    .post-card {
        flex-direction: column;
    }
    
    .post-thumbnail {
        width: 100%;
        height: 200px; /* Fixed height for mobile to maintain consistency */
        min-width: auto;
    }
    
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    .site-header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .main-nav ul {
        gap: 1rem;
    }
    
    .single-post {
        padding: 1rem;
    }
    
    .post-hero {
        margin: -1rem -1rem 1rem;
    }
    
    .search-input-group {
        flex-direction: column;
    }
    
    .search-button {
        width: 100%;
    }
    
    .search-section {
        padding: 1rem;
    }
}