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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #22c55e;
    --tag-bg: #e0e7ff;
    --tag-text: #3730a3;
}

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

a {
    text-decoration: none;
    color: inherit;
}

/* NAV */
nav {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav .logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

nav .nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

nav .nav-links a {
    color: var(--text-light);
    font-weight: 500;
    transition: color 0.2s;
}

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

/* SEARCH */
.search-box {
    max-width: 600px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.search-box input {
    width: 100%;
    padding: 0.8rem 1.2rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

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

/* CATEGORIES */
.categories {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    max-width: 900px;
    margin: 0 auto 1.5rem;
    padding: 0 1rem;
}

.cat-btn {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.cat-btn:hover,
.cat-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ARTICLES GRID */
.articles {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem 3rem;
    display: grid;
    gap: 1.5rem;
}

.article-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

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

.article-card .meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.article-card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.article-card p {
    color: var(--text-light);
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tags {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.8rem;
    flex-wrap: wrap;
}

.tag {
    background: var(--tag-bg);
    color: var(--tag-text);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
}

/* ARTICLE DETAIL */
.article-detail {
    max-width: 700px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.article-detail h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.article-detail .meta {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
}

.article-detail .content {
    font-size: 1.05rem;
    line-height: 1.8;
    white-space: pre-wrap;
}

.article-detail .content h2.section-heading {
    font-size: 1.4rem;
    margin-top: 2rem;
    margin-bottom: 0.8rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid var(--border);
}

.article-detail .content h3 {
    font-size: 1.15rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.article-detail .content strong {
    font-weight: 700;
}

.article-detail .content ol,
.article-detail .content ul {
    margin: 0.8rem 0;
    padding-left: 1.5rem;
}

.article-detail .content li {
    margin-bottom: 0.3rem;
    white-space: normal;
}

.code-block {
    margin: 1.2rem 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #1e293b;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 1rem;
    background: #0f172a;
    font-size: 0.8rem;
}

.code-lang {
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.copy-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

.code-block pre {
    margin: 0;
    padding: 1rem;
    overflow-x: auto;
}

.code-block code {
    color: #e2e8f0;
    font-family: 'Fira Code', 'Consolas', 'Courier New', monospace;
    font-size: 0.88rem;
    line-height: 1.6;
}

.inline-code {
    background: #e0e7ff;
    color: #3730a3;
    padding: 0.15rem 0.4rem;
    border-radius: 5px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.9em;
}

.toc {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem 1.5rem;
    margin-bottom: 2rem;
}

.toc strong {
    display: block;
    margin-bottom: 0.6rem;
    font-size: 1rem;
}

.toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc li {
    margin-bottom: 0.3rem;
}

.toc a {
    color: var(--primary);
    font-size: 0.92rem;
    transition: color 0.2s;
}

.toc a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* COMMENTS */
.comments {
    max-width: 700px;
    margin: 3rem auto;
    padding: 0 1rem;
}

.comments h3 {
    margin-bottom: 1rem;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 2rem;
}

.comment-form input,
.comment-form textarea {
    padding: 0.7rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    font-family: inherit;
}

.comment-form input:focus,
.comment-form textarea:focus {
    border-color: var(--primary);
}

.comment-form button {
    align-self: flex-start;
    padding: 0.6rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
}

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

.comment-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.8rem;
}

.comment-item .name {
    font-weight: 600;
    font-size: 0.9rem;
}

.comment-item .date {
    font-size: 0.75rem;
    color: var(--text-light);
}

.comment-item .text {
    margin-top: 0.4rem;
    font-size: 0.95rem;
}

.comment-item .delete-btn {
    float: right;
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.8rem;
}

/* ADMIN */
.admin-container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
}

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

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

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
}

.admin-table {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.admin-table table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 0.8rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-light);
}

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

.admin-table .actions {
    display: flex;
    gap: 0.4rem;
}

/* MODAL */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--card);
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal h2 {
    margin-bottom: 1.5rem;
}

.modal label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.modal input,
.modal textarea,
.modal select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    outline: none;
    font-family: inherit;
}

.modal textarea {
    min-height: 200px;
    resize: vertical;
}

.modal input:focus,
.modal textarea:focus {
    border-color: var(--primary);
}

.modal .btn-row {
    display: flex;
    gap: 0.8rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

/* EMPTY STATE */
.empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

/* FOOTER */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
}

/* RESPONSIVE */
@media (max-width: 640px) {
    nav {
        padding: 0.8rem 1rem;
    }
    nav .logo {
        font-size: 1.2rem;
    }
    .article-detail h1 {
        font-size: 1.5rem;
    }
    .admin-table {
        font-size: 0.85rem;
    }
    .admin-table th,
    .admin-table td {
        padding: 0.5rem;
    }
}
