/* ==========================================================================
   SW Editorial — theme stylesheet
   Scandinavian functionalism with warm editorial type.
   Rule: components use tokens only. Raw colour values live in section 1.
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */

:root {
    color-scheme: light;

    /* Light ("paper") */
    --bg: #f6f3ec;
    --bg-glass: rgba(246, 243, 236, 0.86);
    --surface: #fffdf8;
    --surface-2: #efebe1;
    --fg: #1c1917;
    --fg-dim: #44403a;
    --fg-faint: #6b645e;          /* guide #78716c darkened: 5.3:1 on bg at 11.5px */
    --accent: #e8451a;            /* brand: focus rings, marks, progress */
    --accent-strong: #c2370f;     /* AA for text and button fills (4.9:1 on bg) */
    --accent-hover: #a82e0a;
    --on-accent: #fffdf8;
    --border: #e1dccf;
    --border-strong: #cbc4b4;
    --ok: #146c43;
    --ok-bg: #e8f5ee;
    --ok-border: #b7dfc8;
    --err: #b42318;
    --err-bg: #fdecea;
    --err-border: #f3c1bb;
    --code-bg: #12151b;
    --code-fg: #f6f3ec;

    /* Type */
    --font-display: 'Bricolage Grotesque', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-ui: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'Spline Sans Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --font-hand: 'Caveat', 'Segoe Print', cursive;

    /* Shape, spacing (4px grid), motion */
    --r-1: 10px;
    --r-2: 16px;
    --r-3: 20px;
    --r-pill: 999px;
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-6: 24px;
    --s-8: 32px;
    --s-12: 48px;
    --s-16: 64px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --dur: 0.15s;

    /* Layout */
    --container: 72rem;
    --measure: 41rem;   /* reading column */
    --wide: 60rem;      /* tables, images, code */
    --header-h: 64px;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0c0e12;
    --bg-glass: rgba(12, 14, 18, 0.86);
    --surface: #12151b;
    --surface-2: #181c24;
    --fg: #f6f3ec;
    --fg-dim: #c9c4b8;
    --fg-faint: #8e897d;
    --accent: #ff5a2d;
    --accent-strong: #ff5a2d;
    --accent-hover: #ff7550;
    --on-accent: #180e08;
    --border: #232833;
    --border-strong: #343b49;
    --ok: #4fc58a;
    --ok-bg: #10241a;
    --ok-border: #1d4a33;
    --err: #ff8a7a;
    --err-bg: #2a1311;
    --err-border: #5a2a25;
    --code-bg: #080a0d;
    --code-fg: #f6f3ec;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0c0e12;
        --bg-glass: rgba(12, 14, 18, 0.86);
        --surface: #12151b;
        --surface-2: #181c24;
        --fg: #f6f3ec;
        --fg-dim: #c9c4b8;
        --fg-faint: #8e897d;
        --accent: #ff5a2d;
        --accent-strong: #ff5a2d;
        --accent-hover: #ff7550;
        --on-accent: #180e08;
        --border: #232833;
        --border-strong: #343b49;
        --ok: #4fc58a;
        --ok-bg: #10241a;
        --ok-border: #1d4a33;
        --err: #ff8a7a;
        --err-bg: #2a1311;
        --err-border: #5a2a25;
        --code-bg: #080a0d;
        --code-fg: #f6f3ec;
    }
}

/* 2. Base ------------------------------------------------------------------ */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--fg-dim);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 640;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--fg);
    text-wrap: balance;
}

p { margin: 0 0 var(--s-4); }
ul, ol { margin: 0; padding: 0; }
img, svg, video { max-width: 100%; height: auto; }
figure { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

a {
    color: var(--accent-strong);
    text-underline-offset: 0.2em;
}

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

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

::selection {
    background: var(--accent);
    color: var(--on-accent);
}

.screen-reader-text,
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: var(--s-2);
    left: var(--s-2);
    z-index: 100;
    padding: var(--s-3) var(--s-4);
    color: var(--on-accent);
    background: var(--accent-strong);
    border-radius: var(--r-1);
    text-decoration: none;
    transform: translateY(-200%);
}

.skip-link:focus { transform: translateY(0); }

.icon { flex: none; }
.muted { color: var(--fg-faint); }

/* 3. Layout primitives -------------------------------------------------- */

.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: max(var(--s-4), env(safe-area-inset-left)) max(var(--s-4), env(safe-area-inset-right));
}

.container--prose { max-width: calc(var(--measure) + 2rem); }
.container--wide { max-width: calc(var(--wide) + 2rem); }

.site-main { display: block; min-height: 60vh; }

.section { padding-block: clamp(48px, 7vw, 96px); }
.section + .section { border-top: 1px solid var(--border); }

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s-4) var(--s-6);
    margin-bottom: var(--s-8);
}

.section-title {
    margin-top: var(--s-2);
    font-size: clamp(1.75rem, 1.25rem + 1.8vw, 2.5rem);
    max-width: 28ch;
}

.section-title--sm { font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem); }

.section-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2) var(--s-6);
}

.label {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.71875rem;     /* 11.5px */
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-faint);
}

.hand {
    margin-bottom: var(--s-2);
    font-family: var(--font-hand);
    font-size: 1.75rem;
    font-weight: 500;
    line-height: 1.1;
    color: var(--accent-strong);
}

.grid { display: grid; gap: var(--s-6); grid-template-columns: 1fr; }
.grid + .grid, .post-card--featured + .grid { margin-top: var(--s-6); }

@media (min-width: 640px) {
    .grid--2,
    .grid--3,
    .grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .grid--3 { grid-template-columns: repeat(3, 1fr); }
    .grid--4 { grid-template-columns: repeat(4, 1fr); }
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-2);
}

/* 4. Buttons, chips, links ---------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: 44px;
    padding: 0 var(--s-6);
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    font-family: var(--font-ui);
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
        color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    color: var(--on-accent);
    background: var(--accent-strong);
}

.btn-primary:hover {
    color: var(--on-accent);
    background: var(--accent-hover);
}

.btn-ghost {
    color: var(--fg);
    background: transparent;
    border-color: var(--border-strong);
}

.btn-ghost:hover,
.btn-ghost:active {
    color: var(--fg);
    background: var(--surface-2);
}

.btn[disabled] { opacity: 0.6; cursor: wait; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--fg-dim);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-pill);
    text-decoration: none;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.icon-btn:hover,
.icon-btn:active {
    color: var(--fg);
    background: var(--surface-2);
}

@media (pointer: coarse) {
    .icon-btn { width: 44px; height: 44px; }
}

.text-link {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-height: 40px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--fg);
    text-decoration: none;
}

.text-link:hover { color: var(--accent-strong); }
.text-link .icon { transition: transform var(--dur) var(--ease); }
.text-link:hover .icon { transform: translateX(3px); }

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    margin-bottom: var(--s-8);
}

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 var(--s-4);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--fg-dim);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    text-decoration: none;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.chip:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--fg); }
.chip[aria-current="page"] { color: var(--on-accent); background: var(--fg); border-color: var(--fg); }

/* 5. Header ---------------------------------------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-glass);
    border-bottom: 1px solid var(--border);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    backdrop-filter: saturate(1.4) blur(12px);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: var(--s-4);
    min-height: var(--header-h);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--s-3);
    min-height: 44px;
    color: var(--fg);
    text-decoration: none;
}

/* Site mark (inline SVG from sw_logo_mark): inverts with the theme tokens */
.logo-mark { display: block; flex: none; }
.logo-tile { fill: var(--fg); }

.logo-dial,
.logo-book {
    fill: none;
    stroke: var(--bg);
    stroke-linecap: round;
    stroke-linejoin: round;
}

.logo-dial { stroke-width: 2.5; }
.logo-book { stroke-width: 2.8; }
.logo-north { fill: var(--accent); }
.logo-south { fill: var(--bg); }
.logo-pivot { fill: var(--fg); }

/* The needle swings a little when the mark is hovered. */
.logo-north,
.logo-south,
.logo-pivot {
    transform-box: view-box;
    transform-origin: 24px 15.5px;
    transition: transform 0.4s var(--ease);
}

.brand:hover .logo-north,
.brand:hover .logo-south { transform: rotate(18deg); }

.brand-name {
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 640;
    letter-spacing: -0.02em;
}

.nav-list {
    display: flex;
    gap: var(--s-1);
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-list a,
.nav-list .current-menu-item > a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 var(--s-4);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--fg-dim);
    border-radius: var(--r-pill);
    text-decoration: none;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.nav-list a:hover,
.nav-list a[aria-current="page"],
.nav-list .current-menu-item > a {
    color: var(--fg);
    background: var(--surface-2);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--s-1);
    margin-left: auto;
}

/* sun/moon: show the icon of the theme you would switch to */
.theme-toggle-sun { display: none; }
.theme-toggle-moon { display: inline-flex; }
:root[data-theme="dark"] .theme-toggle-sun { display: inline-flex; }
:root[data-theme="dark"] .theme-toggle-moon { display: none; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle-sun { display: inline-flex; }
    :root:not([data-theme="light"]) .theme-toggle-moon { display: none; }
}

.nav-toggle-close { display: none; }
.site-header.is-open .nav-toggle-open { display: none; }
.site-header.is-open .nav-toggle-close { display: inline-flex; }

@media (min-width: 768px) {
    .site-nav { margin-left: auto; }
    .header-actions { margin-left: 0; }
    .nav-toggle { display: none; }
}

@media (max-width: 767.98px) {
    .site-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        display: none;
        padding: var(--s-2) max(var(--s-4), env(safe-area-inset-left)) var(--s-4);
        background: var(--surface);
        border-bottom: 1px solid var(--border);
    }

    .site-header.is-open .site-nav { display: block; }
    .nav-list { flex-direction: column; }
    .nav-list a { min-height: 48px; width: 100%; font-size: 1rem; }
}

/* 6. Front page --------------------------------------------------------- */

.hero { padding-block: clamp(40px, 7vw, 96px) clamp(32px, 5vw, 56px); }

.hero-grid {
    display: grid;
    gap: var(--s-12);
    align-items: center;
}

@media (min-width: 900px) {
    .hero-grid { grid-template-columns: 1.2fr 0.8fr; gap: var(--s-16); }
}

.hero-title {
    font-size: clamp(2.25rem, 1.2rem + 4.2vw, 4.25rem);
    line-height: 1.04;
    margin-bottom: var(--s-6);
}

.lead {
    max-width: 38rem;
    font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.1875rem);
    line-height: 1.65;
    color: var(--fg-dim);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-3);
    margin-top: var(--s-8);
}

.hero-portrait {
    justify-self: center;
    width: min(100%, 22rem);
    text-align: center;
}

.hero-portrait img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
    object-position: 50% 20%;
    border-radius: var(--r-3);
    border: 1px solid var(--border);
}

.hero-portrait figcaption { margin-top: var(--s-4); }

@keyframes sw-rise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero-copy > * { animation: sw-rise 0.6s var(--ease) both; }
.hero-copy > :nth-child(2) { animation-delay: 0.05s; }
.hero-copy > :nth-child(3) { animation-delay: 0.1s; }
.hero-copy > :nth-child(4) { animation-delay: 0.15s; }

.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--r-2);
    overflow: hidden;
}

@media (min-width: 768px) {
    .stats { grid-template-columns: repeat(4, 1fr); }
}

.stats li {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    padding: var(--s-6);
    background: var(--surface);
}

.stat-value {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
    font-weight: 640;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--fg);
}

/* Post cards */
.post-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.post-card:hover { border-color: var(--border-strong); }
.post-card:active { background: var(--surface-2); }

.post-card-media {
    display: block;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--surface-2);
}

.post-card-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 15%;   /* favour the top of tall app screenshots */
}

.post-card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--s-2);
    padding: var(--s-6);
}

.post-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-1) var(--s-2);
}

.post-card-cat { color: var(--accent-strong); }

.post-card-title {
    font-size: 1.25rem;
    line-height: 1.25;
}

.post-card-title a {
    color: inherit;
    text-decoration: none;
}

/* Whole card is clickable via the title link */
.post-card-title a::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

.post-card-excerpt {
    flex: 1;
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--fg-dim);
}

.post-card .text-link,
.post-card .btn {
    position: relative;
    z-index: 2;
    align-self: flex-start;
    margin-top: var(--s-2);
}

.post-card--featured { margin-bottom: 0; }

@media (min-width: 768px) {
    .post-card--featured { display: grid; grid-template-columns: 1.15fr 1fr; }
    .post-card--featured .post-card-media { aspect-ratio: auto; min-height: 100%; }
    .post-card--featured .post-card-body { justify-content: center; padding: var(--s-12); gap: var(--s-3); }
    .post-card--featured .post-card-title { font-size: clamp(1.5rem, 1.1rem + 1.2vw, 2.125rem); }
    .post-card--featured .post-card-excerpt { flex: 0 0 auto; font-size: 1.0625rem; }
}

/* Topics */
.topics { margin: 0; padding: 0; list-style: none; }

.topic-card {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    height: 100%;
    padding: var(--s-6);
    text-decoration: none;
    color: var(--fg-dim);
    transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.topic-card:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--fg-dim); }

.topic-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 640;
    letter-spacing: -0.02em;
    color: var(--fg);
}

.topic-blurb { flex: 1; font-size: 0.9375rem; line-height: 1.55; }

.topic-count {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    margin-top: var(--s-2);
}

/* About */
.about-grid {
    display: grid;
    gap: var(--s-8);
}

@media (min-width: 900px) {
    .about-grid { grid-template-columns: 0.9fr 1.1fr; gap: var(--s-16); }
}

.prose-lite { font-size: 1.0625rem; line-height: 1.7; }
.prose-lite h3 { margin: var(--s-8) 0 var(--s-2); font-size: 1.25rem; }

.facts {
    display: grid;
    gap: 1px;
    margin: var(--s-8) 0 0;
    padding: 0;
    list-style: none;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--r-2);
    overflow: hidden;
}

.facts li {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    padding: var(--s-4) var(--s-6);
    background: var(--surface);
    font-size: 1rem;
    color: var(--fg);
}

/* Bookshelf */
.books {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s-6) var(--s-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (min-width: 640px) { .books { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .books { grid-template-columns: repeat(6, 1fr); } }

.book {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    text-decoration: none;
    color: var(--fg);
}

.book img {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-1);
    transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.book:hover img { transform: translateY(-3px); border-color: var(--border-strong); }

.book-title {
    margin-top: var(--s-2);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author { font-size: 0.75rem; color: var(--fg-faint); line-height: 1.3; }

/* Connect */
.connect {
    display: grid;
    gap: var(--s-8);
    padding: clamp(24px, 5vw, 56px);
    border-radius: var(--r-3);
}

@media (min-width: 900px) {
    .connect { grid-template-columns: 1fr 1fr; align-items: center; gap: var(--s-16); }
}

.connect-copy .section-title { margin-bottom: var(--s-4); }
.connect-copy p { max-width: 32rem; }

/* 6b. About page (CV layout) ---------------------------------------------- */

.hero-title--sm { font-size: clamp(2rem, 1.2rem + 3vw, 3.25rem); }
.hero--about { padding-bottom: clamp(24px, 4vw, 48px); }

.cv { padding-bottom: clamp(24px, 5vw, 56px); }

.cv-section {
    display: grid;
    gap: var(--s-4);
    padding-block: var(--s-8);
    border-top: 1px solid var(--border);
}

@media (min-width: 768px) {
    .cv-section { grid-template-columns: 11rem 1fr; gap: var(--s-8); padding-block: var(--s-12); }
    .cv-label { padding-top: 0.35rem; }
}

.cv-body { margin: 0; padding: 0; list-style: none; max-width: 44rem; }
.cv-body.prose-lite p { margin-bottom: var(--s-4); }
.cv-subhead { margin: var(--s-6) 0 var(--s-2); }

.timeline { display: grid; gap: var(--s-8); }

.timeline-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-1) var(--s-4);
}

.timeline-org {
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.timeline-roles {
    display: grid;
    gap: var(--s-2);
    margin: var(--s-3) 0 0;
    padding: 0;
    list-style: none;
}

.timeline-roles li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--s-1) var(--s-4);
}

.timeline-role { font-weight: 600; color: var(--fg); }
.timeline-summary { margin: var(--s-2) 0 0; font-size: 0.9375rem; line-height: 1.6; color: var(--fg-dim); }

.timeline-roles--edu { gap: var(--s-4); margin-top: 0; }
.timeline-roles--edu li { align-items: flex-start; }
.edu-school { display: block; font-size: 0.9375rem; color: var(--fg-dim); }

.pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}

.pill-list li {
    padding: var(--s-2) var(--s-4);
    font-size: 0.9375rem;
    color: var(--fg-dim);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
}

.plain-list { display: grid; gap: var(--s-2); margin: 0; padding: 0; list-style: none; }

.plain-list li {
    position: relative;
    padding-left: var(--s-4);
    color: var(--fg);
}

.plain-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.7em;
    width: 6px;
    height: 6px;
    border-radius: var(--r-pill);
    background: var(--accent);
}

/* 7. Page headers & utility pages ---------------------------------------- */

.page-header {
    padding-block: clamp(40px, 6vw, 80px) clamp(24px, 4vw, 40px);
}

.page-title {
    margin-top: var(--s-2);
    font-size: clamp(2rem, 1.3rem + 2.8vw, 3.25rem);
    max-width: 22ch;
}

.page-desc {
    max-width: 40rem;
    margin-top: var(--s-4);
    font-size: 1.125rem;
    line-height: 1.65;
    color: var(--fg-dim);
}

.page-desc p:last-child { margin-bottom: 0; }

.search-wrap { margin-bottom: var(--s-12); max-width: 36rem; }

.search-form { display: flex; gap: var(--s-2); }

.search-field,
.field {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    padding: 0 var(--s-4);
    font-size: 1rem;              /* 16px: stops iOS zoom on focus */
    color: var(--fg);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-pill);
}

.search-field::placeholder,
.field::placeholder { color: var(--fg-faint); }

.search-field:focus,
.field:focus {
    border-color: var(--accent);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.not-found-actions { margin-top: 0; margin-bottom: var(--s-16); }
.not-found-title { margin-bottom: var(--s-6); }
.empty { padding-block: var(--s-8); font-size: 1.0625rem; color: var(--fg-faint); }
.standalone { padding-block: clamp(40px, 8vw, 96px); }

/* Pagination */
.navigation.pagination { margin-top: var(--s-12); }

.navigation.pagination .nav-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--s-2);
}

.navigation.pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-height: 40px;
    min-width: 40px;
    padding: 0 var(--s-4);
    justify-content: center;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--fg-dim);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    text-decoration: none;
    transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.navigation.pagination a.page-numbers:hover { background: var(--surface-2); border-color: var(--border-strong); }
.navigation.pagination .page-numbers.current { color: var(--on-accent); background: var(--fg); border-color: var(--fg); }
.navigation.pagination .page-numbers.dots { background: transparent; border-color: transparent; }

/* 8. Single post & page -------------------------------------------------- */

.progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    height: 3px;
    pointer-events: none;
}

.progress span {
    display: block;
    height: 100%;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left center;
}

.entry-header { padding-block: clamp(40px, 6vw, 80px) var(--s-8); }

.entry-cats a { color: var(--accent-strong); text-decoration: none; }
.entry-cats a:hover { text-decoration: underline; }

.entry-title {
    margin: var(--s-3) 0 var(--s-6);
    font-size: clamp(2rem, 1.3rem + 2.8vw, 3.25rem);
    line-height: 1.08;
}

.entry-dek {
    margin: 0 0 var(--s-6);
    font-size: 1.1875rem;
    line-height: 1.6;
    color: var(--fg-dim);
}

.entry-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-1) var(--s-4);
    font-size: 0.9375rem;
    color: var(--fg-faint);
}

.entry-meta .avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
}

.entry-author a { color: var(--fg); font-weight: 600; text-decoration: none; }
.entry-author a:hover { text-decoration: underline; }

.entry-meta-item { display: inline-flex; align-items: center; gap: var(--s-1); }

.entry-media { margin-bottom: var(--s-12); }

.entry-media img {
    display: block;
    width: 100%;
    max-height: 34rem;
    object-fit: cover;
    object-position: 50% 0;
    border: 1px solid var(--border);
    border-radius: var(--r-3);
}

.entry-footer { padding-block: var(--s-12) var(--s-8); }

.share {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-3);
    padding-block: var(--s-4);
    border-block: 1px solid var(--border);
}

.share-buttons { display: flex; align-items: center; gap: var(--s-1); }
.share-status { margin-left: var(--s-2); font-size: 0.8125rem; color: var(--ok); }

.tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2);
    margin-top: var(--s-6);
}

.tags a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 var(--s-3);
    font-size: 0.8125rem;
    color: var(--fg-dim);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    text-decoration: none;
}

.tags a:hover { background: var(--surface-2); color: var(--fg); }

.author-card {
    display: flex;
    gap: var(--s-4);
    margin-top: var(--s-8);
    padding: var(--s-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-2);
}

.author-card-photo {
    flex: none;
    width: 64px;
    height: 64px;
    object-fit: cover;
    object-position: 50% 0;
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
}

.author-card-name {
    margin: 0 0 var(--s-1);
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 640;
    color: var(--fg);
}

.author-card-bio { margin: 0; font-size: 0.9375rem; line-height: 1.55; }

.subscribe-band { padding-block: var(--s-8) var(--s-12); }

.post-nav {
    display: grid;
    gap: var(--s-4);
    padding-block: var(--s-8);
}

@media (min-width: 640px) {
    .post-nav { grid-template-columns: 1fr 1fr; }
}

.post-nav-link {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    padding: var(--s-4) var(--s-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-2);
    text-decoration: none;
    transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.post-nav-link:hover { border-color: var(--border-strong); background: var(--surface-2); }
.post-nav-link--next { text-align: right; align-items: flex-end; }
.post-nav-link .label { display: inline-flex; align-items: center; gap: var(--s-1); }

.post-nav-title {
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 640;
    line-height: 1.3;
    color: var(--fg);
}

.related { border-top: 1px solid var(--border); }
.comments-wrap { padding-block: var(--s-8) var(--s-16); }

/* 9. Prose (post and page content) -------------------------------------- */

.prose {
    max-width: calc(var(--wide) + 2rem);
    margin-inline: auto;
    padding-inline: max(var(--s-4), env(safe-area-inset-left)) max(var(--s-4), env(safe-area-inset-right));
    font-size: 1.0625rem;
    line-height: 1.75;
    color: var(--fg-dim);
    overflow-wrap: break-word;
}

@media (min-width: 768px) { .prose { font-size: 1.125rem; } }

.prose > * {
    max-width: var(--measure);
    margin: 0 auto var(--s-6);
}

.prose > :is(figure, pre, iframe, video, .sw-table-wrap, .wp-block-table, .wp-block-image,
    .wp-block-embed, .wp-block-columns, .wp-block-gallery, .wp-block-group, .wp-block-cover) {
    max-width: min(100%, var(--wide));
}

.prose strong, .prose b { font-weight: 650; color: var(--fg); }

.prose a {
    color: var(--accent-strong);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

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

.prose :is(h2, h3, h4) { scroll-margin-top: calc(var(--header-h) + 24px); }

.prose h2 {
    margin-top: var(--s-16);
    margin-bottom: var(--s-4);
    font-size: clamp(1.5rem, 1.25rem + 0.9vw, 1.875rem);
}

.prose h3 {
    margin-top: var(--s-12);
    margin-bottom: var(--s-3);
    font-size: clamp(1.2rem, 1.1rem + 0.4vw, 1.4rem);
}

.prose h4 {
    margin-top: var(--s-8);
    margin-bottom: var(--s-2);
    font-size: 1.0625rem;
}

.prose > :first-child { margin-top: 0; }

.prose ul, .prose ol { padding-left: var(--s-6); }
.prose ul { list-style: disc outside; }
.prose ol { list-style: decimal outside; }
.prose ul ul { list-style: circle outside; }
.prose li { margin-bottom: var(--s-2); padding-left: var(--s-1); }
.prose li::marker { color: var(--fg-faint); }
.prose li > :is(ul, ol) { margin-top: var(--s-2); margin-bottom: 0; }

.prose blockquote {
    padding: var(--s-4) var(--s-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--r-1) var(--r-1) 0;
    color: var(--fg-dim);
}

.prose blockquote > :last-child { margin-bottom: 0; }

.prose hr {
    max-width: 8rem;
    margin-block: var(--s-12);
    border: 0;
    border-top: 1px solid var(--border-strong);
}

/* Code */
.prose :not(pre) > code {
    padding: 0.12em 0.4em;
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--fg);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.prose pre {
    margin-block: var(--s-8);
    padding: var(--s-6);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.7;
    tab-size: 2;
    white-space: pre;
    color: var(--code-fg);
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-2);
}

.prose pre code {
    padding: 0;
    font-size: inherit;
    color: inherit;
    background: none;
    border: 0;
}

.prose kbd {
    padding: 0.1em 0.45em;
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 6px;
}

/* Images & captions */
.prose figure { margin-block: var(--s-8); }

.prose img:not(.emoji):not(.wp-smiley) {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: var(--r-2);
}

.prose figure img { display: block; margin-inline: auto; }

.prose figcaption {
    margin-top: var(--s-3);
    font-size: 0.8125rem;
    line-height: 1.5;
    text-align: center;
    color: var(--fg-faint);
}

.alignleft { float: left; margin: var(--s-2) var(--s-6) var(--s-4) 0; }
.alignright { float: right; margin: var(--s-2) 0 var(--s-4) var(--s-6); }
.aligncenter { display: block; margin-inline: auto; }

/* Tables (wrapped in .sw-table-wrap by functions.php so wide ones scroll) */
.sw-table-wrap {
    width: fit-content;
    min-width: min(100%, var(--measure));
    max-width: 100%;
    margin: var(--s-8) auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-2);
}

.prose table {
    width: 100%;
    min-width: 30rem;
    margin: 0;
    border-collapse: collapse;
    font-size: 0.9375rem;
    line-height: 1.55;
    text-align: left;
}

.prose :is(th, td) {
    padding: var(--s-3) var(--s-4);
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

.prose th {
    font-family: var(--font-mono);
    font-size: 0.71875rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-faint);
    background: var(--surface-2);
}

.prose td:first-child { font-weight: 600; color: var(--fg); }
.prose tbody tr:last-child :is(td, th) { border-bottom: 0; }

/* In-article contents box (built by assets/js/theme.js on long posts) */
.prose .sw-toc {
    margin-block: var(--s-8);
    padding: var(--s-4) var(--s-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-2);
}

.prose .sw-toc summary {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-height: 32px;
    font-family: var(--font-mono);
    font-size: 0.71875rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-faint);
    cursor: pointer;
    list-style: none;
}

.prose .sw-toc summary::-webkit-details-marker { display: none; }

.prose .sw-toc summary::before {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform var(--dur) var(--ease);
}

.prose .sw-toc[open] summary::before { transform: rotate(45deg); }

.prose .sw-toc ul {
    margin: var(--s-3) 0 0;
    padding: 0;
    list-style: none;
}

.prose .sw-toc li { margin: 0; padding: 0; }

.prose .sw-toc a {
    display: block;
    padding: var(--s-1) 0;
    font-family: var(--font-ui);
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--fg-dim);
    text-decoration: none;
}

.prose .sw-toc a:hover { color: var(--accent-strong); }

/* Plugin leftovers: the theme prints its own share and related sections */
.prose .sharedaddy,
.prose .jp-relatedposts,
.prose .sd-like { display: none; }

.page-links { display: flex; gap: var(--s-3); }

/* 10. Comments ---------------------------------------------------------- */

.comments-title { margin: var(--s-12) 0 var(--s-6); font-size: 1.5rem; }
.comment-list { margin: 0; padding: 0; list-style: none; }
.comment-list .children { margin: 0; padding-left: var(--s-6); list-style: none; }

.comment-body {
    margin-bottom: var(--s-4);
    padding: var(--s-4) var(--s-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-2);
}

.comment-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-4); margin-bottom: var(--s-2); }
.comment-author { display: flex; align-items: center; gap: var(--s-3); font-weight: 600; color: var(--fg); }
.comment-author .avatar { border-radius: var(--r-pill); }
.comment-author .says { display: none; }
.comment-metadata, .comment-metadata a { font-size: 0.8125rem; color: var(--fg-faint); text-decoration: none; }
.comment-content p:last-child { margin-bottom: 0; }
.reply { margin-top: var(--s-2); font-size: 0.875rem; }
.comment-reply-link { font-weight: 600; text-decoration: none; }

.comment-form { display: grid; gap: var(--s-4); }
.comment-form p { margin: 0; }
.comment-form label { display: block; margin-bottom: var(--s-1); font-size: 0.875rem; font-weight: 600; color: var(--fg); }

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
    width: 100%;
    padding: var(--s-3) var(--s-4);
    font-size: 1rem;
    color: var(--fg);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-1);
}

.comment-form textarea { min-height: 9rem; }
.comment-form-cookies-consent { display: flex; align-items: center; gap: var(--s-2); font-size: 0.875rem; }
.comment-form-cookies-consent label { margin: 0; font-weight: 400; }

/* 11. Newsletter: inline card, landing page, pop-up --------------------- */

.subscribe {
    padding: clamp(24px, 4vw, 40px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-3);
}

.connect .subscribe { background: var(--bg); }

.subscribe-title { margin-bottom: var(--s-2); font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem); }
.subscribe-title--lg { font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.25rem); margin-bottom: var(--s-4); }
.subscribe-copy { margin-bottom: var(--s-6); }
.subscribe-copy--faint { color: var(--fg-faint); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.subscribe--done .btn { margin-top: var(--s-2); }

.subscribe-form { display: flex; flex-direction: column; gap: var(--s-3); }

@media (min-width: 520px) {
    .subscribe-form { flex-direction: row; }
}

.hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.sw-subscribe-message {
    margin-top: var(--s-4);
    padding: var(--s-3) var(--s-4);
    font-size: 0.9375rem;
    border: 1px solid var(--border);
    border-radius: var(--r-1);
}

.sw-subscribe-message[hidden] { display: none; }

.sw-subscribe-message[data-state="success"] {
    color: var(--ok);
    background: var(--ok-bg);
    border-color: var(--ok-border);
}

.sw-subscribe-message[data-state="error"] {
    color: var(--err);
    background: var(--err-bg);
    border-color: var(--err-border);
}

.sw-popup {
    position: fixed;
    z-index: 60;
    left: max(var(--s-4), env(safe-area-inset-left));
    right: max(var(--s-4), env(safe-area-inset-right));
    bottom: max(var(--s-4), env(safe-area-inset-bottom));
    padding: var(--s-6);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-3);
    visibility: hidden;
    opacity: 0;
    transform: translateY(24px);
    transition: transform 0.4s var(--ease), opacity 0.4s var(--ease), visibility 0s linear 0.4s;
}

.sw-popup.is-open {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0s;
}

@media (min-width: 640px) {
    .sw-popup { right: auto; width: 22.5rem; }
}

.sw-popup-close {
    position: absolute;
    top: var(--s-2);
    right: var(--s-2);
    font-size: 1.5rem;
    line-height: 1;
}

.sw-popup-title { padding-right: var(--s-8); margin-bottom: var(--s-1); font-size: 1.125rem; }
.sw-popup-copy { margin-bottom: var(--s-4); font-size: 0.9375rem; }
.sw-popup-form { display: flex; flex-direction: column; gap: var(--s-2); }

/* 12. Footer ------------------------------------------------------------- */

.site-footer {
    margin-top: var(--s-16);
    padding-top: var(--s-12);
    padding-bottom: max(var(--s-6), env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-6);
}

.footer-name {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: 640;
    letter-spacing: -0.02em;
    color: var(--fg);
}

.footer-role { margin: var(--s-1) 0 0; font-size: 0.9375rem; color: var(--fg-faint); }

.footer-social {
    display: flex;
    gap: var(--s-1);
    margin: 0;
    padding: 0;
    list-style: none;
}

.footer-legal {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--s-3);
    margin-top: var(--s-8);
    padding-top: var(--s-6);
    border-top: 1px solid var(--border);
}

.footer-top { text-decoration: none; }
.footer-top:hover { color: var(--accent-strong); }

/* 13. Motion & print ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    .site-header,
    .site-footer,
    .progress,
    .share,
    .subscribe-band,
    .sw-popup,
    .post-nav,
    .related,
    .comments-wrap,
    .sw-toc { display: none !important; }

    body { background: white; color: black; }
    .prose a { color: inherit; }
}
