:root {
    /* SHABD Design System */
    --ink-primary: #1c1c1e;
    --ink-secondary: #52525b;
    --paper-bg: #f5f5f0;
    --card-bg: #ffffff;
    --accent-color: #bc4749;
    --border-line: #e4e4e7;
    --radius-sharp: 4px;
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background-color: var(--paper-bg);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    color: var(--ink-primary);

    /* App Shell Foundation */
    height: 100vh;
    width: 100vw;
    margin: 0;
    overflow: hidden;
    /* Hide main browser scrollbars entirely */

    display: flex;
    flex-direction: column;
}

/* Inner Scrollable Container */
.scrollable-content {
    flex: 1;
    overflow-y: auto;
    /* Scrollbar belongs to this container only */
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;

    /* Hide scrollbar for Chrome, Safari and Opera */
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.scrollable-content::-webkit-scrollbar {
    display: none;
    /* WebKit */
}

.main-content {
    flex: 1;
}

/* --- Unified Navbar (App Shell Header) --- */
.navbar {
    height: 70px;
    /* Fixed Height */
    padding: 0 2rem;
    background: rgba(245, 245, 240, 0.95);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(8px);

    flex-shrink: 0;
    /* Guarantee never shrinks */
    z-index: 100;

    /* Rigid 3-Column Grid for consistent spacing */
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

/* Left: Logo Section */
.nav-left {
    grid-column: 1;
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: flex-start;
}

.logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--ink-primary);
}

/* Center: Search Section */
.nav-search {
    grid-column: 2;
    width: 400px;
    position: relative;
    justify-self: center;
    /* Locks into exact middle of grid */
}

.search-input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.8rem;
    border: 1px solid var(--border-line);
    border-radius: 50px;
    background: var(--card-bg);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    color: var(--ink-primary);
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--ink-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-secondary);
    font-size: 0.9rem;
    pointer-events: none;
}

/* Right: Actions Section */
.nav-actions {
    grid-column: 3;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    /* Always pushed to right edge */
    gap: 1.5rem;
}

.nav-actions a {
    text-decoration: none;
    color: var(--ink-primary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-actions a:hover {
    color: var(--accent-color);
}

.active-link {
    color: var(--ink-primary) !important;
    font-weight: 700 !important;
    border-bottom: 2px solid var(--accent-color);
}

.nav-badge {
    background-color: var(--accent-color);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 12px;
    margin-left: 6px;
    display: inline-block;
}

/* Menu Button (Mobile) */
.menu-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--ink-primary);
    cursor: pointer;
    padding: 5px;
    display: none;
    /* Hidden on desktop */
}

/* btn */
.btn-nav {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--ink-primary);
    border-radius: var(--radius-sharp);
    color: var(--ink-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

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


/* --- Sidebar & Overlay --- */
.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: var(--paper-bg);
    border-right: 1px solid var(--border-line);
    padding: 2rem;
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.05);
}

.sidebar.open {
    left: 0;
}

.sidebar a {
    text-decoration: none;
    color: var(--ink-secondary);
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar a:hover {
    color: var(--ink-primary);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* --- Responsive Design --- */
@media (max-width: 900px) {
    .navbar {
        height: auto;
        /* Allow header to expand on mobile */
        padding: 1rem;

        display: grid;
        grid-template-columns: 1fr auto;
        /* Logo left, Hamburger right */
        grid-template-rows: auto auto;
        /* Two rows */
        row-gap: 1rem;
    }

    .nav-left {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        justify-content: flex-start;
    }

    .menu-btn {
        display: block;
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        justify-self: end;
    }

    .nav-actions {
        display: none;
        /* Hide standard links on mobile */
    }

    /* Search bar drops to second row and takes full width */
    .nav-search {
        grid-column: 1 / 3;
        grid-row: 2 / 3;
        width: 100%;
        max-width: none;
        margin: 0;
    }

    .article-card {
        grid-template-columns: 1fr;
        grid-template-rows: 250px auto;
    }

    .feed-container {
        padding: 1.5rem 1rem;
    }
}

/* Toast */
.custom-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--ink-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sharp);
    display: none;
    z-index: 2000;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.new-post-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--ink-primary);
    color: white;
    padding: 1rem;
    border-radius: 4px;
    opacity: 0;
    transform: translateY(-20px);
    transition: 0.3s;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 250px;
}

/* --- Feed Item Global Styles --- */
.feed-container {
    max-width: 900px;
    margin: 3rem auto;
    padding: 0 1rem;
}

.article-card {
    background: var(--card-bg);
    border: 1px solid var(--border-line);
    border-radius: var(--radius-sharp);
    margin-bottom: 2.5rem;
    display: grid;
    grid-template-columns: minmax(150px, 30%) 1fr;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s ease;
    min-height: 220px;
}

.article-card:hover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
    border-color: rgba(0, 0, 0, 0.1);
}

.article-image-wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    background-color: #fafafa;
}

.article-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.article-card:hover .article-image {
    transform: scale(1.03);
}

.article-content {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.article-meta {
    font-size: 0.8rem;
    color: var(--ink-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    gap: 10px;
    align-items: center;
}

.article-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.7rem;
    line-height: 1.25;
    color: var(--ink-primary);
    margin-bottom: 0.8rem;
}

.article-excerpt {
    font-size: 1rem;
    color: var(--ink-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--ink-secondary);
    padding-top: 1rem;
    border-top: 1px solid var(--border-line);
}

.stats-group {
    display: flex;
    gap: 15px;
}