:root {
    --bg: #f6f5f2;
    --surface: #fff;
    --text: #1d2126;
    --heading: #0f1418;
    --muted: #666d75;
    --border: #e6e3dd;
    --accent: #c2410c;
    --accent-soft: #fdeee4;
    --code-bg: #1f2329;
    --inline-code: #eeebe5;
    --shadow: 0 1px 2px rgb(16 24 32 / .04), 0 6px 20px rgb(16 24 32 / .06);
    --shadow-hover: 0 2px 4px rgb(16 24 32 / .06), 0 14px 34px rgb(16 24 32 / .13);
    --radius: 14px;
    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171c;
        --surface: #1b1f25;
        --text: #dfe3e8;
        --heading: #f4f6f8;
        --muted: #98a1ab;
        --border: #2a3038;
        --accent: #ff8a4c;
        --accent-soft: #3a2418;
        --code-bg: #0f1216;
        --inline-code: #262c34;
        --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .25);
        --shadow-hover: 0 2px 4px rgb(0 0 0 / .35), 0 14px 34px rgb(0 0 0 / .45);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 17px/1.7 var(--font);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--display); color: var(--heading); letter-spacing: -.015em; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
img, iframe { max-width: 100%; }
img { height: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

body > header, main, body > footer { width: 100%; max-width: 1180px; margin-inline: auto; padding-inline: 16px; }
main { flex: 1; padding-block: 2.5rem 4rem; }

/* ---------- nagłówek ---------- */

body > header {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 2rem; min-height: 68px; max-width: none;
    padding-inline: max(16px, calc((100% - 1148px) / 2));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.logo { display: flex; align-items: center; gap: .6rem; color: var(--heading); text-decoration: none; font: 800 1.25rem var(--display); letter-spacing: -.02em; }
.logo img { display: block; }

body > header nav { margin-left: auto; }
body > header ul { list-style: none; margin: 0; padding: 0; }
body > header nav > ul { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .15rem; }
body > header li { position: relative; }
body > header li a { display: block; padding: .45rem .7rem; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 600; font-size: .93rem; }
body > header li a:hover { background: var(--accent-soft); color: var(--accent); }

body > header li ul {
    position: absolute; top: 100%; left: 0; min-width: 230px; padding: .4rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-hover);
    opacity: 0; visibility: hidden; transition: opacity .15s, visibility .15s;
}
body > header li:hover > ul, body > header li:focus-within > ul { opacity: 1; visibility: visible; }
body > header li ul a { font-weight: 500; }

body > header button { display: none; }

@media (max-width: 960px) {
    body > header { flex-wrap: wrap; justify-content: space-between; gap: 0; }
    body > header button {
        display: block; width: 44px; height: 44px; cursor: pointer;
        border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
        color: var(--heading); font-size: 1.2rem;
    }
    body > header button::before { content: "☰"; }
    body.menu-open > header button::before { content: "✕"; }
    body > header nav { display: none; width: 100%; margin: 0; padding-bottom: 1rem; }
    body.menu-open > header nav { display: block; }
    body > header nav > ul { flex-direction: column; }
    body > header li ul { position: static; opacity: 1; visibility: visible; box-shadow: none; border: 0; background: none; padding: 0 0 0 1rem; min-width: 0; }
}

/* ---------- listy ---------- */

.intro { max-width: 720px; margin-bottom: 2.25rem; }
.intro h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.15; margin: .3rem 0 0; }
.intro .content { margin-top: 1.25rem; }
.crumbs { margin: 0; font-size: .88rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1.5rem; }

.posts article {
    position: relative; display: flex; flex-direction: column; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
}
.posts article:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.posts article > a { display: block; aspect-ratio: 16 / 9; overflow: hidden; }
.posts article > a img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.posts article:hover > a img { transform: scale(1.03); }
.posts article > a span {
    display: grid; place-items: center; height: 100%; padding: 1rem; text-align: center;
    background:
        radial-gradient(circle at 20% 15%, hsl(var(--hue) 75% 72% / .55), transparent 55%),
        linear-gradient(135deg, hsl(var(--hue) 55% 42%), hsl(calc(var(--hue) + 40) 60% 28%));
    color: #fff; font: 700 1.15rem/1.25 var(--display);
}
.posts article > div { display: flex; flex-direction: column; gap: .5rem; padding: 1.15rem 1.25rem 1.4rem; }
.posts small { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; color: var(--muted); font-size: .85rem; }
.posts small a {
    position: relative; z-index: 1; padding: .05rem .6rem; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .78rem; text-decoration: none;
}
.posts h2 { margin: 0; font-size: 1.18rem; line-height: 1.3; }
.posts h2 a { color: var(--heading); text-decoration: none; }
.posts h2 a::after { content: ""; position: absolute; inset: 0; }
.posts article:hover h2 a { color: var(--accent); }
.posts p {
    margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.6;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

@media (min-width: 820px) {
    .highlight article:first-child { grid-column: 1 / -1; display: grid; grid-template-columns: 1.15fr 1fr; }
    .highlight article:first-child > a { aspect-ratio: auto; min-height: 340px; }
    .highlight article:first-child > div { justify-content: center; gap: .8rem; padding: 2.25rem 2.5rem; }
    .highlight article:first-child h2 { font-size: clamp(1.6rem, 2.6vw, 2.15rem); line-height: 1.2; }
    .highlight article:first-child p { font-size: 1.05rem; -webkit-line-clamp: 5; }
}

.pages { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; margin-top: 3rem; color: var(--muted); font-size: .9rem; }
.pages a {
    justify-self: start; padding: .55rem 1.1rem; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
    color: var(--heading); font-weight: 600; text-decoration: none;
}
.pages a:last-child { justify-self: end; }
.pages a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- artykuł ---------- */

.post { max-width: 720px; margin-inline: auto; }
.post h1 { font-size: clamp(2rem, 4.6vw, 3rem); line-height: 1.12; margin: .5rem 0 .8rem; }
.post .date { margin: 0 0 2rem; color: var(--muted); font-size: .9rem; }
.post .cover { display: block; width: 100%; margin: 0 0 2.5rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.note { padding: .7rem 1rem; border-left: 4px solid var(--accent); border-radius: 8px; background: var(--accent-soft); }
.error { text-align: center; padding-top: 3rem; }

/* ---------- treść artykułów (HTML z bazy) ---------- */

.content { font-size: 1.06rem; overflow-wrap: break-word; }
.content > :first-child { margin-top: 0; }
.content h2 { font-size: 1.65rem; line-height: 1.25; margin: 2.8rem 0 .9rem; }
.content h3 { font-size: 1.3rem; line-height: 1.3; margin: 2.2rem 0 .7rem; }
.content h4, .content h5, .content h6 { font-size: 1.08rem; margin: 1.8rem 0 .5rem; }
.content p, .content ul, .content ol { margin: 0 0 1.2rem; }
.content ul, .content ol { padding-left: 1.4rem; }
.content li { margin: .3rem 0; }
.content li::marker { color: var(--accent); }
.content strong { color: var(--heading); }
.content blockquote, .content .pullquote {
    margin: 1.8rem 0; padding: .9rem 1.3rem; border-left: 4px solid var(--accent);
    border-radius: 0 10px 10px 0; background: var(--surface); font-style: italic;
}
.content blockquote p:last-child { margin-bottom: 0; }
.content hr { height: 1px; margin: 3rem 0; border: 0; background: var(--border); }
.content figure { margin: 2rem 0; }
.content figcaption { margin-top: .5rem; color: var(--muted); font-size: .88rem; text-align: center; }
.content img { border-radius: 10px; }
.content .alignright { float: right; max-width: 45%; margin: .3rem 0 1rem 1.75rem; }
.content .alignleft { float: left; max-width: 45%; margin: .3rem 1.75rem 1rem 0; }
.content .aligncenter { margin-inline: auto; text-align: center; }
.content h2, .content h3, .content pre, .content table, .content hr { clear: both; }
.content .text-center { text-align: center; }
.content .text-right { text-align: right; }

.content :not(pre) > code { padding: .12em .4em; border-radius: 5px; background: var(--inline-code); font: .86em var(--mono); }
.content pre {
    margin: 1.8rem 0; padding: 1.1rem 1.25rem; overflow-x: auto; tab-size: 4;
    background: var(--code-bg); color: #e6e6e6; border-radius: 12px; box-shadow: var(--shadow);
    font: .87rem/1.6 var(--mono);
}
.content pre[data-lang]::before, .content pre[data-file]::before {
    content: attr(data-lang); display: block; margin: -.3rem 0 .75rem; padding-bottom: .55rem;
    border-bottom: 1px solid rgb(255 255 255 / .08);
    color: #8b949e; font: 600 .74rem/1 var(--font); letter-spacing: .06em; text-transform: uppercase;
}
.content pre[data-file]::before { content: attr(data-file); }
.content pre code { padding: 0; background: none; font-size: inherit; color: inherit; }
.content pre[class*="language-"], .content code[class*="language-"] { background: none; text-shadow: none; }
.content pre.preformatted { white-space: pre-wrap; background: var(--inline-code); color: var(--text); box-shadow: none; }

.content table { display: block; width: 100%; margin: 1.8rem 0; overflow-x: auto; border-collapse: collapse; font-size: .95rem; }
.content th, .content td { padding: .55rem .75rem; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.content th { background: var(--surface); color: var(--heading); }

.content .columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin: 1.8rem 0; }
.content .media-text { display: grid; grid-template-columns: minmax(80px, 25%) 1fr; gap: 1.25rem; align-items: center; margin: 1.8rem 0; }
.content .media-text.media-right { grid-template-columns: 1fr minmax(80px, 25%); }
.content .media-text-media { margin: 0; }
.content .embed { position: relative; aspect-ratio: 16 / 9; margin: 1.8rem 0; }
.content .embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 12px; }
.content .gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; margin: 1.8rem 0; }
.content .gallery img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.content .math { margin: 1.4rem 0; overflow-x: auto; }

@media (max-width: 640px) {
    body { font-size: 16px; }
    .content .media-text, .content .media-text.media-right { grid-template-columns: 1fr; }
    .content .alignright, .content .alignleft { float: none; max-width: 100%; margin: 1rem auto; }
}

/* ---------- stopka ---------- */

body > footer {
    display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center;
    max-width: none; padding-block: 1.75rem; padding-inline: max(16px, calc((100% - 1148px) / 2));
    border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .9rem;
}
body > footer a { color: var(--muted); text-decoration: none; }
body > footer a:hover { color: var(--accent); }
body > footer span { margin-left: auto; }
