:root {
    --bg: #f7f7fb;
    --surface: #ffffff;
    --surface-soft: #eaf6fe;
    --text: #161622;
    --muted: #5f6170;
    --border: #deddec;
    --brand: #0176d3;
    --brand-dark: #032d60;
    --accent: #00a1e0;
    --code-bg: #101827;
    --code-text: #e5eefc;
    --shadow: 0 16px 45px rgba(17, 24, 39, 0.12);
    --shell: 1180px;
}

[data-theme="dark"] {
    --bg: #0b1020;
    --surface: #121a2d;
    --surface-soft: #132b46;
    --text: #eef2ff;
    --muted: #aab2c8;
    --border: #283552;
    --brand: #4fc3f7;
    --brand-dark: #0176d3;
    --accent: #00a1e0;
    --code-bg: #050816;
    --code-text: #dbeafe;
    --shadow: 0 16px 45px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.65;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--brand); }
img { max-width: 100%; height: auto; }
.shell { width: min(var(--shell), calc(100% - 40px)); margin: 0 auto; }

.promo-strip {
    background: #032d60;
    color: white;
    text-align: center;
    font-weight: 800;
    font-size: 0.88rem;
    padding: 0.55rem 1rem;
}

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.header-main { display: flex; align-items: center; gap: 2rem; padding: 1rem 0; }
.brand { display: inline-flex; align-items: center; gap: 0.8rem; min-width: max-content; }
.brand-mark {
    display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 12px;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: white; font-weight: 900; letter-spacing: -0.05em;
}
.brand strong { display: block; font-size: 1.22rem; letter-spacing: -0.04em; }
.brand small { display: block; color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.09em; }

.global-search { flex: 1; display: flex; border: 1px solid var(--border); background: var(--bg); max-width: 540px; margin-left: auto; }
.global-search input { flex: 1; border: 0; background: transparent; padding: 0.9rem 1rem; color: var(--text); font: inherit; }
.global-search button { border: 0; padding: 0 1rem; background: var(--brand); color: white; font-weight: 800; cursor: pointer; }
.theme-toggle { border: 1px solid var(--border); background: var(--surface-soft); color: var(--text); border-radius: 999px; width: 42px; height: 42px; cursor: pointer; font-weight: 900; }

.topic-nav { background: linear-gradient(90deg, #032d60, #0176d3, #00a1e0); color: white; }
.topic-nav-inner { display: flex; align-items: center; gap: 1.2rem; overflow-x: auto; white-space: nowrap; }
.topic-nav a { display: inline-block; padding: 0.85rem 0; color: white; font-weight: 800; font-size: 0.92rem; }
.topic-nav a:hover { color: #eaf6fe; }

.hero-magazine { padding: 3.2rem 0 2rem; background: radial-gradient(circle at top left, rgba(1, 118, 211, .16), transparent 32%), var(--bg); }
.hero-grid { display: grid; grid-template-columns: 0.88fr 1.12fr; gap: 2rem; align-items: stretch; }
.hero-copy, .featured-panel, .sidebar-card, .article-card, .topic-card, .snippet-card, .page-title-block, .article-body {
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.hero-copy { padding: 2rem; display: flex; flex-direction: column; justify-content: center; }
.kicker { margin: 0 0 0.6rem; color: var(--brand); font-weight: 900; text-transform: uppercase; letter-spacing: .08em; font-size: 0.78rem; }
h1, h2, h3 { line-height: 1.08; letter-spacing: -0.045em; margin-top: 0; }
h1 { font-family: "Roboto Condensed", Inter, sans-serif; font-size: clamp(2.5rem, 6vw, 5.4rem); font-weight: 900; }
h2 { font-family: "Roboto Condensed", Inter, sans-serif; font-size: clamp(1.8rem, 3vw, 2.8rem); }
h3 { font-size: 1.2rem; }
.hero-copy p { color: var(--muted); font-size: 1.08rem; }
.hero-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 1rem; }
.button { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 0; background: var(--accent); color: #ffffff; font-weight: 900; padding: 0.85rem 1.15rem; box-shadow: 5px 5px 0 rgba(0, 0, 0, .14); cursor: pointer; }
.button:hover { color: #ffffff; transform: translate(-1px, -1px); }
.button.ghost { background: var(--surface); border: 2px solid var(--accent); color: var(--text); }
.button-small { font-size: 0.86rem; padding: 0.65rem 0.85rem; }

.featured-panel { display: grid; grid-template-columns: 1fr 1.05fr; min-height: 360px; }
.featured-image, .article-image { background-size: cover; background-position: center; min-height: 240px; }
.featured-content { padding: 2rem; display: flex; flex-direction: column; justify-content: center; }
.featured-content p { color: var(--muted); }
.article-meta { display: flex; flex-wrap: wrap; gap: 0.75rem; color: var(--muted); font-size: 0.88rem; font-weight: 700; }
.article-meta span::before { content: "•"; color: var(--brand); margin-right: .55rem; }
.article-meta span:first-child::before { content: ""; margin: 0; }

.topic-band { padding: 1rem 0 2rem; }
.topic-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.topic-cards.large { margin-bottom: 4rem; }
.topic-card { padding: 1.25rem; border-left: 5px solid var(--accent); }
.topic-card strong { display: block; font-size: 1.18rem; margin-bottom: .35rem; }
.topic-card span { color: var(--muted); font-size: 0.92rem; }
.topic-card:hover { transform: translateY(-2px); }

.content-section, .page-main { padding: 2rem 0 4rem; }
.two-column-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 2rem; align-items: start; }
.section-heading { margin-bottom: 1rem; }
.tab-like-row { display: flex; gap: .45rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab-like-row a { border: 1px solid var(--border); background: var(--surface); padding: .65rem .9rem; font-weight: 800; }
.tab-like-row a:first-child { background: var(--brand); color: white; border-color: var(--brand); }
.article-list { display: grid; gap: 1.2rem; }
.article-card { display: grid; grid-template-columns: 280px 1fr; overflow: hidden; box-shadow: none; }
.article-card-body { padding: 1.4rem; }
.article-card h2 { font-size: clamp(1.5rem, 2.4vw, 2.25rem); margin-bottom: .55rem; }
.article-card p { color: var(--muted); }

.sidebar { display: grid; gap: 1.2rem; position: sticky; top: 150px; }
.sidebar-card { padding: 1.25rem; box-shadow: none; }
.author-card img { width: 72px; height: 72px; object-fit: cover; border-radius: 50%; border: 3px solid var(--brand); }
.trend-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .85rem; }
.trend-list li { border-bottom: 1px solid var(--border); padding-bottom: .85rem; font-weight: 800; }
.accent-card { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: white; }
.accent-card p, .accent-card a { color: white; }
.topic-pills { display: flex; flex-wrap: wrap; gap: .55rem; }
.topic-pills a, .topic-pills span { background: var(--surface-soft); border: 1px solid var(--border); padding: .42rem .6rem; font-weight: 800; font-size: .82rem; }
.accent-card .topic-pills span { color: var(--text); }

.compact-list { display: grid; gap: .65rem; }
.compact-list a { background: var(--surface); border: 1px solid var(--border); padding: 1rem; font-weight: 900; display: flex; justify-content: space-between; gap: 1rem; }
.compact-list span { color: var(--muted); font-size: .85rem; text-transform: uppercase; }
.mini-section { margin-top: 2.5rem; }

.page-title-block { padding: 2rem; margin-bottom: 1.3rem; box-shadow: none; }
.page-title-block p { color: var(--muted); font-size: 1.08rem; }
.filter-bar { display: flex; gap: .7rem; margin-bottom: 1.3rem; }
.filter-bar input, .filter-bar select { min-width: 0; flex: 1; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: .9rem 1rem; font: inherit; }
.filter-bar select { flex: 0 0 180px; }

.article-page { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 2rem; align-items: start; padding: 2rem 0 4rem; }
.article-body { padding: 2.4rem; box-shadow: none; }
.article-body.narrow { max-width: 860px; margin: 0 auto; }
.article-lead { color: var(--muted); font-size: 1.22rem; }
.byline { margin: 1rem 0 1.4rem; }
.article-hero-image { width: 100%; max-height: 420px; object-fit: cover; margin: 0 0 2rem; border: 1px solid var(--border); }
.article-content { font-size: 1.06rem; }
.article-content h2 { margin-top: 2.3rem; font-size: 2rem; }
.article-content p, .article-content li { color: var(--text); }
.article-content a { color: var(--brand); text-decoration: underline; text-decoration-thickness: 2px; }
.article-content pre, .snippet-card pre { background: var(--code-bg); color: var(--code-text); padding: 1rem; overflow-x: auto; border-radius: 0; border-left: 5px solid var(--brand); }
.article-content code, .snippet-card code { font-family: "SFMono-Regular", Consolas, Monaco, monospace; font-size: .92rem; }
.article-content :not(pre) > code { background: var(--surface-soft); padding: .1rem .3rem; color: var(--brand); font-weight: 800; }
.callout { background: var(--surface-soft); border-left: 5px solid var(--accent); padding: 1rem; margin: 1.4rem 0; }
.article-sidebar { display: grid; gap: 1rem; position: sticky; top: 150px; }

.snippet-grid { display: grid; gap: 1rem; }
.snippet-card { padding: 1.3rem; box-shadow: none; }
.about-content { font-size: 1.08rem; }
.about-content p, .about-content li { color: var(--text); }

.site-footer { background: #032d60; color: white; padding: 3rem 0 1rem; }
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 2rem; }
.site-footer p, .site-footer a { color: #d1d5db; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.footer-copy { text-align: center; border-top: 1px solid rgba(255, 255, 255, 0.18); padding-top: 1rem; margin-top: 2rem; }

@media (max-width: 980px) {
    .header-main { flex-wrap: wrap; gap: 1rem; }
    .global-search { order: 3; max-width: none; width: 100%; }
    .hero-grid, .two-column-layout, .article-page, .footer-grid { grid-template-columns: 1fr; }
    .featured-panel, .article-card { grid-template-columns: 1fr; }
    .topic-cards { grid-template-columns: 1fr 1fr; }
    .sidebar, .article-sidebar { position: static; }
}

@media (max-width: 640px) {
    .shell { width: min(100% - 24px, var(--shell)); }
    h1 { font-size: 2.8rem; }
    .topic-cards { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; }
    .filter-bar select { flex-basis: auto; }
    .article-body, .hero-copy, .featured-content, .page-title-block { padding: 1.25rem; }
}

/* --------------------------------------------------------------------------
   Responsive hardening
   Keeps the editorial layout usable across browser zoom levels, tablets and
   small mobile widths without horizontal page overflow.
-------------------------------------------------------------------------- */
html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.site-header,
.promo-strip,
.topic-nav,
.hero-magazine,
.content-section,
.page-main,
.site-footer {
    max-width: 100vw;
}

.header-main,
.hero-grid,
.featured-panel,
.article-card,
.two-column-layout,
.article-page,
.footer-grid,
.topic-cards {
    min-width: 0;
}

.header-main > *,
.hero-grid > *,
.featured-panel > *,
.article-card > *,
.two-column-layout > *,
.article-page > *,
.footer-grid > *,
.topic-cards > * {
    min-width: 0;
}

.global-search input {
    min-width: 0;
}

.topic-nav-inner {
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior-inline: contain;
}

.topic-nav-inner::-webkit-scrollbar {
    display: none;
}

.featured-image,
.article-image {
    width: 100%;
}

@media (max-width: 1180px) {
    :root {
        --shell: 1040px;
    }

    .hero-grid {
        grid-template-columns: 0.95fr 1.05fr;
        gap: 1.4rem;
    }

    h1 {
        font-size: clamp(2.4rem, 5.4vw, 4.6rem);
    }

    .featured-content {
        padding: 1.6rem;
    }
}

@media (max-width: 900px) {
    .site-header {
        position: static;
    }

    .promo-strip {
        font-size: 0.82rem;
        line-height: 1.35;
        padding: 0.65rem 1rem;
    }

    .header-main {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 1rem;
    }

    .brand {
        min-width: 0;
    }

    .brand strong {
        font-size: 1.05rem;
        white-space: normal;
    }

    .global-search {
        grid-column: 1 / -1;
        order: initial;
        margin-left: 0;
    }

    .topic-nav-inner {
        gap: 1rem;
        padding-inline: max(12px, calc((100vw - var(--shell)) / 2));
    }

    .topic-nav a {
        padding: 0.75rem 0;
    }

    .hero-magazine {
        padding: 2.2rem 0 1.5rem;
    }

    .hero-grid,
    .featured-panel,
    .article-card,
    .two-column-layout,
    .article-page,
    .footer-grid {
        grid-template-columns: 1fr;
    }

    .featured-panel {
        min-height: 0;
    }

    .featured-image,
    .article-image {
        min-height: 260px;
    }

    .topic-cards {
        grid-template-columns: 1fr 1fr;
    }

    .sidebar,
    .article-sidebar {
        position: static;
    }
}

@media (max-width: 560px) {
    .shell {
        width: calc(100% - 24px);
    }

    .promo-strip {
        font-size: 0.78rem;
    }

    .header-main {
        grid-template-columns: 1fr auto;
        padding: 0.9rem 0;
    }

    .brand-mark {
        width: 42px;
        height: 42px;
        border-radius: 10px;
    }

    .brand {
        gap: 0.65rem;
    }

    .brand strong {
        font-size: 1rem;
    }

    .brand small {
        font-size: 0.66rem;
        letter-spacing: 0.08em;
    }

    .theme-toggle {
        width: 38px;
        height: 38px;
    }

    .global-search input {
        padding: 0.78rem 0.85rem;
        font-size: 0.92rem;
    }

    .global-search button {
        padding: 0 0.85rem;
    }

    .topic-nav-inner {
        gap: 0.9rem;
        padding-inline: 12px;
    }

    .topic-nav a {
        font-size: 0.86rem;
        padding: 0.65rem 0;
    }

    .hero-copy,
    .featured-content,
    .article-card-body,
    .page-title-block,
    .article-body,
    .snippet-card,
    .sidebar-card,
    .topic-card {
        padding: 1.1rem;
    }

    h1 {
        font-size: clamp(2.05rem, 12vw, 3.1rem);
        line-height: 1.03;
        overflow-wrap: anywhere;
    }

    h2 {
        font-size: clamp(1.65rem, 8vw, 2.25rem);
    }

    .hero-copy p,
    .page-title-block p,
    .article-lead {
        font-size: 1rem;
    }

    .hero-actions,
    .tab-like-row,
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .button,
    .tab-like-row a {
        width: 100%;
    }

    .featured-image,
    .article-image {
        min-height: 210px;
    }

    .topic-cards {
        grid-template-columns: 1fr;
    }

    .article-meta {
        gap: 0.45rem;
    }

    .article-meta span::before {
        margin-right: 0.35rem;
    }

    .article-content pre,
    .snippet-card pre {
        max-width: 100%;
        font-size: 0.82rem;
    }
}

@media (max-width: 380px) {
    .shell {
        width: calc(100% - 18px);
    }

    .brand small {
        display: none;
    }

    .global-search {
        display: grid;
        grid-template-columns: 1fr auto;
    }

    .global-search button {
        font-size: 0.82rem;
    }

    h1 {
        font-size: 2rem;
    }
}

/* --------------------------------------------------------------------------
   Wide viewport / browser zoom compensation
   Browser zoom-out creates a very large CSS viewport. A fixed 1040/1180px
   shell then looks like a narrow column with excessive empty borders. These
   rules let the magazine layout breathe on large logical viewports while
   keeping normal desktop/tablet/mobile behavior intact.
-------------------------------------------------------------------------- */
@media (min-width: 1200px) {
    :root {
        --shell: 1280px;
    }

    .hero-grid {
        grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    }
}

@media (min-width: 1500px) {
    :root {
        --shell: 1400px;
    }
}

@media (min-width: 1800px) {
    :root {
        --shell: 1560px;
    }

    .hero-magazine {
        padding-top: 3.8rem;
    }
}

@media (min-width: 2300px) {
    :root {
        --shell: 1840px;
    }

    .hero-grid {
        grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
        gap: 2.4rem;
    }
}

@media (min-width: 2900px) {
    :root {
        --shell: 2200px;
    }
}

/* Keep the top blocks usable when the browser is zoomed in or the viewport is
   in the awkward tablet range before the mobile breakpoint. */
@media (max-width: 760px) {
    .promo-strip {
        font-size: clamp(0.76rem, 3.4vw, 0.95rem);
    }

    .header-main {
        align-items: start;
    }

    .global-search {
        width: 100%;
    }

    .topic-nav {
        overflow: hidden;
    }

    .topic-nav-inner {
        max-width: 100%;
    }
}

/* Prevent article/sidebar cards from feeling absurdly large when Chrome zoom-in
   reduces the available CSS viewport but text is magnified by the browser. */
@media (max-width: 520px) {
    .article-page,
    .page-main,
    .content-section {
        padding-top: 1.25rem;
    }

    .sidebar-card,
    .article-body {
        font-size: 0.95rem;
    }

    .author-card img {
        width: 58px;
        height: 58px;
    }
}

/* Database-backed rich article blocks */
.code-block {
    margin: 1.75rem 0;
}

.code-block figcaption,
.content-image figcaption {
    color: var(--muted);
    font-size: .9rem;
    font-weight: 800;
    letter-spacing: .03em;
    margin-bottom: .55rem;
    text-transform: uppercase;
}

.content-image {
    margin: 2rem 0;
}

.content-image img {
    border: 1px solid var(--line);
    display: block;
    max-width: 100%;
    width: 100%;
}

.content-gallery {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin: 2rem 0;
}

.content-gallery img {
    aspect-ratio: 16 / 10;
    border: 1px solid var(--line);
    object-fit: cover;
    width: 100%;
}

.content-divider {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 2.5rem 0;
}

.article-content blockquote {
    border-left: 5px solid var(--accent);
    color: var(--text);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 2rem 0;
    padding: 1rem 1.25rem;
}
