/* Prem — Ghost theme
   Light, readable blog that borrows premai.io's design tokens:
   Aeonik Pro, 44px / 16px-radius buttons, 24px cards, 8px nav pills; strict monochrome with anthracite.
   The homepage intro uses an animated field of rounded squares. */

/* ---------- Fonts ----------
   Aeonik Pro @font-face lives in default.hbs so it shares the preload's versioned URL. */
/* Metric-matched fallback (the overrides premai.io ships) to avoid layout shift */
@font-face {
    font-family: "Aeonik Fallback";
    src: local("Arial");
    ascent-override: 91.72%;
    descent-override: 20.71%;
    line-gap-override: 0%;
    size-adjust: 101.4%;
}

/* ---------- Tokens ---------- */
:root {
    color-scheme: light;

    --bg: #ffffff;
    --surface: #f7f7f7;
    --line: rgba(0, 0, 0, 0.08);
    --line-2: rgba(0, 0, 0, 0.12);
    --line-3: rgba(0, 0, 0, 0.18);

    --ink: #1f2124;
    --text: #2f3237;
    --text-2: rgba(31, 33, 36, 0.72);
    --muted: rgba(31, 33, 36, 0.66);
    --faint: rgba(31, 33, 36, 0.42);

    /* Strict monochrome: anthracite instead of black, neutral greys for fills */
    --accent: #2b2e33;
    --accent-hover: #3e4248;
    --tint: #f4f4f5;
    --tint-2: #ececee;
    --tint-line: #dedfe2;
    --mid: #a3a7ad;
    --grad-title: linear-gradient(0deg, #5d6168 0%, #1f2124 88%);

    --font: var(--gh-font-body, "Aeonik Pro"), "Aeonik Fallback", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-heading: var(--gh-font-heading, "Aeonik Pro"), "Aeonik Fallback", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --container: 1600px;
    --read: 1200px;
    --gutter: clamp(20px, 4vw, 40px);
    --head-h: 64px;
    --measure: 700px;
    --wide: 1200px;

    --r-btn: 16px;
    --r-nav: 8px;
    --r-sm: 12px;
    --r-media: 16px;
    --r-card: 24px;

    --ease: cubic-bezier(0.3, 0, 0.2, 1);
    --ease-link: cubic-bezier(0.44, 0, 0.56, 1);

    --shadow-white: 0 0 0 1.1px rgba(0, 0, 0, 0.02), 0 2.2px 4.4px rgba(0, 0, 0, 0.02), 0 11px 11px rgba(0, 0, 0, 0.02), 0 25px 15px rgba(0, 0, 0, 0.02), 0 44px 26px rgba(0, 0, 0, 0.02), inset 0 0.28px 0.28px rgba(255, 255, 255, 0.32), inset 0 0.83px 0.28px rgba(255, 255, 255, 0.12), inset 0 4.4px 17.6px rgba(255, 255, 255, 0.16), inset 0 -13.2px 17.6px rgba(255, 255, 255, 0.16);
    --shadow-card: 0 12.8px 12.8px -6.4px rgba(42, 51, 70, 0.04), 0 4px 4px -2px rgba(42, 51, 70, 0.03), 0 2.4px 2.4px -1.2px rgba(42, 51, 70, 0.05), 0 0.8px 0.8px -0.4px rgba(42, 51, 70, 0.03);
}


/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: calc(var(--head-h) + 24px);
    background: var(--bg);
}
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
img, video, svg, iframe { max-width: 100%; }
img { display: block; height: auto; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-family: var(--font-heading); font-weight: 400; line-height: 1.1; color: var(--ink); letter-spacing: 0; }
p, figure, blockquote { margin: 0; }
::selection { background: rgba(43, 46, 51, 0.16); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 16px; top: -48px; z-index: 100; padding: 10px 16px; border-radius: var(--r-sm); background: var(--ink); color: #fff; font-weight: 500; }
.skip-link:focus { top: 12px; }

.site { display: flex; flex-direction: column; min-height: 100vh; }
.site-main { flex: 1; padding-top: var(--head-h); }
.container { width: 100%; max-width: calc(var(--container) + var(--gutter) * 2); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.container-read { width: 100%; max-width: calc(var(--read) + var(--gutter) * 2); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }

.grad-text {
    background-image: var(--grad-title);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
    padding-bottom: 0.08em;
}

.eyebrow { font-size: 20px; line-height: 28px; font-weight: 500; color: var(--muted); }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 14px; line-height: 20px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meta a { color: var(--text-2); transition: color 0.4s var(--ease-link); }
.meta a:hover { color: var(--ink); }
.meta-sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.7; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; line-height: 20px; color: var(--muted); }
.crumbs a { transition: color 0.4s var(--ease-link); }
.crumbs a:hover { color: var(--accent); }
.crumbs span[aria-hidden] { color: var(--faint); }

/* ---------- Buttons & inputs (44px, radius 16, as on premai.io) ---------- */
.btn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    height: 44px; padding: 0 24px;
    border: 0; border-radius: var(--r-btn);
    font-family: var(--font); font-size: 16px; line-height: 1.2; font-weight: 500;
    white-space: nowrap; cursor: pointer;
    transition: opacity 0.4s var(--ease), background-color 0.4s var(--ease);
}
.btn::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 1px solid transparent; pointer-events: none; }
.btn:hover { opacity: 0.7; }
.btn-white { background: #fff; color: var(--ink); box-shadow: var(--shadow-white); }
.btn-white::after { border-color: rgba(0, 0, 0, 0.1); }
.btn-dark { background: var(--accent); color: #fff; box-shadow: none; }
.btn-dark::after { display: none; }
.btn-dark:hover { opacity: 0.7; }
.btn-sm { height: 40px; padding: 0 18px; font-size: 15px; }


.spinner { display: none; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.loading .btn-label { visibility: hidden; }
.loading .spinner { display: block; position: absolute; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
    position: relative;
    display: inline-grid; place-items: center; flex-shrink: 0;
    width: 40px; height: 40px; padding: 0;
    border: 0; border-radius: var(--r-sm);
    background: transparent; color: var(--ink); cursor: pointer;
    transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}
.icon-btn:hover { background: rgba(0, 0, 0, 0.05); }

.input {
    width: 100%; min-width: 0; height: 44px; padding: 0 16px;
    border: 1px solid var(--line-2); border-radius: var(--r-btn);
    background: #fff; color: var(--ink);
    font-size: 16px; outline: none;
    box-shadow: var(--shadow-card);
    transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(43, 46, 51, 0.18); }

.pill {
    display: inline-flex; align-items: center; height: 40px; padding: 0 16px;
    border: 1px solid var(--line-2); border-radius: var(--r-sm);
    background: #fff;
    font-size: 14px; line-height: 20px; color: var(--text-2); white-space: nowrap;
    transition: background-color 0.4s var(--ease), color 0.4s var(--ease), border-color 0.4s var(--ease);
}
.pill:hover { background: var(--tint); border-color: var(--tint-line); color: var(--ink); }
.pill.is-active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }

/* ---------- Header (premai.io nav metrics: 64px, logo 115x28, 16px links in 32px/8px pills, 44px CTA) ---------- */
.head { position: fixed; top: 0; left: 0; right: 0; z-index: 50; height: var(--head-h); }
.head::before {
    content: ""; position: absolute; inset: 0;
    background: rgba(255, 255, 255, 0.8);
    -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
    opacity: 0; transition: opacity 0.4s var(--ease);
}
.head.is-scrolled::before, .nav-open .head::before { opacity: 1; }
.head-inner { position: relative; display: flex; align-items: center; gap: 24px; height: 100%; }
.head-logo { display: inline-flex; color: var(--ink); flex-shrink: 0; transition: opacity 0.4s var(--ease); }
.head-logo:hover { opacity: 0.7; }
.logo-svg { display: block; width: 115px; height: 28px; }
.head-nav { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; }
.head-nav .nav { display: flex; align-items: center; gap: 16px; margin: 0; padding: 0; list-style: none; }
.head-nav .nav > li { position: relative; }
.head-nav .nav > li > a, .nav-drop, .nav-link {
    display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px;
    border: 0; border-radius: var(--r-nav); background: transparent;
    font-family: var(--font); font-size: 16px; line-height: 22.4px; color: var(--ink); white-space: nowrap; cursor: pointer;
    transition: background-color 0.4s var(--ease);
}
.nav-drop { padding: 0 8px 0 12px; }
.head-nav .nav > li > a:hover, .nav-drop:hover, .nav-link:hover, .has-drop.is-open > .nav-drop { background: rgba(0, 0, 0, 0.05); }
.chevron { transition: transform 0.3s var(--ease); }
.has-drop.is-open .chevron { transform: rotate(180deg); }
.drop {
    position: absolute; top: calc(100% + 12px); left: -12px; z-index: 2;
    display: grid; gap: 4px; min-width: 320px; padding: 12px;
    border-radius: var(--r-card); background: #fff;
    box-shadow: 0 0 0 1px var(--line), 0 24px 48px -16px rgba(31, 33, 36, 0.16);
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), visibility 0.25s;
}
.drop::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 12px; }
.has-drop.is-open > .drop { opacity: 1; visibility: visible; transform: none; }
.head-nav .drop-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 24px 12px 12px; border-radius: var(--r-sm); text-align: left; white-space: normal; transition: background-color 0.3s var(--ease); }
.head-nav .drop-item:hover { background: rgba(0, 0, 0, 0.04); }
.drop-title { font-size: 16px; line-height: 22.4px; font-weight: 500; color: var(--ink); }
.drop-desc { font-size: 14px; line-height: 19.6px; color: var(--text-2); }
.head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto; }
.head-nav-members { display: none; }
.burger { display: none; }
.burger .dots-close { display: none; }
.nav-open .burger .dots-grid { display: none; }
.nav-open .burger .dots-close { display: inline; }

.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none; overflow: hidden; }
.progress span { display: block; width: 100%; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
body:not(.post-template) .progress { display: none; }

@media (max-width: 1279px) {
    .burger { display: inline-grid; }
    .head-signin { display: none; }
    .head-nav-members { display: flex; gap: 12px; margin-top: 24px; }
    .head-nav-members .btn { flex: 1; }
    .head-nav {
        position: fixed; top: var(--head-h); left: 0; right: 0; bottom: 0; transform: none;
        display: block; padding: 16px var(--gutter) 32px;
        background: var(--bg); overflow-y: auto;
        opacity: 0; visibility: hidden; transform: translateY(-8px);
        transition: opacity 0.3s var(--ease), transform 0.3s var(--ease), visibility 0.3s;
    }
    .nav-open .head-nav { opacity: 1; visibility: visible; transform: none; }
    .nav-open { overflow: hidden; }
    .head-nav .nav { flex-direction: column; align-items: stretch; gap: 0; }
    .head-nav .nav > li > a, .nav-drop { display: flex; justify-content: space-between; width: 100%; height: auto; padding: 16px 0; border-radius: 0; border-bottom: 1px solid var(--line); font-size: 20px; line-height: 28px; }
    .head-nav .nav > li:last-child > a { border-bottom: 0; }
    .head-nav .nav a:hover, .nav-drop:hover, .has-drop.is-open > .nav-drop, .head-nav .nav-current > a { background: none; }
    .drop { position: static; display: none; min-width: 0; padding: 4px 0 12px; border-radius: 0; box-shadow: none; opacity: 1; visibility: visible; transform: none; }
    .drop::before { display: none; }
    .has-drop.is-open > .drop { display: grid; }
    .head-nav .drop-item { padding: 10px 0 10px 12px; }
}
@media (max-width: 520px) {
    .head-cta { display: none; }
}

/* ---------- Hero: blog intro + animated squares field ---------- */
.hero { position: relative; border-bottom: 1px solid var(--line); overflow: hidden; }
.hero-inner {
    display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); column-gap: 64px; align-items: center;
    padding-top: 80px; padding-bottom: 80px;
}
.hero-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 24px; }
.hero-title { font-size: 66px; line-height: 1.04; font-weight: 400; text-wrap: balance; max-width: 13em; }
.hero-lede { max-width: 560px; font-size: 20px; line-height: 28px; color: var(--text-2); }
.hero-copy .subscribe { margin-top: 8px; }
.hero-art { position: relative; height: 100%; min-height: 320px; }

.squares {
    --sq: 44px; --sq-gap: 10px; --sq-r: 13px;
    position: absolute; inset: -24px 0;
    display: grid; gap: var(--sq-gap);
    grid-template-columns: repeat(auto-fill, var(--sq)); grid-auto-rows: var(--sq);
    align-content: center; justify-content: end;
    -webkit-mask-image: radial-gradient(70% 80% at 60% 50%, #000 30%, rgba(0, 0, 0, 0) 100%);
    mask-image: radial-gradient(70% 80% at 60% 50%, #000 30%, rgba(0, 0, 0, 0) 100%);
}
.sq {
    border-radius: var(--sq-r);
    background-color: #f5f5f6;
    box-shadow: inset 0 0 0 1px rgba(31, 33, 36, 0.04);
    transition: background-color 1.08s cubic-bezier(0.25, 0.1, 0.25, 1);
}
.sq.is-hot { transition-duration: 0.4s; }

@keyframes rise { from { opacity: 0; transform: translateY(24px); } }
.hero-copy > * { animation: rise 1s var(--ease) both; }
.hero-copy > :nth-child(2) { animation-delay: 0.08s; }
.hero-copy > :nth-child(3) { animation-delay: 0.16s; }

@media (max-width: 1199px) {
    .hero-title { font-size: 56px; }
}
@media (max-width: 1023px) {
    .hero-inner { grid-template-columns: 1fr; row-gap: 40px; padding-top: 56px; padding-bottom: 56px; }
    .hero-art { order: -1; min-height: 0; height: 80px; }
    .squares { inset: 0 calc(var(--gutter) * -1) 0 0; --sq: 36px; --sq-gap: 8px; --sq-r: 11px; justify-content: start; -webkit-mask-image: linear-gradient(90deg, #000 40%, rgba(0, 0, 0, 0) 100%); mask-image: linear-gradient(90deg, #000 40%, rgba(0, 0, 0, 0) 100%); }
}
@media (max-width: 640px) {
    .hero-title { font-size: 40px; }
    .hero-lede { font-size: 18px; line-height: 26px; }
    .hero-art { height: 92px; }
    .squares { --sq: 26px; --sq-gap: 7px; --sq-r: 8px; }
}

/* ---------- Subscribe ---------- */
.subscribe { width: 100%; max-width: 480px; }
.subscribe-row { display: flex; gap: 8px; }
.subscribe-row .btn { flex-shrink: 0; }
.subscribe-note { margin-top: 12px; font-size: 14px; line-height: 20px; color: var(--muted); }
.subscribe-note .when-success, .subscribe-note .when-error { display: none; }
.subscribe.success .when-idle, .subscribe.error .when-idle { display: none; }
.subscribe.success .when-success { display: inline; color: var(--accent); }
.subscribe.error .when-error { display: inline; color: #c0392b; }
@media (max-width: 420px) {
    .subscribe-row { flex-direction: column; }
}

/* ---------- Sections & feed ---------- */
.feed-section { padding-top: 80px; padding-bottom: 120px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 40px; }
.section-head .eyebrow { margin-bottom: 12px; }
.section-head > .icon-btn { margin-right: -11px; }
.section-title { font-size: 56px; line-height: 1.1; }
.filter { display: flex; gap: 8px; padding: 4px; margin: -12px -4px 36px; overflow-x: auto; scrollbar-width: none; }
.filter::-webkit-scrollbar { display: none; }

.feed { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 56px 32px; }

.card-link { display: flex; flex-direction: column; height: 100%; }
.card-media {
    position: relative; overflow: hidden;
    aspect-ratio: 1200 / 630;
    border-radius: var(--r-media);
    background: var(--surface);
}
.card-media::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 1px solid var(--line); pointer-events: none; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.8s var(--ease); }
.card-link:hover .card-media img { transform: scale(1.03); }
.card-media-empty { display: grid; place-items: center; height: 100%; color: rgba(31, 33, 36, 0.28); background: var(--tint); }
.card-body { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding-top: 20px; }
.card-tag { font-size: 14px; line-height: 20px; font-weight: 500; color: var(--muted); }
.card-title {
    font-size: 20px; line-height: 28px; font-weight: 500; color: var(--ink);
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
    transition: color 0.4s var(--ease-link);
}
.card-link:hover .card-title { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; text-decoration-color: rgba(31, 33, 36, 0.3); }
.card-excerpt { font-size: 18px; line-height: 28px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.card-lead { margin-bottom: 120px; }
.card-lead .card-link { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 56px; align-items: center; }
.card-lead .card-media { border-radius: var(--r-card); box-shadow: var(--shadow-card); }
.card-lead .card-body { gap: 16px; padding-top: 0; }
.card-lead .card-title { display: block; font-size: 40px; line-height: 1.1; font-weight: 400; -webkit-line-clamp: unset; overflow: visible; }
.feed > .card-lead { grid-column: 1 / -1; margin-bottom: 0; }
.card-lead .card-cta { margin-top: 12px; }
.card-lead .card-link:hover .card-cta { opacity: 0.7; }

.more { display: flex; justify-content: center; margin-top: 72px; }

/* Scroll reveal (only when JS is running) */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.45s var(--ease), transform 0.5s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }

@media (max-width: 1279px) {
    .card-lead .card-link { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; }
    .card-lead .card-title { font-size: 32px; }
}
@media (max-width: 1023px) {
    .feed { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 48px 24px; }
    .card-lead { margin-bottom: 80px; }
    .card-lead .card-link { grid-template-columns: 1fr; gap: 28px; }
    .card-lead .card-title { font-size: 34px; }
    .section-title { font-size: 44px; }
    .feed-section { padding-top: 56px; }
}
@media (max-width: 640px) {
    .feed { grid-template-columns: 1fr; gap: 40px; }
    .feed-section { padding-top: 40px; padding-bottom: 80px; }
    .card-lead { margin-bottom: 64px; }
    .card-lead .card-title { font-size: 28px; }
    .card-excerpt { font-size: 16px; line-height: 24px; }
    .section-title { font-size: 36px; }
    .section-head { margin-bottom: 28px; }
}

/* ---------- Archive headers ---------- */
.archive-head { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding-top: 72px; margin-bottom: 56px; }
.archive-title { font-size: 82px; line-height: 1; }
.archive-desc { max-width: 720px; font-size: 20px; line-height: 28px; color: var(--text-2); }
.archive-author { flex-direction: row; align-items: center; gap: 32px; }
.archive-author > div { display: flex; flex-direction: column; gap: 16px; }
.archive-avatar { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; background: var(--surface); box-shadow: 0 0 0 1px var(--line-2); }
.feed-section > .archive-head:first-child { padding-top: 0; }
@media (max-width: 640px) {
    .archive-head { padding-top: 40px; margin-bottom: 40px; }
    .archive-title { font-size: 48px; }
    .archive-author { flex-direction: column; align-items: flex-start; gap: 20px; }
}

/* ---------- Post header ---------- */
.post-head {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 64px; align-items: center;
    padding-top: 72px; padding-bottom: 72px;
}
.no-image .post-head { grid-template-columns: minmax(0, 1fr); }
.no-image .post-head-copy { max-width: 960px; }
.post-head-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; }
.post-title { font-size: 48px; line-height: 52px; text-wrap: balance; }
.post-dek { font-size: 20px; line-height: 30px; color: var(--text-2); text-wrap: pretty; }
.post-meta { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.avatars { display: flex; }
.avatar { display: block; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: var(--surface); box-shadow: 0 0 0 1px var(--line), 0 0 0 3px #fff; }
.avatar + .avatar { margin-left: -10px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar span { display: grid; place-items: center; height: 100%; font-size: 12px; font-weight: 500; color: var(--ink); }
.post-meta-text { display: flex; flex-direction: column; gap: 2px; }
.post-authors { font-size: 16px; line-height: 22px; font-weight: 500; color: var(--ink); }
.post-authors a { transition: color 0.4s var(--ease-link); }
.post-authors a:hover { color: var(--accent); }
.post-cover { position: relative; }
.post-cover img { width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: var(--r-card); background: var(--surface); box-shadow: 0 0 0 1px var(--line), var(--shadow-card); }
.post-cover figcaption, .page-cover figcaption { margin-top: 12px; font-size: 14px; line-height: 20px; color: var(--muted); }

.page-head { display: flex; flex-direction: column; gap: 20px; max-width: calc(var(--measure) + var(--gutter) * 2); padding-top: 72px; padding-bottom: 56px; }
.page-cover { margin-top: 24px; }
.page-cover img { width: 100%; border-radius: var(--r-card); }

@media (max-width: 1279px) {
    .post-head { grid-template-columns: minmax(0, 1fr); max-width: calc(var(--measure) + var(--gutter) * 2); gap: 40px; padding-top: 48px; padding-bottom: 48px; }
    .post-cover { order: 2; }
}
@media (max-width: 640px) {
    .post-head { padding-top: 32px; padding-bottom: 32px; gap: 28px; }
    .post-head-copy { gap: 16px; }
    .post-title { font-size: 34px; line-height: 38px; }
    .post-dek { font-size: 18px; line-height: 28px; }
    .post-cover img { border-radius: var(--r-media); }
}

/* ---------- Post layout: centered 768 text column, wide blocks up to 1200 ---------- */
.post-layout { width: 100%; max-width: calc(var(--wide) + var(--gutter) * 2); margin: 0 auto; padding: 0 var(--gutter); }
.post-main { min-width: 0; }

/* Table of contents: a dot-matrix rail on the right (Prem's halftone motif).
   Each heading is a row of square dots: read sections mid-grey, the current one anthracite, the rest pale.
   Hover or focus reveals a fixed-width card over the rail — it fades and slides in, nothing reflows. */
.toc {
    position: fixed; z-index: 30;
    top: calc(var(--head-h) + 120px);
    right: max(16px, calc(50% - var(--wide) / 2 - 76px));
    opacity: 0; pointer-events: none;
    transition: opacity 0.4s var(--ease);
}
.toc.is-visible, .toc:focus-within { opacity: 1; pointer-events: auto; }
.toc[hidden] { display: block; }

.toc-rail { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; padding: 14px 12px; transition: opacity 0.2s var(--ease) 0.1s; }
.toc-row { display: flex; gap: 3px; height: 4px; }
.toc-row i, .toc-dots i { flex-shrink: 0; width: 4px; height: 4px; border-radius: 1px; background: rgba(31, 33, 36, 0.14); transition: background-color 0.4s var(--ease); }
.is-read > i, .is-read .toc-dots i { background: rgba(31, 33, 36, 0.42); }
.is-active > i, .is-active .toc-dots i { background: var(--accent); }

.toc-card {
    position: absolute; top: 0; right: 0; width: 340px; padding: 16px 8px 10px;
    border-radius: var(--r-card); background: #fff;
    box-shadow: 0 0 0 1px var(--line), 0 24px 48px -16px rgba(31, 33, 36, 0.18);
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateX(10px) scale(0.98); transform-origin: top right;
    transition: opacity 0.2s var(--ease) 0.12s, transform 0.3s var(--ease) 0.12s, visibility 0s linear 0.42s;
}
.toc:hover .toc-card, .toc:focus-within .toc-card {
    opacity: 1; visibility: visible; pointer-events: auto; transform: none;
    transition: opacity 0.22s var(--ease), transform 0.32s var(--ease), visibility 0s;
}
.toc:hover .toc-rail, .toc:focus-within .toc-rail { opacity: 0; transition: opacity 0.1s var(--ease) 0s; }
.toc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 8px; padding: 0 12px; }
.toc-title { margin: 0; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.toc-left { font-size: 13px; line-height: 20px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.toc-list { position: relative; margin: 0; padding: 4px 0; list-style: none; max-height: calc(100vh - var(--head-h) - 240px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.toc-list::-webkit-scrollbar { display: none; }
/* soft fades instead of a scrollbar, only on the edges that can still scroll */
.toc-list[data-fade="bottom"] { -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(180deg, #000 calc(100% - 48px), transparent); }
.toc-list[data-fade="top"] { -webkit-mask-image: linear-gradient(180deg, transparent, #000 48px); mask-image: linear-gradient(180deg, transparent, #000 48px); }
.toc-list[data-fade="both"] { -webkit-mask-image: linear-gradient(180deg, transparent, #000 48px, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(180deg, transparent, #000 48px, #000 calc(100% - 48px), transparent); }
.toc-list a { display: flex; align-items: center; gap: 14px; min-height: 34px; padding: 6px 12px; border-radius: var(--r-sm); font-size: 14px; line-height: 20px; color: var(--muted); text-decoration: none; transition: background-color 0.2s var(--ease), color 0.2s var(--ease); }
.toc-list a:hover { color: var(--ink); background: rgba(0, 0, 0, 0.04); }
.toc-label { flex: 1; min-width: 0; }
.toc-h3 .toc-label { padding-left: 14px; font-size: 13px; }
.toc-dots { display: flex; justify-content: flex-end; gap: 3px; flex-shrink: 0; width: 32px; }
.toc-list .is-active a { color: var(--ink); font-weight: 500; }

html:not(.js) .toc-mobile { display: none !important; }
.toc-mobile { display: none; margin-bottom: 32px; border: 1px solid var(--line-2); border-radius: var(--r-media); background: var(--surface); }
.toc-mobile summary { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; list-style: none; cursor: pointer; font-size: 16px; font-weight: 500; color: var(--ink); }
.toc-mobile summary::-webkit-details-marker { display: none; }
.toc-mobile-chevron { width: 10px; height: 10px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translate(-2px, -2px); transition: transform 0.3s var(--ease); }
.toc-mobile[open] .toc-mobile-chevron { transform: rotate(-135deg) translate(-2px, -2px); }
.toc-mobile-list { margin: 0; padding: 0 18px 16px; list-style: none; }
.toc-mobile-list a { display: block; padding: 6px 0; font-size: 15px; line-height: 21px; color: var(--text-2); }
.toc-mobile-list .toc-h3 a { padding-left: 14px; font-size: 14px; color: var(--muted); }

@media (max-width: 1379px) {
    .toc { display: none !important; }
    .toc-mobile:not([hidden]) { display: block; }
}

/* ---------- Content ---------- */
.content {
    display: grid;
    grid-template-columns: [wide-start] minmax(0, 1fr) [main-start] min(var(--measure), 100%) [main-end] minmax(0, 1fr) [wide-end];
    font-size: 18px; line-height: 30px; color: var(--text);
    overflow-wrap: break-word;
}
.content > * { grid-column: main; min-width: 0; }
.content > .kg-width-wide,
.content > .kg-width-full,
.content > .is-wide { grid-column: wide; }



.content > * + * { margin-top: 24px; }
.content > :first-child { margin-top: 0; }
.content h2, .content h3, .content h4 { font-weight: 500; color: var(--ink); text-wrap: balance; position: relative; }
.content h2 { margin-top: 64px; font-size: 32px; line-height: 40px; }
.content h3 { margin-top: 40px; font-size: 24px; line-height: 32px; }
.content h4 { margin-top: 32px; font-size: 19px; line-height: 28px; }
.content h5, .content h6 { margin-top: 28px; font-size: 18px; line-height: 28px; font-weight: 500; color: var(--ink); }
.content h2 + * { margin-top: 16px; }
.content h3 + * { margin-top: 12px; }
.content h4 + *, .content h5 + *, .content h6 + * { margin-top: 8px; }
.content p { text-wrap: pretty; }
.content strong, .content b { font-weight: 500; color: var(--ink); }
.content em { font-style: italic; }
.content a {
    color: var(--ink);
    text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
    text-decoration-color: rgba(31, 33, 36, 0.32);
    transition: color 0.4s var(--ease-link), text-decoration-color 0.4s var(--ease-link);
}
.content a:hover { color: var(--ink); text-decoration-color: currentColor; }
.content ul, .content ol { padding-left: 24px; margin-bottom: 0; }
.content li + li { margin-top: 8px; }
.content li > ul, .content li > ol { margin-top: 8px; }
.content li::marker { color: var(--mid); }
.content ol > li::marker { font-variant-numeric: tabular-nums; }
.content hr { height: 1px; margin: 48px 0 24px; border: 0; background: var(--line); }

.heading-anchor {
    position: absolute; left: -28px; top: 0; width: 24px;
    color: var(--faint); font-weight: 400; text-decoration: none !important;
    opacity: 0; transition: opacity 0.2s var(--ease), color 0.2s var(--ease);
}
.content h2:hover .heading-anchor, .content h3:hover .heading-anchor { opacity: 1; }
.heading-anchor:hover { color: var(--accent); }
@media (max-width: 860px) { .heading-anchor { display: none; } }

.content blockquote:not(.kg-blockquote-alt) {
    padding-left: 20px; border-left: 2px solid var(--accent);
    font-size: 20px; line-height: 30px; color: var(--ink);
}
.content blockquote.kg-blockquote-alt {
    margin-top: 48px; margin-bottom: 24px; padding: 0; font-style: normal; text-align: center;
    font-size: 28px; line-height: 1.3; color: var(--ink);
}

.content code { font-family: var(--font-mono); font-size: 0.875em; }
.content :not(pre) > code { padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.content pre {
    overflow-x: auto; margin: 0; padding: 16px 20px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: #f6f6f7; color: var(--ink);
    font-size: 14px; line-height: 22px; tab-size: 2;
    -webkit-overflow-scrolling: touch;
}
.content pre code { font-size: inherit; color: inherit; background: none; padding: 0; border: 0; }
.code-block { border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #f6f6f7; overflow: hidden; }
.code-block pre { border: 0; border-radius: 0; background: transparent; }
.code-head { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--line); background: #efeff1; font-size: 13px; color: var(--muted); }
.code-copy { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); font-size: 13px; cursor: pointer; transition: background-color 0.3s var(--ease), color 0.3s var(--ease); }
.code-copy:hover { background: rgba(0, 0, 0, 0.05); color: var(--ink); }

/* Images and media */
.content figure { margin-top: 40px; }
.content figure + * { margin-top: 40px; }
.content :is(h2, h3, h4) + figure { margin-top: 24px; }
.content figure + h2 { margin-top: 64px; }
.content > .kg-card:not(figure) { margin-top: 40px; }
.content :is(h2, h3, h4) + .kg-card:not(figure) { margin-top: 24px; }
.content .kg-image-card img, .content > img { margin: 0; border-radius: var(--r-sm); background: var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: zoom-in; }
.content .kg-width-wide img, .content .kg-width-full img, .content .is-wide img { width: 100%; }
.content figcaption { margin-top: 12px; font-size: 14px; line-height: 20px; color: var(--muted); text-align: left; }
.content figcaption a { color: var(--text-2); }
.content iframe { border: 0; border-radius: var(--r-sm); }
.content .kg-embed-card { display: flex; flex-direction: column; align-items: center; }
.content .kg-embed-card > * { max-width: 100%; }
.content .kg-gallery-image img { border-radius: 8px; }


/* Text pasted from Google Docs carries inline fonts, sizes, colors and borders — the theme wins (Koenig cards are left alone) */
:where(.content) :is([style*="font-family"], [style*="font-size"]):not(.kg-card, .kg-card *) { font-family: inherit !important; font-size: inherit !important; }
:where(.content) :where(span, p, li, td, th, div[style*="color"])[style]:not(.kg-card, .kg-card *) { color: inherit !important; }
:where(.content) :where(span, p, li, div[style*="color"])[style]:not(.kg-card, .kg-card *) { background-color: transparent !important; }
:where(.content) [style*="text-transform"] { text-transform: none !important; letter-spacing: normal !important; }
.content td p[style], .content th p[style], .content li p[style] { line-height: inherit !important; margin-top: 0 !important; margin-bottom: 0 !important; }
.content td > p + p, .content th > p + p, .content li > p + p { margin-top: 10px !important; }

/* Tables: wrapped by JS in .table-frame > .table-scroll */
.content .table-scroll :is(th, td) { word-break: normal !important; overflow-wrap: break-word !important; }
.content table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; line-height: 22px; font-variant-numeric: tabular-nums; }
.content > table { display: block; overflow-x: auto; }
.table-frame { position: relative; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff; box-shadow: var(--shadow-card); }
.table-scroll { overflow-x: auto; border-radius: inherit; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--line-3) transparent; }
.table-frame.can-scroll:not(.at-end)::after { content: ""; position: absolute; top: 1px; right: 1px; bottom: 1px; width: 40px; border-radius: 0 var(--r-sm) var(--r-sm) 0; background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95)); pointer-events: none; }
.content th, .content td {
    padding: 12px 16px !important; text-align: left; vertical-align: top;
    border: 0 !important; border-bottom: 1px solid var(--line) !important;
    color: var(--text); background-color: #fff !important;
}
.content th:not(:first-child), .content td:not(:first-child) { min-width: 140px; }
.content tr:last-child > td, .content tr:last-child > th { border-bottom: 0 !important; }
.content tbody tr:hover > td { background-color: #fafafa !important; }
.content thead th, .content thead td, .content table.has-head tr:first-child > * {
    background: var(--tint) !important; color: var(--ink);
    font-size: 14px; line-height: 20px; font-weight: 500;
    border-bottom: 1px solid var(--tint-line) !important;
}
.content td:first-child, .content th:first-child { font-weight: 500; color: var(--ink); }
.content table col { width: auto !important; }
.content table[style] { border: 0 !important; }
.content table.cols-5plus td:not(:first-child), .content table.cols-5plus th:not(:first-child) { box-shadow: inset 1px 0 0 var(--line); }

/* Single-cell tables are summary boxes — rendered as callouts */
.callout, .content .kg-callout-card {
    display: block; padding: 24px 28px;
    border: 1px solid var(--tint-line); border-radius: var(--r-media);
    background: var(--tint);
    font-size: 16px; line-height: 26px; color: var(--text);
}
.content .callout table, .content .callout tbody, .content .callout tr, .content .callout td { display: block; width: auto !important; height: auto !important; padding: 0 !important; border: 0 !important; background: none !important; font-size: inherit; line-height: inherit; font-weight: 400; color: inherit; min-width: 0; box-shadow: none; }
.callout colgroup { display: none; }
.content .callout td > :not(:first-child) { margin-top: 12px !important; }
.callout ul, .callout ol { padding-left: 20px; }
.callout li + li { margin-top: 6px; }
.content .kg-callout-card { display: flex; gap: 12px; }
.content .kg-callout-card-grey, .content .kg-callout-card-white, .content .kg-callout-card-blue { background: var(--tint); }
.content .kg-callout-emoji { font-size: 20px; line-height: 26px; }
.content .kg-callout-text { font-size: 16px; line-height: 26px; }

/* Ghost cards */
.content .kg-card, .content .kg-card :not(pre, code, pre *) { font-family: var(--font) !important; }
.content .kg-cta-sponsor-label, .content .kg-collection-card-title { text-transform: none !important; letter-spacing: normal !important; font-weight: 500; font-size: 13px; color: var(--muted); }
.content .kg-embed-card iframe[src*="youtube.com"], .content .kg-embed-card iframe[src*="youtube-nocookie.com"], .content .kg-embed-card iframe[src*="player.vimeo.com"], .content > iframe[src*="youtube.com"], .content iframe[src*="youtube.com/embed"] { width: 100%; height: auto; aspect-ratio: 16 / 9; }
.content .kg-video-card .kg-video-container { border-radius: var(--r-sm); }
.content :is(.kg-bookmark-description, .kg-bookmark-author, .kg-bookmark-publisher) { opacity: 1; }
.content .kg-audio-duration { color: var(--muted); }
.content .kg-file-card a.kg-file-card-container { border-radius: var(--r-media); border-color: var(--line-2); }
.content .kg-audio-card { box-shadow: inset 0 0 0 1px var(--line-2); }
.content :is(a.kg-cta-button, a.kg-product-card-button, .kg-header-card a.kg-header-card-button, .kg-header-card.kg-v2 .kg-header-card-button, .kg-signup-card-button) { border-radius: var(--r-btn); }
.content .kg-signup-card-fields { border-radius: var(--r-btn); }
.content .kg-callout-card div.kg-callout-text { font-size: 16px; line-height: 26px; }
.content .kg-callout-card div.kg-callout-emoji { padding-right: 0; font-size: 20px; line-height: 26px; }
.content .kg-toggle-card-icon { margin-top: 2px; }
.content .kg-toggle-card:not(:has(+ .kg-toggle-card)) { border-bottom: 1px solid var(--line); }
.content .kg-product-card-container { max-width: none; }
.content .kg-bookmark-card a.kg-bookmark-container {
    display: flex; overflow: hidden; min-height: 148px;
    border: 1px solid var(--line-2); border-radius: var(--r-media);
    background: #fff; color: var(--ink); text-decoration: none;
    box-shadow: var(--shadow-card);
    transition: border-color 0.4s var(--ease);
}
.content .kg-bookmark-card a.kg-bookmark-container:hover { border-color: var(--mid); }
.content .kg-bookmark-content { padding: 20px; }
.content .kg-bookmark-title { font-size: 16px; line-height: 22px; font-weight: 500; color: var(--ink); }
.content .kg-bookmark-description { margin-top: 6px; font-size: 14px; line-height: 20px; color: var(--muted); }
.content .kg-bookmark-metadata { margin-top: 14px; font-size: 13px; color: var(--muted); }
.content .kg-bookmark-thumbnail img { border-radius: 0; box-shadow: none; cursor: pointer; }
.content .kg-toggle-card { padding: 20px 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: none; box-shadow: none; }
.content .kg-toggle-card + .kg-toggle-card { margin-top: 0; }
.content .kg-toggle-heading-text { font-size: 20px; line-height: 28px; font-weight: 500; color: var(--ink); }
.content .kg-toggle-card-icon svg { color: var(--muted); }
.content .kg-button-card a.kg-btn { height: 44px; padding: 0 24px; border-radius: var(--r-btn); background: var(--accent); color: #fff; font-family: var(--font); font-size: 16px; font-weight: 500; text-decoration: none; box-shadow: none; }
.content .kg-cta-card, .content .kg-header-card, .content .kg-signup-card { border-radius: var(--r-card); }
.content .kg-cta-card { border: 1px solid var(--line-2); background: var(--surface); }
.content .kg-product-card-container { border-radius: var(--r-media); border: 1px solid var(--line-2); box-shadow: var(--shadow-card); }

/* ---------- Post footer ---------- */
.post-foot { max-width: var(--measure); margin: 64px auto 0; }
.content .is-signoff { display: none; }
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.post-share { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 16px; font-weight: 500; color: var(--ink); }
.share { display: flex; gap: 4px; }
.share .icon-btn { color: var(--text-2); }
.share .icon-btn:hover { color: var(--accent); background: var(--tint); }
.copy-toast {
    position: absolute; bottom: calc(100% + 8px); right: 0; transform: translateY(4px);
    padding: 6px 10px; border-radius: 8px; background: var(--ink); color: #fff;
    font-size: 13px; font-weight: 500; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.copied .copy-toast { opacity: 1; transform: none; }
.author-box { display: flex; gap: 16px; align-items: flex-start; margin-top: 32px; }
.author-box + .author-box { margin-top: 24px; }
.author-box-img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--surface); box-shadow: 0 0 0 1px var(--line); flex-shrink: 0; }
.author-box-label { font-size: 14px; line-height: 20px; color: var(--muted); }
.author-box-name { font-size: 20px; line-height: 28px; font-weight: 500; color: var(--ink); transition: color 0.4s var(--ease-link); }
.author-box-name:hover { color: var(--accent); }
.author-box-bio { margin-top: 4px; font-size: 16px; line-height: 24px; color: var(--text-2); }

.post-subscribe {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; gap: 24px;
    margin-top: 48px; padding: 32px;
    border: 1px solid var(--tint-line); border-radius: var(--r-card);
    background: var(--tint);
}
.post-subscribe-title { font-size: 24px; line-height: 32px; font-weight: 500; }
.post-subscribe-text { margin-top: 8px; font-size: 16px; line-height: 24px; color: var(--text-2); }
.post-subscribe .subscribe { max-width: none; }
.post-comments { max-width: var(--measure); margin: 64px auto 0; }

.related { padding-bottom: 120px; }
.related::before { content: ""; display: block; height: 1px; margin-bottom: 120px; background: var(--line); }

@media (max-width: 640px) {
    .content { font-size: 17px; line-height: 28px; }
    .content > * + * { margin-top: 20px; }
    .content h2 { margin-top: 48px; font-size: 26px; line-height: 32px; }
    .content h3 { margin-top: 32px; font-size: 21px; line-height: 28px; }
    .content h4 { margin-top: 28px; font-size: 18px; line-height: 26px; }
    .content blockquote:not(.kg-blockquote-alt) { font-size: 18px; line-height: 28px; }
    .content .kg-image-card img { border-radius: 8px; }
    .content table { font-size: 14px; line-height: 20px; }
    .content th, .content td { padding: 10px 12px !important; }
    .content th:not(:first-child), .content td:not(:first-child) { min-width: 128px; }
    .table-frame { margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
    .table-frame .table-scroll { border-radius: 0; }
    .table-frame.can-scroll:not(.at-end)::after { border-radius: 0; right: 0; }
    .table-frame.can-scroll td:first-child, .table-frame.can-scroll th:first-child { position: sticky; left: 0; z-index: 1; box-shadow: inset -1px 0 0 var(--line); }
    .callout, .content .kg-callout-card { padding: 20px; }
    .post-main .content > .table-frame.is-wide { width: auto; justify-self: stretch; }
    .content figure + h2 { margin-top: 48px; }
    .content blockquote.kg-blockquote-alt { font-size: 22px; line-height: 30px; }
    .content .kg-bookmark-card a.kg-bookmark-container { flex-direction: column-reverse; }
    .content .kg-bookmark-thumbnail { width: 100%; aspect-ratio: 1200 / 630; max-height: none; }
    .content .kg-bookmark-thumbnail img { position: static; width: 100%; height: 100%; object-fit: cover; }
    .content .kg-gallery-row { flex-wrap: wrap; }
    .content .kg-gallery-image { flex: 1 1 100% !important; }
    .content .kg-gallery-image:not(:first-of-type) { margin: 0.75em 0 0 0; }
    .post-subscribe { padding: 24px; }
    .related::before { margin-bottom: 80px; }
    .related { padding-bottom: 80px; }
}

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; background: rgba(255, 255, 255, 0.94); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); opacity: 0; transition: opacity 0.3s var(--ease); cursor: zoom-out; }
.lightbox.is-open { opacity: 1; }
.lightbox-close { position: absolute; top: 16px; right: 16px; width: 44px; height: 44px; border: 0; border-radius: var(--r-btn); background: #fff; color: var(--ink); font-size: 24px; line-height: 1; cursor: pointer; box-shadow: var(--shadow-white); }
.lightbox-close:hover { opacity: 0.7; }
.content .kg-image-card img:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.lightbox img { max-width: min(1600px, 100%); max-height: 100%; border-radius: var(--r-sm); box-shadow: 0 0 0 1px var(--line-2), 0 24px 64px rgba(0, 0, 0, 0.12); }

/* ---------- Footer (premai.io structure: centered CTA, brand + addresses, 4 link columns, centered copyright) ---------- */
.foot { position: relative; overflow: hidden; margin-top: auto; background: var(--bg); }
.foot-art {
    position: absolute; left: 0; right: 0; bottom: 0; height: 100%;
    background: url("../images/footer-mountains-light.jpg") center 62% / cover no-repeat;
    filter: grayscale(1) contrast(1.05);
    -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, #000 25%);
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, #000 25%);
    pointer-events: none;
}
.foot-inner { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 120px; padding-top: 120px; padding-bottom: 24px; }
.foot-cta { display: flex; flex-direction: column; align-items: center; gap: 24px; max-width: 700px; margin: 0 auto; text-align: center; }
.foot-cta-title { font-size: 56px; line-height: 1.1; text-wrap: balance; }
.foot-cta-text { font-size: 20px; line-height: 28px; color: var(--text-2); text-wrap: balance; }
.foot-cta-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.foot-grid { display: flex; justify-content: space-between; gap: 48px; }
.foot-brand { width: 450px; max-width: 100%; display: flex; flex-direction: column; gap: 24px; }
.foot-logo { display: inline-flex; color: var(--ink); }
.foot-logo .logo-svg { width: 182px; height: 44px; }
.foot-tagline { font-size: 14px; line-height: 19.6px; color: var(--ink); }
.foot-addresses { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: 12px; line-height: 18px; color: var(--muted); }
.foot-addresses li { display: flex; align-items: center; gap: 8px; }
.flag { flex-shrink: 0; width: 16px; height: 12px; border-radius: 2px; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.2); }
.flag-ch { background: linear-gradient(#fff, #fff) center / 8px 2.4px no-repeat, linear-gradient(#fff, #fff) center / 2.4px 8px no-repeat, #3a3d42; }
.flag-us { background: linear-gradient(#3a3d42, #3a3d42) 0 0 / 7px 6px no-repeat, repeating-linear-gradient(180deg, #8a8e94 0 1.5px, #e9eaec 1.5px 3px); }
.flag-it { background: linear-gradient(90deg, #3a3d42 0 33.3%, #fff 33.3% 66.6%, #9a9ea4 66.6%); }
.foot-social { display: flex; gap: 8px; margin-left: -8px; }
.foot-social .icon-btn { color: var(--ink); }
.foot-cols { display: flex; gap: 40px; }
.foot-col { display: flex; flex-direction: column; gap: 12px; min-width: 60px; }
.foot-label { margin-bottom: 4px; font-size: 12px; line-height: 18px; color: var(--text-2); }
.foot-col a { font-size: 14px; line-height: 19.6px; color: var(--ink); transition: opacity 0.4s var(--ease); }
.foot-col a:hover { opacity: 0.7; }
.foot-grid + .foot-bottom { margin-top: -84px; }
.foot-bottom { display: flex; justify-content: center; gap: 16px; font-size: 14px; line-height: 19.6px; color: var(--text-2); }
.foot-bottom a { transition: color 0.4s var(--ease-link); }
.foot-bottom a:hover { color: var(--text-2); }
@media (max-width: 1023px) {
    .foot-grid { flex-direction: column; gap: 56px; }
    .foot-cols { flex-wrap: wrap; gap: 32px 40px; }
}
@media (max-width: 640px) {
    .foot-inner { gap: 64px; padding-top: 64px; }
    .foot-grid + .foot-bottom { margin-top: -32px; }
    .foot-art { -webkit-mask-image: linear-gradient(180deg, transparent 0 55%, #000 85%); mask-image: linear-gradient(180deg, transparent 0 55%, #000 85%); background-position: center bottom; }
    .foot-cta-title { font-size: 36px; }
    .foot-cta-text { font-size: 18px; line-height: 26px; }
    .foot-cols { display: grid; grid-template-columns: 1fr 1fr; }
    .foot-bottom { flex-direction: column; align-items: center; gap: 8px; }
}

/* ---------- Error ---------- */
.error-template { min-height: 100vh; display: grid; place-items: center; }
.error-page { display: flex; flex-direction: column; align-items: center; gap: 24px; padding-top: 80px; padding-bottom: 80px; text-align: center; }
.error-logo { color: var(--ink); margin-bottom: 32px; }
.error-title { font-size: 66px; line-height: 1; text-wrap: balance; }
.error-text { max-width: 480px; font-size: 20px; line-height: 28px; color: var(--text-2); }
@media (max-width: 640px) { .error-title { font-size: 44px; } }

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
    .js .reveal { opacity: 1; transform: none; }
}
