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

body {
    font-family: "Helvetica Neue", sans-serif;
    background-color: #121212;
    color: #fff;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

header {
    position: fixed;
    width: 100%;
    height: 80px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background: #181818;
}

header .logo {
    display: flex;
    align-items: center;
}

header .logo {
    text-decoration: none;
    color: inherit;
}

header .logo img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
}

/* ------------------------------- Search ------------------------------- */

.search-wrap {
    flex: 0 1 320px;
    margin-left: 20px;
}

#search {
    width: 100%;
    padding: 9px 14px;
    font-family: inherit;
    font-size: 15px;
    color: #fff;
    background: #121212;
    border: 1px solid #333;
    border-radius: 999px;
    outline: none;
    transition: border-color .2s;
}

#search::placeholder { color: #777; }
#search:focus { border-color: #fff; }

/* Recolor the native "clear" (X) button to white instead of the default blue. */
#search::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    cursor: pointer;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 6 18 18 M18 6 6 18' stroke='white' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ------------------------------ Layout -------------------------------- */

.container {
    max-width: 760px;
    margin: 0 auto;
    padding: 110px 20px 80px;
}

/* --------------------------- Tag filter bar --------------------------- */

.tag-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 28px;
}

.tag-chip {
    background: transparent;
    border: 1px solid #333;
    border-radius: 999px;
    color: #bbb;
    padding: 5px 12px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all .2s;
}

.tag-chip:hover { border-color: #fff; color: #fff; }
.tag-chip.active { background: #fff; border-color: #fff; color: #121212; }

/* ----------------------------- Post cards ----------------------------- */

.posts-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.post-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: #181818;
    border: 1px solid #232323;
    border-radius: 12px;
    padding: 22px 24px;
    transition: border-color .2s, transform .2s, background .2s;
}

.post-card:hover {
    border-color: #3a3a3a;
    background: #1c1c1c;
    transform: translateY(-2px);
}

.card-title { font-size: 1.5rem; margin-bottom: 6px; }
.card-desc { color: #bbb; line-height: 1.55; margin-bottom: 12px; }

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
    color: #888;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.tag {
    font-size: 12px;
    color: #9aa;
    background: #202020;
    border-radius: 6px;
    padding: 2px 8px;
    text-decoration: none;
}

a.tag:hover { color: #fff; }

.empty, .error { color: #888; text-align: center; padding: 40px 0; }
.error { color: #e57373; }

/* ------------------------------ Post page ----------------------------- */

/* The top bar acts as the post header: back button + title + meta. */
#header.post-bar {
    position: static;
    height: auto;
    padding: 0;
    display: block;
}

.post-bar-inner {
    max-width: 760px;
    margin: 0 auto;
    padding: 26px 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.back-btn {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #333;
    border-radius: 50%;
    color: #fff;
    background: transparent;
    transition: background .2s, color .2s, border-color .2s;
}

.back-btn:hover { background: #fff; color: #121212; border-color: #fff; }

.back-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.post-headline { min-width: 0; }
.post-headline h1 { font-size: 2rem; line-height: 1.2; margin-bottom: 10px; }
.post-headline .tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* On post pages the bar is static, so the body needs far less top padding. */
.container.post-main { padding-top: 36px; }

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 14px;
    color: #888;
    margin-bottom: 12px;
}

.post-content {
    font-size: 1.08rem;
    line-height: 1.75;
    color: #e8e8e8;
}

.post-content h2 { font-size: 1.7rem; margin: 36px 0 14px; }
.post-content h3 { font-size: 1.35rem; margin: 28px 0 12px; }
.post-content h4 { font-size: 1.15rem; margin: 24px 0 10px; }
.post-content p { margin: 0 0 18px; }
.post-content ul, .post-content ol { margin: 0 0 18px; padding-left: 26px; }
.post-content li { margin-bottom: 6px; }
.post-content a { color: #6db3f2; }
.post-content img { max-width: 100%; height: auto; border-radius: 8px; margin: 12px 0; }

.post-content blockquote {
    border-left: 3px solid #444;
    margin: 0 0 18px;
    padding: 4px 18px;
    color: #bbb;
}
.post-content blockquote p:last-child { margin-bottom: 0; }

.post-content code {
    background: #232323;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: .9em;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.post-content pre {
    background: #1b1b1b;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 16px 18px;
    overflow-x: auto;
    margin: 0 0 18px;
}
.post-content pre code { background: none; padding: 0; font-size: .92rem; line-height: 1.6; }

.post-content hr { border: none; border-top: 1px solid #2a2a2a; margin: 32px 0; }

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 18px;
    font-size: .95rem;
    display: block;
    overflow-x: auto;
}
.post-content th,
.post-content td {
    border: 1px solid #2a2a2a;
    padding: 9px 13px;
    text-align: left;
}
.post-content thead th { background: #1b1b1b; font-weight: 600; }
.post-content tbody tr:nth-child(even) { background: #161616; }

/* ------------------------------- Likes -------------------------------- */

.post-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid #2a2a2a;
    display: flex;
    justify-content: center;
}

.like-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: transparent;
    border: 1px solid #333;
    border-radius: 999px;
    color: #ccc;
    padding: 9px 20px;
    font-size: 16px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color .2s, color .2s;
}

.like-btn:hover { border-color: #555; }

.like-btn .heart {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    transition: transform .15s ease;
}

.like-btn.liked { color: #ff4d6d; border-color: #ff4d6d; }
.like-btn.liked .heart { fill: #ff4d6d; stroke: #ff4d6d; animation: heart-pop .3s ease; }

@keyframes heart-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

/* ----------------------------- Responsive ----------------------------- */

@media (max-width: 600px) {
    header { padding: 0 14px; }
    .search-wrap { flex-basis: 180px; margin-left: 12px; }
    .container { padding: 100px 16px 60px; }
    .post-header h1 { font-size: 2rem; }
    .card-title { font-size: 1.3rem; }
}