/* ==========================================================================
   ARK-RAPID — site styles in Ark-Lumen ("Guided by Light"), the ARK-RAPID theme
   shared with ark-gemma-az. Two modes: Daybreak (light, :root) and Nightwatch
   ([data-theme="dark"]). The layout's pre-paint script picks one (saved choice,
   else the OS setting) and the header toggle switches it.

   Colours: night navy for trust, cyan light for the values that guide, rapid
   blue for action and violet for AI; the ark mark keeps its own blue and lime.
   Cyan is light, not ink: it glows and underlines, small text uses --light-ink.

   Everything below the two token blocks reads only tokens, so a mode can be
   applied to the whole page (<html data-theme>) or to one element. Post
   custom CSS (.ark-post) and admin.css use the same token names.
   ========================================================================== */

/* ---------- Ark-Lumen tokens ---------- */

:root,
[data-theme="light"] {
    /* Daybreak */
    --bg: #f6f8fc;
    --bg-pattern: radial-gradient(1100px 420px at 50% -180px, rgba(10, 206, 251, .10), transparent 70%);
    --surface: #ffffff;
    --surface-2: #eef2f9;
    --surface-3: #e2e8f4;
    --border: #dde4f0;
    --border-hover: #c3cee3;
    --hover: rgba(8, 19, 56, .04);
    --text: #0b1533;
    --text-dim: #46506a;
    --muted: #5e6782;
    --heading: #081338;
    --link: #1d5bd8;
    --link-hover: #1440a8;
    --primary: #2563eb;
    --on-primary: #ffffff;
    --accent: #2563eb;
    --accent-2: #5b2bd9;
    --accent-3: #0acefb;
    --light: #0acefb;
    --light-ink: #0a6cb0;
    --ai-ink: #5b2bd9;
    --ai-grad: linear-gradient(90deg, #2e71ec 0%, #6b28f4 100%);
    --brand-blue: #1647eb;
    --glow: rgba(46, 113, 236, .20);
    --glow-faint: rgba(10, 206, 251, .10);
    --speak-bg: rgba(10, 206, 251, .16);
    --focus: #2563eb;
    --header-bg: rgba(255, 255, 255, .86);
    --shadow: 0 1px 2px rgba(8, 19, 56, .06), 0 8px 24px rgba(8, 19, 56, .08);
    --shadow-lg: 0 24px 48px rgba(8, 19, 56, .16);
    --scroll: #d3dbea;
    --mark: url("/img/brand/ark-mark.png");

    /* Code stays on night-navy console surfaces in both modes. */
    --code-bg: #040b24;
    --code-border: #13214a;
    --code-text: #e3e8f0;
    --code-dim: #93a1b8;
    --inline-code-bg: #eef2f9;
    --inline-code-text: #5b2bd9;

    --info: #1d5bd8;   --info-bg: rgba(46, 113, 236, .10);
    --tip: #15803d;    --tip-bg: rgba(21, 128, 61, .10);
    --warn: #a15c07;   --warn-bg: rgba(217, 119, 6, .10);
    --danger: #b42318; --danger-bg: rgba(180, 35, 24, .08);
    color-scheme: light;
}

[data-theme="dark"] {
    /* Nightwatch: the light kept burning through the night */
    --bg: #030a22;
    --bg-pattern: radial-gradient(1100px 420px at 50% -180px, rgba(10, 206, 251, .08), transparent 70%),
                  radial-gradient(700px 360px at 92% -60px, rgba(107, 40, 244, .10), transparent 70%);
    --surface: #071231;
    --surface-2: #0c1a40;
    --surface-3: #13234f;
    --border: #172659;
    --border-hover: #263c7c;
    --hover: rgba(255, 255, 255, .05);
    --text: #eaf0ff;
    --text-dim: #a7b3d1;
    --muted: #8a97ba;
    --heading: #ffffff;
    --link: #7cc4ff;
    --link-hover: #a9d8ff;
    --primary: #2563eb;
    --on-primary: #ffffff;
    --accent: #4fd8ff;
    --accent-2: #a78bfa;
    --accent-3: #0acefb;
    --light: #0acefb;
    --light-ink: #4fd8ff;
    --ai-ink: #a78bfa;
    --ai-grad: linear-gradient(90deg, #5b9bff 0%, #a27bff 100%);
    --brand-blue: #6ea8ff;
    --glow: rgba(10, 206, 251, .20);
    --glow-faint: rgba(10, 206, 251, .07);
    --speak-bg: rgba(10, 206, 251, .14);
    --focus: #0acefb;
    --header-bg: rgba(7, 18, 49, .84);
    --shadow: 0 8px 32px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 48px rgba(0, 0, 0, .60);
    --scroll: #1a2b60;
    --mark: url("/img/brand/ark-mark-night.png");

    --code-bg: #010616;
    --code-border: #172659;
    --inline-code-bg: #13234f;
    --inline-code-text: #c4b5fd;

    --info: #7cc4ff;   --info-bg: rgba(46, 113, 236, .16);
    --tip: #4ade80;    --tip-bg: rgba(74, 222, 128, .12);
    --warn: #fbbf24;   --warn-bg: rgba(251, 191, 36, .12);
    --danger: #f87171; --danger-bg: rgba(248, 113, 113, .12);
    color-scheme: dark;
}

:root {
    /* Brand constants, the same in both modes */
    --lumen: linear-gradient(90deg, #0acefb 0%, #2e71ec 45%, #6b28f4 100%);
    --accent-grad: linear-gradient(135deg, #2563eb 0%, #5b3bef 100%);

    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-ui: var(--font-body);
    --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --font-head: var(--font-display);
    --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, "Cascadia Mono", "Roboto Mono", monospace;
    --head-weight: 600;
    --radius: 14px;

    /* Reading: the reader's text size, typeface and spacing (Reading settings on a post) adjust these. */
    --content-size: 1.125rem;
    --content-leading: 1.75;
    --header-h: 64px;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: calc(var(--header-h) + 20px);
    scrollbar-color: var(--scroll) var(--bg);
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.65;
    color: var(--text);
    /* First light: a faint glow above every page. */
    background: var(--bg-pattern), var(--bg);
    background-repeat: no-repeat;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}
body.is-listening { padding-bottom: 104px; }

main { flex: 1; outline: none; }

h1, h2, h3, h4 {
    font-family: var(--font-ui);
    font-weight: 700;
    color: var(--heading);
    line-height: 1.22;
    letter-spacing: -0.01em;
    margin: 0 0 .5em;
}
h1, h2 { font-family: var(--font-head); font-weight: var(--head-weight); letter-spacing: -0.005em; }

a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); text-decoration-thickness: 2px; }

img { max-width: 100%; height: auto; }

::selection { background: rgba(10, 206, 251, .30); color: var(--heading); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }

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

.skip-link {
    position: absolute; left: 12px; top: -48px; z-index: 100;
    padding: 8px 14px; border-radius: 8px;
    background: var(--primary); color: var(--on-primary); font-family: var(--font-ui);
}
.skip-link:focus { top: 12px; }

.eyebrow {
    margin: 0 0 .4rem;
    font-family: var(--font-ui);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--light-ink);
}

.lede { font-size: 1.15rem; color: var(--text-dim); max-width: 46rem; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 2rem 0; }

/* ---------- Brand: the mark, the wordmark and the motto ---------- */

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--heading); }
.brand:hover { color: var(--heading); }

/* The ark: blue on Daybreak, relit on Nightwatch. A background image, so only the active one loads. */
.ark-mark {
    display: inline-block; flex: none;
    width: 40px; height: 40px;
    background: var(--mark) center / contain no-repeat;
}
.ark-mark-lg { width: 144px; height: 144px; }

/* A soft halo of light behind whatever it wraps. */
.ark-glow { position: relative; display: inline-grid; place-items: center; }
.ark-glow::before {
    content: "";
    position: absolute;
    inset: -36px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(10, 206, 251, .26), rgba(107, 40, 244, .10) 60%, transparent);
}
.ark-glow > * { position: relative; }

.brand-text { font-family: var(--font-ui); font-weight: 800; font-size: 1.18rem; letter-spacing: .04em; white-space: nowrap; }
.brand-ark { color: var(--brand-blue); }
.brand-dash { color: var(--heading); margin: 0 1px; }
.brand-rapid { color: var(--heading); }

.ark-tagline {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--text-dim);
    letter-spacing: .01em;
}

/* ---------- Buttons and form controls ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45em;
    padding: .62em 1.15em;
    border: 1px solid transparent;
    border-radius: 999px;
    font-family: var(--font-ui);
    font-size: .95rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: transform .15s ease, background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .2s ease, filter .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { flex: none; }
.btn-primary { background: var(--accent-grad); color: var(--on-primary); }
.btn-primary:hover { color: var(--on-primary); filter: brightness(1.08); box-shadow: 0 6px 18px var(--glow); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-hover); }
.btn-ghost:hover { border-color: var(--accent); color: var(--heading); background: var(--hover); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: .38em .8em; font-size: .82rem; }
.btn-block { width: 100%; }

/* Round icon button: theme toggle, search link, player controls. */
.icon-btn {
    display: inline-grid; place-items: center; flex: none;
    width: 36px; height: 36px; padding: 0;
    border: 1px solid var(--border); border-radius: 999px;
    background: transparent; color: var(--text-dim);
    cursor: pointer; text-decoration: none;
    transition: color .15s, border-color .15s, box-shadow .2s, background-color .15s;
}
.icon-btn:hover { color: var(--light-ink); border-color: var(--light); box-shadow: 0 0 0 4px var(--glow-faint); }

.ark-theme-toggle .ark-icon-sun { display: none; }
[data-theme="dark"] .ark-theme-toggle .ark-icon-sun { display: block; }
[data-theme="dark"] .ark-theme-toggle .ark-icon-moon { display: none; }

/* Segmented control: one choice of a few, as aria-pressed buttons. */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.seg button {
    min-height: 34px; padding: .3em .9em;
    border: 0; border-radius: 999px; background: transparent;
    color: var(--text-dim); font-family: var(--font-ui); font-size: .86rem; font-weight: 600; cursor: pointer;
}
.seg button:hover { color: var(--heading); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--heading); box-shadow: 0 1px 2px rgba(8, 19, 56, .12), 0 0 0 1px var(--border); }
.seg .seg-serif { font-family: var(--font-display); font-size: .95rem; }

input, select, textarea, button { font: inherit; }

input[type="text"], input[type="email"], input[type="search"], input[type="password"], input[type="url"],
input[type="datetime-local"], input:not([type]), select, textarea {
    width: 100%;
    padding: .62em .85em;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: .95rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--glow);
}
::placeholder { color: var(--muted); opacity: .85; }

/* ---------- Header ---------- */

.site-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--header-bg);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--border);
}
/* The lumen line: the logo's light, cyan to violet, across the top of every page. */
.site-header::before {
    content: "";
    position: absolute; top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--lumen);
}
.header-inner { display: flex; align-items: center; gap: 20px; min-height: var(--header-h); }
.site-nav { display: flex; align-items: center; gap: 2px; margin-left: auto; font-family: var(--font-ui); }
.site-nav a {
    position: relative;
    padding: .45em .8em; border-radius: 999px;
    color: var(--text-dim); font-weight: 600; font-size: .95rem; text-decoration: none;
}
.site-nav a:hover { color: var(--heading); background: var(--hover); }
.site-nav a[aria-current="page"] { color: var(--heading); }
.site-nav a[aria-current="page"]::after {
    content: "";
    position: absolute; left: .8em; right: .8em; bottom: .1em;
    height: 2px; border-radius: 2px;
    background: var(--lumen);
    box-shadow: 0 0 8px var(--glow);
}
.site-nav .nav-cta { color: var(--link); }
.site-search { width: 210px; }
.site-search input { border-radius: 999px; padding: .5em 1em; font-size: .9rem; background: var(--surface); }
.header-tools { display: flex; align-items: center; gap: 6px; }
.search-link { display: none; }

/* Reading progress: the lumen fills the header's lower edge as you read a post. */
.read-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; pointer-events: none; }
.read-progress span {
    display: block; height: 100%; width: 0;
    background: var(--lumen);
    box-shadow: 0 0 10px var(--glow);
}

/* ---------- Hero ---------- */

.hero { padding: 64px 0 28px; }
.hero-inner { display: flex; align-items: center; gap: 56px; }
.hero-mark { flex: none; margin: 8px 12px; }
.hero-title {
    font-family: var(--font-ui); font-weight: 800;
    font-size: clamp(2.5rem, 6vw, 4rem);
    letter-spacing: .02em;
    margin-bottom: .05em;
}
.hero-motto { font-size: clamp(1.2rem, 2.6vw, 1.5rem); margin: 0 0 .7rem; }
.hero-tagline { font-size: clamp(1.05rem, 2vw, 1.2rem); font-weight: 600; color: var(--heading); margin: 0 0 .5rem; }
.hero-intro { color: var(--text-dim); max-width: 44rem; margin: 0 0 1.5rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Sections, chips and cards ---------- */

.page-section { padding: 28px 24px 56px; }
.section-title { font-size: 1.6rem; margin: 2rem 0 1.1rem; }
.list-header { margin: 8px 0 18px; }
.list-header h1 { font-size: clamp(2rem, 4.5vw, 2.8rem); }

.topics { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

.chip {
    display: inline-flex; align-items: center; gap: .45em;
    padding: .32em .85em;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    position: relative; z-index: 1;
}
.chip:hover, .chip[aria-current="page"] { border-color: var(--accent); color: var(--heading); }
.chip[aria-current="page"] { box-shadow: 0 0 0 3px var(--glow-faint); }
.chip-sm { font-size: .76rem; padding: .22em .7em; }
.chip-count {
    min-width: 1.5em; padding: 0 .4em; border-radius: 999px;
    background: var(--surface-2); color: var(--muted); font-size: .78em; text-align: center;
}

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px; }

.card {
    position: relative;
    display: flex; flex-direction: column; gap: .55rem;
    padding: 24px 22px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--lumen); opacity: .85; }
.card:hover { transform: translateY(-3px); border-color: var(--border-hover); box-shadow: var(--shadow), 0 10px 30px var(--glow-faint); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 1.6em; }
.card-title { font-size: 1.2rem; margin: .1rem 0 0; letter-spacing: -0.01em; }
.card-title a { color: var(--heading); text-decoration: none; }
.card-title a::after { content: ""; position: absolute; inset: 0; }
.card-title a:hover { color: var(--link); }
.card-subtitle { margin: 0; color: var(--text-dim); font-family: var(--font-display); font-style: italic; font-size: 1.05rem; }
.card-summary { margin: 0; color: var(--muted); font-size: .95rem; flex: 1; }
.card-meta { display: flex; flex-wrap: wrap; gap: .45em; font-family: var(--font-ui); font-size: .8rem; color: var(--muted); }

@media (min-width: 900px) {
    .card-featured { grid-column: span 2; padding: 32px 30px 24px; }
    .card-featured .card-title { font-family: var(--font-display); font-weight: 600; font-size: 1.8rem; letter-spacing: -0.005em; }
}

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 36px 0 8px; font-family: var(--font-ui); }
.pagination-status { color: var(--muted); font-size: .9rem; }

.breadcrumb { font-family: var(--font-ui); font-size: .85rem; margin: 6px 0 18px; }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: .4em; list-style: none; margin: 0; padding: 0; color: var(--muted); }
.breadcrumb li + li::before { content: "/"; margin-right: .4em; color: var(--border-hover); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--link); }
.breadcrumb [aria-current="page"] { color: var(--text); max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.search-large { display: flex; gap: 10px; max-width: 560px; margin-top: 1rem; }

/* ---------- Post ---------- */

.post { padding: 24px 0 40px; }
.post-header { max-width: 50rem; margin-bottom: 24px; }
.post-title { font-size: clamp(2rem, 4.8vw, 3.1rem); letter-spacing: -0.015em; line-height: 1.14; margin: .45rem 0 .4rem; }
.post-subtitle { font-family: var(--font-display); font-style: italic; font-size: 1.3rem; line-height: 1.45; color: var(--text-dim); margin: 0 0 1rem; }
.post-meta { display: flex; flex-wrap: wrap; gap: .5em; margin: 0; font-family: var(--font-ui); font-size: .9rem; color: var(--muted); }
.post-meta a { color: var(--text); font-weight: 600; }

/* Listen and Reading settings, under the post's title. */
.reader-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; }
.btn-listen .listen-time { font-weight: 500; opacity: .85; }
.reader-settings {
    max-width: 36rem;
    margin-top: 14px;
    padding: 18px 20px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    font-family: var(--font-ui);
}
.reader-settings[hidden] { display: none; }
.setting { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); align-items: center; gap: 8px 14px; margin-bottom: 14px; }
.setting-label { font-size: .82rem; font-weight: 700; color: var(--text-dim); }
.setting > :is(.seg, .size-control) { justify-self: start; }
.size-control { display: inline-flex; align-items: center; gap: 8px; }
.size-value { min-width: 3.4em; text-align: center; font-variant-numeric: tabular-nums; font-size: .9rem; color: var(--text); }
.setting select { max-width: 22rem; }
.setting-note { grid-column: 2; margin: -6px 0 0; font-size: .78rem; color: var(--muted); }

.post-cover { margin: 0 0 24px; }
.post-cover img { width: 100%; max-height: 460px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }

.post-tldr {
    position: relative;
    max-width: 50rem;
    margin: 0 0 32px;
    padding: 16px 20px 16px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: calc(1.0625rem * var(--reader-scale, 1));
    overflow: hidden;
}
.post-tldr::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(180deg, #0acefb, #2e71ec 50%, #6b28f4); }
.post-tldr p { margin: 0; }
.tldr-label {
    font-family: var(--font-ui); font-size: .72rem; font-weight: 800;
    letter-spacing: .14em; text-transform: uppercase; color: var(--light-ink); margin-bottom: .25rem !important;
}

.post-shell { display: block; }
.post-shell.has-toc { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 52px; align-items: start; }
.post-toc { position: sticky; top: calc(var(--header-h) + 24px); max-height: calc(100vh - var(--header-h) - 48px); overflow: auto; font-family: var(--font-ui); font-size: .86rem; }
.toc-title {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    font-weight: 800; color: var(--heading); margin: 0 0 .5rem;
    text-transform: uppercase; letter-spacing: .1em; font-size: .72rem;
    list-style: none; cursor: pointer;
}
.toc-title::-webkit-details-marker { display: none; }
.toc-title::after { content: "+"; font-family: var(--font-mono); font-size: 1rem; color: var(--light-ink); }
.post-toc details[open] .toc-title::after { content: "–"; }
.post-toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.post-toc li a {
    display: block; padding: .3em .8em; margin-left: -2px;
    border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.35;
}
.post-toc li.toc-l3 a { padding-left: 1.6em; font-size: .95em; }
.post-toc li a:hover { color: var(--heading); }
.post-toc li a.is-active { color: var(--link); border-left-color: var(--light); font-weight: 600; }

.post-body { min-width: 0; max-width: 46rem; }

/* Long-form content. Applies to posts and to the editor preview. Sizes are in em, so the reader's
   text size scales headings, code and tables with the prose. */
.post-content {
    font-size: calc(var(--content-size) * var(--reader-scale, 1));
    line-height: var(--content-leading);
    overflow-wrap: break-word;
}
[data-reader-font="serif"] .post-content,
[data-reader-font="serif"] .post-tldr p:not(.tldr-label) { font-family: var(--font-display); }
[data-reader-spacing="roomy"] .post-content { --content-leading: 1.95; letter-spacing: .012em; word-spacing: .05em; }
[data-reader-spacing="roomy"] .post-content :is(p, ul, ol, blockquote) { margin-bottom: 1.45em; }

.post-content > :first-child { margin-top: 0; }
.post-content h2 { font-size: 1.5em; margin: 2em 0 .55em; padding-top: .2em; line-height: 1.25; }
.post-content h3 { font-size: 1.2em; margin: 1.7em 0 .5em; }
.post-content h4 { font-size: 1.04em; margin: 1.5em 0 .4em; }
.post-content :is(h2, h3, h4)[id] { scroll-margin-top: calc(var(--header-h) + 24px); }
.post-content p, .post-content ul, .post-content ol, .post-content blockquote, .post-content table, .post-content figure, .post-content dl { margin: 0 0 1.2em; }
.post-content ul, .post-content ol { padding-left: 1.4em; }
.post-content li { margin: .35em 0; }
.post-content li::marker { color: var(--light-ink); }
.post-content li > ul, .post-content li > ol { margin: .3em 0; }
.post-content strong { color: var(--heading); }
.post-content hr { border: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--border-hover), transparent); margin: 2.4em 0; }
.post-content img { border-radius: calc(var(--radius) * .7); }
.post-content figure { text-align: center; }
.post-content figcaption { margin-top: .5em; font-family: var(--font-ui); font-size: .82em; color: var(--muted); }
.post-content blockquote {
    padding: .2em 0 .2em 1.1em; border-left: 3px solid var(--accent-2);
    color: var(--text-dim); font-family: var(--font-display); font-style: italic; font-size: 1.06em;
}
.post-content table { width: 100%; border-collapse: collapse; font-size: .9em; display: block; overflow-x: auto; }
.post-content th, .post-content td { padding: .6em .8em; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.post-content th { font-family: var(--font-ui); font-size: .82em; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); background: var(--surface-2); }
.post-content tbody tr:hover > td { background: var(--hover); }
.post-content .task-list-item { list-style: none; margin-left: -1.2em; }
.post-content .task-list-item input { margin-right: .5em; }

.post-content :not(pre) > code {
    padding: .12em .4em;
    border-radius: 6px;
    background: var(--inline-code-bg);
    color: var(--inline-code-text);
    font-family: var(--font-mono);
    font-size: .84em;
}

.post-content pre {
    margin: 0 0 1.3em;
    padding: 16px 18px;
    overflow-x: auto;
    border: 1px solid var(--code-border);
    border-radius: calc(var(--radius) * .75);
    background: var(--code-bg);
    color: var(--code-text);
    font-family: var(--font-mono);
    font-size: .8em;
    line-height: 1.6;
    tab-size: 4;
}
.post-content pre code { font-family: inherit; font-size: inherit; background: none; padding: 0; color: inherit; }

/* Code colours, Ark-Lumen night console. The page loads no highlight.js stylesheet. */
:is(.post-content pre, .console-code) code.hljs { display: block; background: transparent; padding: 0; overflow: visible; color: var(--code-text); }
:is(.post-content, .console-code) :is(.hljs-comment, .hljs-quote) { color: #8a97ba; font-style: italic; }
:is(.post-content, .console-code) :is(.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-section, .hljs-doctag) { color: #c4a7ff; }
:is(.post-content, .console-code) :is(.hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta .hljs-string) { color: #a7f3d0; }
:is(.post-content, .console-code) :is(.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link) { color: #fcd34d; }
:is(.post-content, .console-code) :is(.hljs-title, .hljs-title.function_, .hljs-title.class_, .hljs-name, .hljs-tag, .hljs-selector-id, .hljs-selector-class) { color: #7cc4ff; }
:is(.post-content, .console-code) :is(.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-property, .hljs-params) { color: #4fd8ff; }
:is(.post-content, .console-code) :is(.hljs-built_in, .hljs-type, .hljs-selector-pseudo) { color: #f0abfc; }
:is(.post-content, .console-code) .hljs-meta { color: #93a1b8; }
:is(.post-content, .console-code) .hljs-deletion { color: #f87171; }
:is(.post-content, .console-code) .hljs-emphasis { font-style: italic; }
:is(.post-content, .console-code) .hljs-strong { font-weight: 700; }

/* Code frame added by site.js: language label and copy button. */
.code-frame { margin: 0 0 1.4em; border: 1px solid var(--code-border); border-radius: calc(var(--radius) * .75); overflow: hidden; background: var(--code-bg); }
.code-frame pre { margin: 0; border: 0; border-radius: 0; }
.code-head {
    position: relative;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 10px 6px 16px;
    border-bottom: 1px solid var(--code-border);
    background: rgba(255, 255, 255, .03);
    font-family: var(--font-mono);
    font-size: .7rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--code-dim);
}
.code-head::before { content: ""; position: absolute; top: 0; left: 0; width: 64px; height: 2px; background: var(--lumen); }
.code-copy {
    min-height: 28px;
    border: 1px solid var(--code-border); border-radius: 6px; background: transparent;
    color: var(--code-dim); font-family: var(--font-mono); font-size: .72rem; padding: 3px 10px; cursor: pointer;
}
.code-copy:hover { color: #ffffff; border-color: #0acefb; }

/* Callouts: Markdown ::: containers, GitHub-style > [!NOTE] alerts, and HTML class="callout …". */
.post-content :is(.tip, .info, .note, .warning, .danger, .success, .markdown-alert, .callout) {
    margin: 0 0 1.3em;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: 0 calc(var(--radius) * .7) calc(var(--radius) * .7) 0;
    background: var(--info-bg);
    border-left-color: var(--info);
}
.post-content :is(.tip, .info, .note, .warning, .danger, .success, .markdown-alert) > :last-child { margin-bottom: 0; }
.post-content :is(.tip, .success, .markdown-alert-tip) { background: var(--tip-bg); border-left-color: var(--tip); }
.post-content :is(.warning, .markdown-alert-warning, .markdown-alert-important) { background: var(--warn-bg); border-left-color: var(--warn); }
.post-content :is(.danger, .markdown-alert-caution) { background: var(--danger-bg); border-left-color: var(--danger); }
.post-content :is(.tip, .info, .note, .warning, .danger, .success)::before {
    display: block; margin-bottom: .3em;
    font-family: var(--font-ui); font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
}
.post-content .tip::before { content: "Tip"; color: var(--tip); }
.post-content .success::before { content: "Works"; color: var(--tip); }
.post-content .info::before, .post-content .note::before { content: "Note"; color: var(--info); }
.post-content .warning::before { content: "Watch out"; color: var(--warn); }
.post-content .danger::before { content: "Danger"; color: var(--danger); }
.post-content .callout::before { content: none; }
.post-content .markdown-alert-title {
    display: flex; align-items: center; gap: .4em; margin-bottom: .3em !important;
    font-family: var(--font-ui); font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.post-content .markdown-alert-title svg { fill: currentColor; }
.post-content .markdown-alert-note .markdown-alert-title { color: var(--info); }
.post-content .markdown-alert-tip .markdown-alert-title { color: var(--tip); }
.post-content :is(.markdown-alert-warning, .markdown-alert-important) .markdown-alert-title { color: var(--warn); }
.post-content .markdown-alert-caution .markdown-alert-title { color: var(--danger); }

.post-content .mermaid {
    margin: 0 0 1.3em; padding: 16px; text-align: center; overflow-x: auto;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}

/* The block being read aloud. A spread shadow, so the highlight never moves the text. */
.post-content .is-speaking, .post-tldr.is-speaking, .post-header .is-speaking {
    background: var(--speak-bg);
    box-shadow: 0 0 0 .35em var(--speak-bg);
    border-radius: 4px;
    transition: background-color .25s ease, box-shadow .25s ease;
}

.post-tags { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 2.2rem 0 1.4rem; }

/* Reactions */
.reactions {
    margin: 2rem 0 1rem;
    padding: 20px 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
}
.reactions-title { font-size: 1.25rem; margin: 0 0 .8rem; }
.reactions-buttons { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.react {
    display: inline-flex; align-items: center; gap: .55em;
    min-height: 44px;
    padding: .55em 1.1em .55em .7em;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font-ui);
    font-weight: 700;
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease, background-color .15s ease;
}
.react:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); }
.react:disabled { cursor: default; opacity: .7; }
.react-icon {
    display: inline-grid; place-items: center;
    width: 2.1em; height: 2.1em; border-radius: 50%;
    background: var(--surface); font-size: 1.15rem; line-height: 1;
    box-shadow: 0 0 0 1px var(--border);
}
.react-count { min-width: 1.4em; padding: .05em .45em; border-radius: 999px; background: var(--surface); font-variant-numeric: tabular-nums; }
.react-clap[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--heading); }
.react-critic[aria-pressed="true"] { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 14%, var(--surface)); color: var(--heading); }
.react.is-pop .react-icon { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.3) rotate(-8deg); } }
.reactions-note { margin: .8rem 0 0; font-size: .82rem; color: var(--muted); font-family: var(--font-ui); }
.reactions-status { margin: .3rem 0 0; min-height: 1.2em; font-size: .85rem; color: var(--danger); font-family: var(--font-ui); }

.share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 1rem 0 2rem; font-family: var(--font-ui); }
.share-label { font-size: .85rem; color: var(--muted); margin-right: 4px; }

/* FAQ */
.post-faq { margin: 2.5rem 0; }
.post-faq h2 { font-size: 1.6rem; }
.post-faq details {
    border: 1px solid var(--border); border-radius: calc(var(--radius) * .7);
    background: var(--surface); margin-bottom: 10px; overflow: hidden;
}
.post-faq summary {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px; cursor: pointer; list-style: none;
}
.post-faq summary::-webkit-details-marker { display: none; }
.post-faq summary::after { content: "+"; font-family: var(--font-mono); font-size: 1.2rem; color: var(--light-ink); }
.post-faq details[open] summary::after { content: "–"; }
.post-faq summary h3 { font-size: 1.02rem; margin: 0; }
.faq-answer { padding: 0 18px 14px; color: var(--text); font-size: calc(1rem * var(--reader-scale, 1)); }
.faq-answer p { margin: 0; }

.author-box {
    display: flex; gap: 18px; align-items: flex-start;
    padding: 20px 22px; margin: 2rem 0;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
}
.author-box .ark-mark { width: 56px; height: 56px; }
.author-box p { margin: 0 0 .3em; }
.author-name { font-weight: 700; color: var(--heading); }
.author-role { font-family: var(--font-ui); font-size: .88rem; color: var(--light-ink); font-weight: 600; }
.author-bio { font-size: .95rem; color: var(--text-dim); }

.related { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.preview-banner {
    position: sticky; top: var(--header-h); z-index: 40;
    padding: 10px 24px; text-align: center;
    background: var(--warn-bg); color: var(--text); border-bottom: 1px solid var(--border);
    font-family: var(--font-ui); font-size: .9rem;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

/* ---------- Listen: the read-aloud player ---------- */

.listen-player {
    position: fixed; z-index: 70;
    left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    width: min(680px, calc(100% - 24px));
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center; gap: 6px 14px;
    padding: 12px 14px 12px 12px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-ui);
    overflow: hidden;
}
.listen-player[hidden] { display: none; }
.listen-player::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--lumen); }
.listen-controls, .listen-options { display: flex; align-items: center; gap: 6px; }
.listen-player .icon-btn { width: 40px; height: 40px; }
.listen-player .listen-play { width: 46px; height: 46px; border: 0; background: var(--accent-grad); color: #fff; }
.listen-player .listen-play:hover { color: #fff; filter: brightness(1.08); box-shadow: 0 6px 18px var(--glow); }
.listen-play .icon-pause { display: none; }
.listen-player.is-playing .listen-play .icon-play { display: none; }
.listen-player.is-playing .listen-play .icon-pause { display: block; }
.listen-info { min-width: 0; }
.listen-title { margin: 0; font-size: .74rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--light-ink); }
.listen-now { margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .88rem; color: var(--text); }
.listen-bar { height: 4px; margin-top: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.listen-bar span { display: block; height: 100%; width: 0; background: var(--lumen); transition: width .3s ease; }
.listen-rate { width: auto; min-height: 40px; padding: .35em .5em; border-radius: 999px; font-size: .86rem; font-variant-numeric: tabular-nums; }

/* ---------- Newsletter ---------- */

.newsletter { padding: 8px 0 56px; }
.newsletter-inner {
    position: relative;
    display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: center;
    padding: 36px 36px;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) * 1.4);
    background:
        radial-gradient(520px 240px at 100% 0, rgba(107, 40, 244, .12), transparent 70%),
        radial-gradient(520px 240px at 0 100%, rgba(10, 206, 251, .14), transparent 70%),
        var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.newsletter-inner::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--lumen); }
.newsletter h2 { font-size: 1.8rem; margin-bottom: .3em; }
.newsletter-copy p:last-child { margin: 0; color: var(--text-dim); }
.newsletter-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.newsletter-form input[type="email"] { border-radius: 999px; padding: .75em 1.1em; }
.newsletter-status { grid-column: 1 / -1; margin: 0; min-height: 1.4em; font-family: var(--font-ui); font-size: .9rem; }
.newsletter-status.is-ok { color: var(--tip); }
.newsletter-status.is-error { color: var(--danger); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Footer ---------- */

.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 40px 0 24px; font-family: var(--font-ui); }
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; }
.footer-brand .ark-mark { width: 36px; height: 36px; }
.footer-motto { margin: .8rem 0 .3rem; font-size: 1.05rem; }
.footer-brand p { color: var(--muted); max-width: 30rem; font-size: .92rem; }
.footer-links { display: flex; flex-direction: column; gap: 6px; font-size: .92rem; }
.footer-links h2 { font-size: .74rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 0 0 .4rem; font-family: var(--font-ui); font-weight: 700; }
.footer-links a { color: var(--text); text-decoration: none; padding: 2px 0; }
.footer-links a:hover { color: var(--link); text-decoration: underline; }
.footer-note { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); font-size: .82rem; color: var(--muted); }

/* ---------- Misc pages ---------- */

.panel {
    padding: 20px 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.panel h2 { font-size: 1.3rem; }
.panel h3 { font-size: 1.05rem; }
.panel ul { padding-left: 1.2em; margin: 0; }

.narrow { max-width: 680px; }
.message-panel { margin-top: 40px; text-align: center; }
.message-panel.is-ok { border-top: 4px solid var(--tip); }
.message-panel.is-error { border-top: 4px solid var(--danger); }
.message-panel form { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.error-page { text-align: center; padding-top: 64px; }
.error-page .search-large { margin: 1.5rem auto; }
.error-code {
    font-family: var(--font-mono); font-size: clamp(4rem, 14vw, 7rem); font-weight: 800; line-height: 1; margin: 0;
    background: var(--lumen); -webkit-background-clip: text; background-clip: text; color: transparent;
}

.about-header { display: flex; gap: 40px; align-items: center; margin-bottom: 28px; }
.about-header .ark-glow { margin: 24px; }
.about-header .ark-mark { width: 112px; height: 112px; }
.about-header h1 { font-size: clamp(2.2rem, 5vw, 3rem); margin: 0; }
.about-header .lede { margin: .3rem 0; color: var(--heading); font-weight: 600; }
.about .prose { max-width: 48rem; margin: 2rem 0 1rem; }
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.service-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.cta-panel {
    position: relative;
    margin-top: 3rem; padding: 36px 32px; text-align: center;
    border-radius: calc(var(--radius) * 1.4);
    background:
        radial-gradient(700px 300px at 50% 120%, rgba(10, 206, 251, .18), transparent 70%),
        radial-gradient(500px 260px at 90% -20%, rgba(107, 40, 244, .12), transparent 70%),
        var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}
.cta-panel::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--lumen); }
.cta-panel .hero-actions { justify-content: center; }

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
    .post-shell.has-toc { grid-template-columns: 1fr; gap: 0; }
    .post-toc { position: static; max-height: none; margin-bottom: 24px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
    .post-toc .toc-title { margin: 0; min-height: 28px; }
    .post-toc details[open] .toc-title { margin-bottom: .6rem; }
    .post-body { max-width: none; }
    .site-search { display: none; }
    .search-link { display: inline-grid; }
}

@media (max-width: 760px) {
    :root { --content-size: 1.0625rem; --header-h: 58px; }
    body { font-size: 16px; }
    .wrap { padding: 0 16px; }
    .page-section { padding: 20px 16px 44px; }
    .header-inner { gap: 10px; }
    .brand { gap: 8px; }
    .brand .ark-mark { width: 32px; height: 32px; }
    .brand-text { font-size: 1rem; }
    .site-nav a { padding: .45em .55em; font-size: .9rem; }
    .site-nav a[aria-current="page"]::after { left: .55em; right: .55em; }
    .site-nav a[href="/"] { display: none; }
    .icon-btn { width: 34px; height: 34px; }
    .hero { padding: 36px 0 12px; }
    .hero-inner { flex-direction: column; align-items: flex-start; gap: 22px; }
    .hero-mark { margin: 12px 18px 0; }
    .ark-mark-lg { width: 96px; height: 96px; }
    .post { padding-top: 16px; }
    .post-subtitle { font-size: 1.15rem; }
    .setting { grid-template-columns: 1fr; gap: 6px; }
    .setting-note { grid-column: 1; margin: 0; }
    .reader-settings { padding: 16px 16px 4px; }
    /* Top-level code and diagrams use the full screen width on phones (not ones inside callouts). */
    .post-content > :is(.code-frame, .mermaid, pre) { margin-left: -16px; margin-right: -16px; border-left: 0; border-right: 0; border-radius: 0; }
    .post-content :is(p, li) { hyphens: auto; -webkit-hyphens: auto; }
    .newsletter-inner { grid-template-columns: 1fr; padding: 28px 20px; }
    .newsletter-form { grid-template-columns: 1fr; }
    .footer-inner { grid-template-columns: 1fr 1fr; }
    .footer-brand { grid-column: 1 / -1; }
    .about-header { flex-direction: column; align-items: flex-start; gap: 16px; }
    .about-grid { grid-template-columns: 1fr; }
    .author-box { flex-direction: column; }
    .search-large { flex-direction: column; }
    .breadcrumb [aria-current="page"] { max-width: 22ch; }
    .share .btn, .reader-bar .btn { min-height: 44px; }

    .listen-player {
        grid-template-columns: minmax(0, 1fr) auto;
        bottom: 0; width: 100%;
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
        border-radius: 18px 18px 0 0; border-bottom: 0;
    }
    .listen-info { grid-column: 1 / -1; grid-row: 1; }
    .listen-controls { grid-row: 2; }
    .listen-options { grid-row: 2; }
    body.is-listening { padding-bottom: 150px; }
}

@media (max-width: 480px) {
    .site-nav .nav-cta { display: none; }
}

@media (max-width: 359px) {
    .brand-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
    .site-header, .site-footer, .newsletter, .reactions, .share, .post-toc, .related, .read-progress, .code-copy,
    .reader-bar, .reader-settings, .listen-player, .skip-link { display: none !important; }
    body { background: #fff; color: #000; padding: 0 !important; }
    .post-content { font-size: 11pt; }
    .post-content a { color: inherit; }
}
