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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #fff;
}

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

/* Header */
header {
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 1.5rem 0;
}

.site-title h1 {
    margin: 0;
}

.site-title h1 a {
    text-decoration: none;
    color: #333;
    font-size: 2rem;
    font-weight: 700;
}

.site-subtitle {
    color: #666;
    font-size: 0.9rem;
    margin-top: 0.2rem;
    font-weight: 400;
}

/* Blog Grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

@media (min-width: 768px) {
    .posts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.post-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.post-image {
    height: 200px;
    overflow: hidden;
    background: #f5f5f5;
}

.post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder-image {
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.9rem;
}

.placeholder-image::before {
    content: "No Image";
}

.post-content {
    padding: 1.5rem;
}

.post-content h2 {
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
    font-weight: 600;
}

.post-content h2 a {
    text-decoration: none;
    color: #333;
}

.post-content h2 a:hover {
    color: #666;
}

.excerpt {
    color: #666;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: #f5f5f5;
    color: #666;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Single Post */
.post-single {
    max-width: 800px;
    margin: 2rem auto;
}

.feature-image {
    margin-bottom: 2rem;
    border-radius: 8px;
    overflow: hidden;
}

.feature-image img {
    width: 100%;
    height: auto;
}

.post-header {
    margin-bottom: 2rem;
    text-align: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 1.5rem;
}

.post-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.post-header .post-tags {
    justify-content: center;
}

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

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    margin: 2rem 0 1rem 0;
    color: #333;
    font-weight: 600;
}

.post-content h1 {
    font-size: 2rem;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
}

.post-content h2 {
    font-size: 1.6rem;
}

.post-content h3 {
    font-size: 1.4rem;
}

.post-content h4 {
    font-size: 1.2rem;
}

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

.post-content ul,
.post-content ol {
    margin: 1.5rem 0;
    padding-left: 2rem;
}

.post-content li {
    margin-bottom: 0.5rem;
    color: #444;
}

.post-content .post-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 2rem 0;
    display: block;
}

.post-content a {
    color: #333;
    text-decoration: underline;
}

.post-content a:hover {
    color: #666;
}

.post-content code {
    background: #f5f5f5;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.post-content strong {
    font-weight: 600;
    color: #222;
}

.post-content em {
    font-style: italic;
    color: #555;
}

/* Footer */
footer {
    background: #f8f9fa;
    border-top: 1px solid #eee;
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
    color: #666;
}

/* No posts message */
.no-posts {
    text-align: center;
    padding: 4rem 2rem;
    color: #666;
}

.no-posts h2 {
    margin-bottom: 1rem;
    color: #333;
}

.no-posts p {
    font-size: 1.1rem;
}

/* Admin Styles */
.admin-login {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #f5f5f5;
}

.admin-login form {
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 300px;
}

.admin-login h2 {
    margin-bottom: 1rem;
    text-align: center;
}

.admin-login input,
.admin-login button {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.admin-login button {
    background: #333;
    color: #fff;
    border: none;
    cursor: pointer;
}

.admin-login button:hover {
    background: #555;
}

.admin-header {
    background: #333;
    color: #fff;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-header button {
    background: #666;
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

.admin-container {
    display: flex;
    min-height: calc(100vh - 80px);
}

.admin-sidebar {
    width: 300px;
    background: #f5f5f5;
    padding: 1rem;
    border-right: 1px solid #ddd;
}

.admin-sidebar button {
    width: 100%;
    padding: 0.75rem;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 1rem;
}

.admin-sidebar ul {
    list-style: none;
}

.admin-sidebar li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #ddd;
}

.admin-sidebar a {
    text-decoration: none;
    color: #333;
    flex: 1;
}

.admin-sidebar a:hover {
    color: #666;
}

.admin-sidebar li button {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    width: auto;
    margin: 0;
}

.admin-editor {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.editor-toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.editor-toolbar input[type="text"] {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.editor-toolbar button {
    padding: 0.5rem 1rem;
    background: #28a745;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.editor-toolbar input[type="file"] {
    padding: 0.5rem;
}

#editor {
    flex: 1;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    outline: none;
}

.admin-errors {
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.admin-errors h3 {
    margin-bottom: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .posts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .post-card {
        margin-bottom: 1rem;
    }

    .container {
        padding: 0 15px;
    }

    .post-title {
        font-size: 2rem;
    }

    .site-title h1 a {
        font-size: 1.6rem;
    }

    .admin-container {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
    }

    .editor-toolbar {
        flex-wrap: wrap;
    }

    .editor-toolbar input[type="text"] {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Smooth transitions */
* {
    transition: color 0.2s, background-color 0.2s;
}

/* Focus states */
input:focus,
textarea:focus,
button:focus {
    outline: 2px solid #333;
    outline-offset: 2px;
}

/* Print styles */
@media print {

    .admin-header,
    .admin-sidebar,
    .editor-toolbar {
        display: none;
    }

    .post-content {
        max-width: none;
    }
}

/* Post Navigation */
.post-navigation {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #eee;
    text-align: center;
}

.back-to-home {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #f8f9fa;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    border: 1px solid #ddd;
    transition: all 0.2s;
}

.back-to-home:hover {
    background: #e9ecef;
    color: #000;
    transform: translateY(-1px);
}

/* Admin Preview Styles */
#preview {
    max-height: 400px;
    overflow-y: auto;
    border-radius: 4px;
}

#preview h3 {
    color: #333;
    margin-top: 0;
}

#preview-content {
    line-height: 1.6;
}

#preview-content h1 {
    font-size: 1.8rem;
    color: #333;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
}

#preview-content h2 {
    font-size: 1.5rem;
    color: #333;
    margin-top: 1.5rem;
}

#preview-content h3 {
    font-size: 1.3rem;
    color: #333;
    margin-top: 1.2rem;
}

#preview-content p {
    margin-bottom: 1rem;
    color: #444;
}

#preview-content img {
    border-radius: 4px;
    margin: 1rem 0;
}

#preview-content code {
    background: #f5f5f5;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

#preview-content strong {
    font-weight: 600;
}

#preview-content em {
    font-style: italic;
}

#preview-content a {
    color: #007bff;
    text-decoration: underline;
}

/* Enhanced editor toolbar */
.editor-toolbar {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.editor-toolbar input[type="text"] {
    font-size: 1rem;
}

.editor-toolbar input[name="title"] {
    font-weight: 600;
    font-size: 1.1rem;
}

.editor-toolbar input[name="slug"] {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #666;
}

/* Auto-save indicator */
.auto-save-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.auto-save-indicator.show {
    opacity: 1;
}

/* Improved sidebar */
.admin-sidebar h3 {
    color: #333;
    margin: 1.5rem 0 0.5rem 0;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-sidebar ul {
    max-height: 400px;
    overflow-y: auto;
}

.admin-sidebar li:hover {
    background: #f0f0f0;
}

/* Responsive admin */
@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .admin-container {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        max-height: 300px;
        overflow-y: auto;
    }

    .editor-toolbar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .editor-toolbar input,
    .editor-toolbar button {
        width: 100%;
    }

    #editor {
        min-height: 300px;
    }

    #preview {
        margin-top: 1rem;
    }
}

/* Loading states for admin */
.admin-editor.loading {
    opacity: 0.6;
    pointer-events: none;
}

.admin-editor.loading::after {
    content: 'Saving...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 1rem 2rem;
    border-radius: 4px;
    font-size: 1.1rem;
}

/* Success/Error messages */
.admin-success {
    background: #d4edda;
    color: #155724;
    padding: 1rem;
    margin: 1rem;
    border-radius: 4px;
    border: 1px solid #c3e6cb;
}

.admin-errors {
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    margin: 1rem;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
}

#editor {
    width: 100%;
    height: calc(100vh - 200px);
}

/* Keyboard shortcuts help */
.shortcuts-help {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.shortcuts-help.show {
    opacity: 1;
}

.shortcuts-help kbd {
    background: #555;
    padding: 0.2rem 0.4rem;
    border-radius: 2px;
    font-family: monospace;
}

/* Table Styles */
.post-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.post-table th,
.post-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
    vertical-align: top;
}

.post-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

.post-table tr:hover {
    background: #f8f9fa;
}

.post-table tr:last-child td {
    border-bottom: none;
}

/* Responsive tables */
@media (max-width: 768px) {
    .post-table {
        font-size: 0.9rem;
    }

    .post-table th,
    .post-table td {
        padding: 0.5rem;
    }

    /* Stack table on very small screens */
    @media (max-width: 480px) {

        .post-table,
        .post-table thead,
        .post-table tbody,
        .post-table th,
        .post-table td,
        .post-table tr {
            display: block;
        }

        .post-table thead tr {
            position: absolute;
            top: -9999px;
            left: -9999px;
        }

        .post-table tr {
            border: 1px solid #ccc;
            margin-bottom: 0.5rem;
            padding: 0.5rem;
            border-radius: 4px;
        }

        .post-table td {
            border: none;
            position: relative;
            padding-left: 50% !important;
            padding-top: 0.5rem;
            padding-bottom: 0.5rem;
        }

        .post-table td:before {
            content: attr(data-label) ": ";
            position: absolute;
            left: 6px;
            width: 45%;
            padding-right: 10px;
            white-space: nowrap;
            font-weight: bold;
            color: #333;
        }
    }
}

/* Code block improvements */
pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

pre code {
    background: none;
    padding: 0;
    border: none;
    font-family: 'Courier New', 'Monaco', monospace;
}

/* Blockquote styles */
blockquote {
    border-left: 4px solid #007bff;
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    font-style: italic;
    color: #555;
    border-radius: 0 4px 4px 0;
}

blockquote p {
    margin: 0;
}

/* Horizontal rule */
hr {
    border: none;
    height: 1px;
    background: #e9ecef;
    margin: 2rem 0;
}

/* Strikethrough */
del {
    color: #6c757d;
    text-decoration: line-through;
}

/* Enhanced inline code */
code {
    background: #f1f3f4;
    color: #d73a49;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', 'Monaco', monospace;
    font-size: 0.9em;
}