/* ── Reset & Base ────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:       #0f0f1a;
    --surface:  #1a1a2e;
    --border:   #2a2a4a;
    --accent:   #7b8cde;
    --accent-h: #9aaae8;
    --danger:   #e94560;
    --text:     #e0e0e0;
    --muted:    #aaa;
    --radius:   6px;
    --radius-lg:10px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }

/* ── Header ─────────────────────────────────────── */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.site-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.01em;
}

header nav { display: flex; gap: 1.2rem; }
header nav a { color: var(--muted); font-size: 0.9rem; }
header nav a:hover { color: var(--text); }

/* ── Main & Footer ──────────────────────────────── */
main {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
}

footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* ── Flash messages ─────────────────────────────── */
.flash-messages { margin-bottom: 1.5rem; }
.flash {
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.7rem 1rem;
    margin-bottom: 0.5rem;
    color: var(--accent);
}
.flash.error { border-color: var(--danger); color: var(--danger); }

/* ── Page layout ────────────────────────────────── */
.page-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2.5rem;
    align-items: start;
}

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.2rem;
    position: sticky;
    top: 72px;
}

.sidebar h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 0.8rem;
}

.category-list { list-style: none; }
.category-list li { margin-bottom: 2px; }
.category-list a {
    display: block;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    transition: background 0.15s;
}
.category-list a:hover { background: var(--border); color: var(--text); }
.category-list a.active { background: var(--accent); color: #fff; }

/* ── Feed heading ───────────────────────────────── */
.feed-heading {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text);
}

/* ── Post list ──────────────────────────────────── */
.post-list { display: flex; flex-direction: column; gap: 0; }

.post-card {
    padding: 1.8rem 0;
    border-bottom: 1px solid var(--border);
}
.post-card:first-child { padding-top: 0; }

.post-meta {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.post-category {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    background: rgba(123,140,222,0.12);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
}
.post-category:hover { color: var(--accent-h); }

.post-date, .post-read {
    font-size: 0.82rem;
    color: var(--muted);
}

.post-title {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}
.post-title a { color: var(--text); }
.post-title a:hover { color: var(--accent); }

.post-excerpt {
    color: var(--muted);
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    line-height: 1.6;
}

.read-more {
    font-size: 0.88rem;
    color: var(--accent);
    font-weight: 500;
}
.read-more:hover { color: var(--accent-h); }

/* ── Pagination ─────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 2.5rem;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ── Single post ────────────────────────────────── */
.post-layout {
    max-width: 720px;
    margin: 0 auto;
}

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

.post-title-full {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.25;
    margin: 0.6rem 0 0.8rem;
    color: var(--text);
}

.post-subtitle {
    font-size: 1.1rem;
    color: var(--muted);
    line-height: 1.5;
}

/* ── Post body (rendered markdown) ─────────────── */
.post-body {
    font-size: 1.05rem;
    line-height: 1.8;
    color: #d0d0e0;
}

.post-body h1, .post-body h2, .post-body h3,
.post-body h4, .post-body h5, .post-body h6 {
    color: var(--text);
    margin: 2rem 0 0.8rem;
    line-height: 1.3;
    font-weight: 700;
}
.post-body h1 { font-size: 1.7rem; }
.post-body h2 { font-size: 1.4rem; }
.post-body h3 { font-size: 1.2rem; }

.post-body p { margin: 0 0 1.2rem; }

.post-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.post-body a:hover { color: var(--accent-h); }

.post-body ul, .post-body ol {
    margin: 0 0 1.2rem 1.5rem;
}
.post-body li { margin-bottom: 0.3rem; }

.post-body blockquote {
    border-left: 3px solid var(--accent);
    margin: 1.5rem 0;
    padding: 0.5rem 0 0.5rem 1.2rem;
    color: var(--muted);
    font-style: italic;
}

.post-body pre {
    background: #111122;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    overflow-x: auto;
    margin: 1.2rem 0;
}
.post-body pre code {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: #c8d3f5;
    background: none;
    padding: 0;
}
.post-body code {
    font-family: 'Courier New', monospace;
    font-size: 0.875em;
    color: var(--accent-h);
    background: rgba(123,140,222,0.12);
    padding: 0.15em 0.4em;
    border-radius: 3px;
}

.post-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

.post-body img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 1rem 0;
}

/* ── Post footer ────────────────────────────────── */
.post-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-link { color: var(--muted); font-size: 0.9rem; }
.back-link:hover { color: var(--text); }

/* ── Empty state ────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 5rem 2rem;
    color: var(--muted);
}
.empty-state h2 { color: var(--text); margin-bottom: 0.8rem; }
.empty-state a { margin-top: 1rem; display: inline-block; }

/* ── Auth box ───────────────────────────────────── */
.auth-box {
    max-width: 360px;
    margin: 4rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
}
.auth-box h2 { margin-bottom: 1.2rem; }
.auth-box input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.7rem 1rem;
    color: var(--text);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    outline: none;
}
.auth-box input:focus { border-color: var(--accent); }
.auth-box button {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 0.7rem;
    cursor: pointer;
    font-size: 0.95rem;
}
.auth-box button:hover { background: var(--accent-h); }

/* ── Admin ──────────────────────────────────────── */
.admin-layout { display: flex; flex-direction: column; gap: 2rem; }

.admin-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border);
}
.admin-section-header h2 { font-size: 1.1rem; }

.admin-section > h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* ── Admin form ─────────────────────────────────── */
.admin-form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.field-label {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: -0.3rem;
}

.admin-form input,
.admin-form textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.9rem;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    width: 100%;
    resize: vertical;
}
.admin-form textarea { font-family: 'Courier New', monospace; font-size: 0.875rem; }
.admin-form input:focus, .admin-form textarea:focus { border-color: var(--accent); }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text);
}
.checkbox-label input[type="checkbox"] { width: auto; }

.form-row { display: flex; gap: 0.7rem; align-items: center; }

.admin-form button, .btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-block;
    text-align: center;
    transition: background 0.2s;
}
.admin-form button:hover, .btn-primary:hover { background: var(--accent-h); }

.admin-form a.btn-secondary, .btn-secondary {
    background: var(--border);
    color: var(--text);
    border: none;
    border-radius: var(--radius);
    padding: 0.6rem 1.2rem;
    display: inline-block;
    font-size: 0.9rem;
    text-align: center;
    transition: background 0.2s;
}
.admin-form a.btn-secondary:hover, .btn-secondary:hover { background: #3a3a5a; color: var(--text); }

/* ── Admin table ────────────────────────────────── */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.admin-table th, .admin-table td {
    padding: 0.65rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.admin-table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.action-cell { white-space: nowrap; display: flex; gap: 0.4rem; align-items: center; }

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    border-radius: var(--radius);
    cursor: pointer;
    border: none;
    display: inline-block;
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c73050; }

.status-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
}
.status-badge.published { background: rgba(123,222,140,0.15); color: #7bde8c; }
.status-badge.draft { background: var(--border); color: var(--muted); }

.muted { color: var(--muted); }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 700px) {
    .page-layout { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .post-title-full { font-size: 1.5rem; }
    .form-row { flex-direction: column; }
}
