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

:root {
    --bg:      #ffffff;
    --surface: #f7f7f7;
    --border:  #e0e0e0;
    --text:    #1a1a1a;
    --muted:   #666666;
    --accent:  #2563eb;
    --danger:  #dc2626;
    --radius:  6px;
    --max:     760px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 17px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
}

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

/* ── Layout ───────────────────────────────────── */
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

header {
    border-bottom: 1px solid var(--border);
    padding: 18px 0;
    margin-bottom: 40px;
}
header .wrap { display: flex; align-items: center; justify-content: space-between; }
header .logo { font-size: 1.2rem; font-weight: 700; color: var(--text); }
header .logo:hover { text-decoration: none; }
header nav a { margin-left: 20px; color: var(--muted); font-size: 0.9rem; }

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

/* ── Post list ────────────────────────────────── */
.post-list { list-style: none; }
.post-list li { padding: 24px 0; border-bottom: 1px solid var(--border); }
.post-list li:first-child { padding-top: 0; }

.post-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 6px; }
.post-title a { color: var(--text); }
.post-title a:hover { color: var(--accent); text-decoration: none; }

.post-meta { font-size: 0.82rem; color: var(--muted); margin-bottom: 10px; }
.post-excerpt { color: #444; }

/* ── Single post ──────────────────────────────── */
.post-header { margin-bottom: 32px; }
.post-header h1 { font-size: 2rem; line-height: 1.3; margin-bottom: 10px; }

.post-body { max-width: 100%; }
.post-body p  { margin-bottom: 1.1em; }
.post-body h2 { font-size: 1.4rem; margin: 1.6em 0 0.5em; }
.post-body h3 { font-size: 1.15rem; margin: 1.4em 0 0.4em; }
.post-body ul, .post-body ol { padding-left: 1.6em; margin-bottom: 1em; }
.post-body li { margin-bottom: 0.3em; }
.post-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1em;
    color: var(--muted);
    margin: 1.2em 0;
}
.post-body code {
    background: var(--surface);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Fira Code', 'Consolas', monospace;
}
.post-body pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 16px 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 1.2em;
}
.post-body pre code { background: none; padding: 0; color: inherit; font-size: 0.88em; }
.post-body img { max-width: 100%; height: auto; border-radius: var(--radius); }
.post-body a { border-bottom: 1px solid; }
.post-body a:hover { border-color: transparent; }

/* ── Pagination ───────────────────────────────── */
.pagination { display: flex; gap: 8px; margin-top: 36px; justify-content: center; }
.pagination a, .pagination span {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--muted);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Admin ────────────────────────────────────── */
.admin-body { background: var(--surface); min-height: 100vh; }
.admin-header {
    background: #1e1e2e;
    color: #fff;
    padding: 14px 0;
    margin-bottom: 32px;
}
.admin-header .wrap { display: flex; align-items: center; justify-content: space-between; }
.admin-header .logo { color: #fff; font-weight: 700; font-size: 1rem; }
.admin-header nav a { color: #aaa; margin-left: 20px; font-size: 0.88rem; }
.admin-header nav a:hover { color: #fff; text-decoration: none; }

.admin-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
}

.btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4ed8; color: #fff; text-decoration: none; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #b91c1c; color: #fff; text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }
.btn-sm { padding: 4px 12px; font-size: 0.82rem; }

/* ── Forms ────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
.form-group input[type=text],
.form-group input[type=password],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--bg);
    transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-group textarea { resize: vertical; min-height: 380px; font-family: 'Fira Code', monospace; font-size: 0.9rem; }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 0.9rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ── Post table ───────────────────────────────── */
.post-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.post-table th { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--border); color: var(--muted); font-weight: 600; }
.post-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.post-table tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 0.78rem; font-weight: 600; }
.badge-pub   { background: #dcfce7; color: #166534; }
.badge-draft { background: #f3f4f6; color: #6b7280; }

/* ── Login ────────────────────────────────────── */
.login-wrap { max-width: 360px; margin: 80px auto; }

@media (max-width: 600px) {
    body { font-size: 16px; }
    .post-header h1 { font-size: 1.5rem; }
}

/* ── Post cover ───────────────────────────────── */
.post-cover {
    margin: 0 0 32px;
    border-radius: var(--radius);
    overflow: hidden;
    max-height: 480px;
}
.post-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Gallery ──────────────────────────────────── */
.post-gallery   { margin-top: 48px; }
.gallery-heading { font-size: 1.1rem; margin-bottom: 16px; }

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.gallery-item {
    margin: 0;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--surface);
}
.gallery-link {
    display: block;
    aspect-ratio: 4/3;
    overflow: hidden;
}
.gallery-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease;
}
.gallery-link:hover img { transform: scale(1.04); }
.gallery-item figcaption {
    font-size: .82rem;
    color: var(--muted);
    padding: 6px 10px 8px;
}

/* ── Lightbox ─────────────────────────────────── */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.92);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.lightbox-inner {
    max-width: 92vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.lightbox-img {
    max-width: 100%;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}
.lightbox-caption {
    color: rgba(255,255,255,.7);
    font-size: .88rem;
    margin-top: 10px;
    text-align: center;
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: fixed;
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(255,255,255,.28); }
.lightbox-close { top: 18px; right: 18px; font-size: 1rem; }
.lightbox-prev  { left: 18px; top: 50%; transform: translateY(-50%); }
.lightbox-next  { right: 18px; top: 50%; transform: translateY(-50%); }

/* ── Tag pills ────────────────────────────────── */
.tag-pill {
    display: inline-block;
    padding: 3px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: .82rem;
    color: var(--muted);
    text-decoration: none;
    transition: border-color .15s, color .15s;
}
.tag-pill:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}
.tag-pill-sm { font-size: .75rem; padding: 2px 8px; }
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Views count ──────────────────────────────── */
.views-count { color: var(--muted); font-size: .82rem; }

/* ── Search form ──────────────────────────────── */
.search-form { margin-bottom: 28px; }
.search-input-wrap {
    display: flex;
    gap: 8px;
}
.search-input-wrap input[type=search] {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
}
.search-input-wrap input[type=search]:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* Подсветка совпадений в результатах поиска */
.search-headline mark {
    background: #fef9c3;
    color: inherit;
    border-radius: 2px;
    padding: 0 2px;
}

/* ── Related posts ────────────────────────────── */
.related-posts {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}
.related-heading {
    font-size: 1rem;
    color: var(--muted);
    margin-bottom: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: .82rem;
}
