.articles-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    align-items: start;
}

.site-topbar {
    padding-block: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.site-topbar nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.site-brand {
    display: grid;
    gap: 0.15rem;
}

.site-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.site-github {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    color: inherit;
}

.site-github svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: currentColor;
}

.theme-switcher {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.theme-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

.theme-switcher select {
    margin-bottom: 0;
    min-width: 7.5rem;
}

#main-content {
    animation: page-enter 220ms ease-out;
}

@keyframes page-enter {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.htmx-swapping {
    opacity: 0.35;
    transition: opacity 160ms ease;
}

.htmx-settling {
    animation: section-enter 180ms ease-out;
}

@keyframes section-enter {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.image-hover {
    position: relative;
}

.image-hover img {
    cursor: zoom-in;
}

.image-hover::after {
    content: attr(data-tip);
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(15, 23, 42, 0.85);
    color: #fff;
    padding: 0.15rem 0.45rem;
    border-radius: 0.35rem;
    font-size: 0.75rem;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 120ms ease, transform 120ms ease;
    pointer-events: none;
}

.image-hover:hover::after {
    opacity: 1;
    transform: translateY(0);
}

.article-card img {
    width: 100%;
    height: 240px;
    object-fit: cover;
    object-position: top center;
}

.preview-card {
    margin-bottom: 1rem;
}

.preview-image {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.preview-card footer {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

#image-preview {
    margin-bottom: 1rem;
}

#content-takeover article {
    max-width: 860px;
    margin-inline: auto;
}

.detail-layout {
    display: grid;
    gap: 1rem;
}

.detail-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.country-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.detail-source-note {
    font-size: 0.92rem;
    opacity: 0.85;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--secondary);
    background: color-mix(in srgb, var(--contrast) 6%, transparent);
    border-radius: 0.5rem;
}

.query-tab[aria-pressed="true"] {
    background: var(--contrast);
    color: var(--contrast-inverse);
}

.detail-table {
    margin-bottom: 0;
}

.detail-table td:first-child {
    font-weight: 600;
    white-space: nowrap;
}

.detail-table td:last-child a[role="button"] {
    margin-bottom: 0;
}

.inline-note {
    border-left: 4px solid var(--primary);
    padding-left: 0.75rem;
    opacity: 0.92;
}

.media-frame img {
    width: 100%;
    border-radius: 0.5rem;
}

.media-embed {
    width: 100%;
    min-height: 340px;
    border: 0;
    border-radius: 0.5rem;
}

.article-card footer a {
    display: inline-block;
    margin-bottom: 0.4rem;
}

@media (max-width: 1100px) {
    .articles-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .site-topbar nav {
        flex-direction: column;
        align-items: flex-start;
    }

    .site-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .articles-grid {
        grid-template-columns: 1fr;
    }

    .media-embed {
        min-height: 220px;
    }
}
