@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Inter+Tight:wght@600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap");

/* ==========================================================================
   The Kargo Book — theme
   ==========================================================================
   mdBook ships a deliberately plain theme. This file layers a complete design
   system over it: a violet→blue→cyan gradient accent, Inter / Inter Tight
   typography, card surfaces, dark code blocks, and the two navigation
   affordances mdBook lacks — collapsible sidebar sections and an "On this page"
   rail (both built by theme/ui.js).

   Structure
     1. Tokens              6. Headings and prose
     2. Theme mapping       7. Code
     3. Base layout         8. Tables
     4. Sidebar             9. Status callouts and pills
     5. Top bar            10. On this page
                           11. Page nav, hero, misc
   ========================================================================== */

/* NOTE ON UNITS
   mdBook's general.css sets `:root { font-size: 62.5% }`, so 1rem = 10px here,
   not 16px. Every rem below is written against that 10px base — a value that
   looks like "1.6rem" is 16px. Keep that in mind when editing, or text ends up
   silently 1.6x too small. */

/* 1. Tokens ============================================================== */

:root {
    /* ---- Accent ramp -------------------------------------------------
       The whole palette derives from these three stops. Warm amber → orange
       → coral, the Firebase family: no purple, no pink, no magenta anywhere.
       Swap these three and the gradient, and the entire site follows. */
    --k-c1: #ffb020;
    --k-c2: #ff7a3d;
    --k-c3: #f2552c;
    --k-accent: var(--k-c2);

    --k-grad: linear-gradient(95deg, #ffb020 0%, #ff7a3d 55%, #f2552c 100%);
    --k-grad-soft: linear-gradient(
        95deg,
        rgba(255, 176, 32, 0.16),
        rgba(255, 122, 61, 0.13),
        rgba(242, 85, 44, 0.12)
    );

    /* Ambient washes behind the page — the gradient should be felt, not just
       seen on a few components. */
    --k-wash:
        radial-gradient(980px 540px at 8% -10%, rgba(255, 176, 32, 0.16), transparent 62%),
        radial-gradient(820px 460px at 92% -6%, rgba(242, 85, 44, 0.12), transparent 64%),
        radial-gradient(700px 500px at 50% 108%, rgba(255, 122, 61, 0.07), transparent 70%);

    /* Semantic */
    --k-green: #16a36a;
    --k-amber: #d98400;
    --k-red: #e5484d;

    /* Type */
    --k-display: "Inter Tight", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --k-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --k-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Shape */
    --k-radius: 18px;
    --k-radius-sm: 12px;
    --k-radius-xs: 8px;

    /* mdBook globals */
    --sidebar-target-width: 304px;
    --content-max-width: none;
    --menu-bar-height: 56px;
    --page-padding: 24px;
    --mono-font: var(--k-mono);
    --code-font-size: 0.855em;

    /* Readable measure for prose; visual blocks ignore it. */
    --k-prose: 1100px;

    /* Ceiling for wide blocks — tables and diagrams get more room than prose
       without sprawling across an ultrawide display. */
    --k-wide: 1560px;

    /* Rail width for "On this page" */
    --k-toc-width: 244px;
}

/* 2. Theme mapping ======================================================= */

/* Light — `light` and `rust` both render as the light theme. */
html.light,
html.rust {
    --k-ink: #0d0e14;
    --k-ink-2: #2b2d38;
    --k-muted: #6b6f7e;
    --k-faint: #9a9eac;
    --k-line: #e9ebf1;
    --k-line-2: #dfe1e9;
    --k-soft: #f6f7fa;
    --k-soft-2: #eef0f5;
    --k-surface: #ffffff;
    --k-bg: #ffffff;
    --k-glass: rgba(255, 255, 255, 0.82);
    --k-shadow: 0 1px 2px rgba(16, 18, 30, 0.04), 0 8px 24px rgba(16, 18, 30, 0.06);
    --k-shadow-lg: 0 2px 4px rgba(16, 18, 30, 0.04), 0 24px 60px rgba(16, 18, 30, 0.1);
    --k-accent-fg: #1a62d6;
    --k-accent-bg: rgba(26, 98, 214, 0.09);
    --k-brand-fg: #c2410c;
    --k-brand-bg: rgba(255, 122, 61, 0.12);
    --k-green-fg: #0d7a4e;
    --k-green-bg: #e8f8f0;
    --k-amber-fg: #8a5b00;
    --k-amber-bg: #fff6e6;
    --k-slate-fg: #5a6072;
    --k-slate-bg: #f0f2f7;
    --k-sidebar-wash: rgba(255, 176, 32, 0.1);

    /* Code: IntelliJ Light — the counterpart to Darcula. */
    --k-code-bg: #f8f9fc;
    /* Flat on purpose. The card already carries a tinted surface, a border, a
       shadow, a hairline and a language label; a gradient on the one element
       you actually read code in is a fifth signal for no gain — and at a
       legible alpha it is invisible anyway. Set a gradient here to restore it. */
    --k-code-grad: none;
    --k-code-fg: #080808;
    --k-code-head-bg: transparent;
    --k-code-border: #e3e6ee;
    --k-code-rule: #e7e9f0;
    --k-code-label: #9aa0ae;
    --k-code-dot: #d7dae3;
    --k-hl-keyword: #0033b3;
    --k-hl-string: #067d17;
    --k-hl-number: #1750eb;
    --k-hl-comment: #8c8c8c;
    --k-hl-function: #00627a;
    --k-hl-meta: #9e880d;
    --k-hl-field: #871094;
    --k-hl-type: #000000;
    --k-hl-section: #0033b3;

    --bg: var(--k-bg);
    --fg: var(--k-ink-2);
    --sidebar-bg: #fbfbfd;
    --sidebar-fg: var(--k-ink-2);
    --sidebar-non-existant: var(--k-faint);
    --sidebar-active: var(--k-accent-fg);
    --sidebar-spacer: var(--k-line);
    --scrollbar: #c9ccd8;
    --icons: #9096a6;
    --icons-hover: var(--k-ink);
    --links: var(--k-accent-fg);
    --inline-code-color: var(--k-accent-fg);
    --theme-popup-bg: #ffffff;
    --theme-popup-border: var(--k-line-2);
    --theme-hover: var(--k-soft);
    --quote-bg: var(--k-soft);
    --quote-border: var(--k-line);
    --table-border-color: var(--k-line);
    --table-header-bg: var(--k-soft);
    --table-alternate-bg: transparent;
    --searchbar-border-color: var(--k-line-2);
    --searchbar-bg: #ffffff;
    --searchbar-fg: var(--k-ink);
    --searchbar-shadow-color: rgba(255, 122, 61, 0.28);
    --searchresults-header-fg: var(--k-muted);
    --searchresults-border-color: var(--k-line);
    --searchresults-li-bg: var(--k-soft);
    --search-mark-bg: rgba(255, 176, 32, 0.34);
    --overlay-bg: rgba(13, 14, 20, 0.36);
    --footnote-highlight: rgba(255, 122, 61, 0.3);
    --color-scheme: light;
}

/* Dark — `coal`, `navy` and `ayu` all render as the dark theme. */
html.coal,
html.navy,
html.ayu {
    --k-ink: #eceef3;
    --k-ink-2: #c9ccd6;
    --k-muted: #9297a7;
    --k-faint: #6d7283;
    --k-line: #262838;
    --k-line-2: #34374a;
    --k-soft: #161722;
    --k-soft-2: #1d1f2c;
    --k-surface: #12131c;
    --k-bg: #0b0c12;
    --k-glass: rgba(11, 12, 18, 0.8);
    --k-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --k-shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 24px 60px rgba(0, 0, 0, 0.5);
    --k-accent-fg: #8ab4f8;
    --k-accent-bg: rgba(138, 180, 248, 0.14);
    --k-brand-fg: #ffb36b;
    --k-brand-bg: rgba(255, 138, 61, 0.16);
    --k-green-fg: #4fd69a;
    --k-green-bg: #0f2a1f;
    --k-amber-fg: #ffcf70;
    --k-amber-bg: #2a1f0c;
    --k-slate-fg: #a6abba;
    --k-slate-bg: #1d1f2c;
    --k-sidebar-wash: rgba(255, 138, 61, 0.07);

    /* Code: JetBrains Darcula. */
    --k-code-bg: #141622;
    /* Flat on purpose. The card already carries a tinted surface, a border, a
       shadow, a hairline and a language label; a gradient on the one element
       you actually read code in is a fifth signal for no gain — and at a
       legible alpha it is invisible anyway. Set a gradient here to restore it. */
    --k-code-grad: none;
    --k-code-fg: #a9b7c6;
    --k-code-head-bg: transparent;
    --k-code-border: #2a2d3d;
    --k-code-rule: #262838;
    --k-code-label: #7b8094;
    --k-code-dot: #343848;
    --k-hl-keyword: #cc7832;
    --k-hl-string: #6a8759;
    --k-hl-number: #6897bb;
    --k-hl-comment: #808080;
    --k-hl-function: #ffc66d;
    --k-hl-meta: #bbb529;
    --k-hl-field: #9876aa;
    --k-hl-type: #a9b7c6;
    --k-hl-section: #cc7832;

    --bg: var(--k-bg);
    --fg: var(--k-ink-2);
    --sidebar-bg: #0e0f17;
    --sidebar-fg: var(--k-ink-2);
    --sidebar-non-existant: var(--k-faint);
    --sidebar-active: var(--k-accent-fg);
    --sidebar-spacer: var(--k-line);
    --scrollbar: #3a3d50;
    --icons: #6d7283;
    --icons-hover: var(--k-ink);
    --links: var(--k-accent-fg);
    --inline-code-color: var(--k-accent-fg);
    --theme-popup-bg: #12131c;
    --theme-popup-border: var(--k-line-2);
    --theme-hover: var(--k-soft-2);
    --quote-bg: var(--k-soft);
    --quote-border: var(--k-line);
    --table-border-color: var(--k-line);
    --table-header-bg: var(--k-soft);
    --table-alternate-bg: transparent;
    --searchbar-border-color: var(--k-line-2);
    --searchbar-bg: #12131c;
    --searchbar-fg: var(--k-ink);
    --searchbar-shadow-color: rgba(255, 122, 61, 0.4);
    --searchresults-header-fg: var(--k-muted);
    --searchresults-border-color: var(--k-line);
    --searchresults-li-bg: var(--k-soft-2);
    --search-mark-bg: rgba(255, 138, 61, 0.38);
    --overlay-bg: rgba(0, 0, 0, 0.55);
    --footnote-highlight: rgba(255, 179, 107, 0.3);
    --color-scheme: dark;

    /* Dial the ambient wash down in dark mode so it reads as depth, not glow. */
    --k-wash:
        radial-gradient(980px 540px at 8% -10%, rgba(255, 176, 32, 0.1), transparent 62%),
        radial-gradient(820px 460px at 92% -6%, rgba(242, 85, 44, 0.09), transparent 64%),
        radial-gradient(700px 500px at 50% 108%, rgba(255, 122, 61, 0.05), transparent 70%);
}

/* 3. Base layout ========================================================= */

html {
    font-family: var(--k-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--k-body);
    background: var(--k-bg);
    color: var(--k-ink-2);
    font-size: 16px;
    line-height: 1.7;
}

/* The gradient lives on the root so it spans the viewport and stays put while
   the page scrolls; everything above it is transparent. */
html {
    background-color: var(--k-bg);
    background-image: var(--k-wash);
    background-attachment: fixed;
    background-repeat: no-repeat;
}

body,
#body-container,
#page-wrapper.page-wrapper,
.page,
#content.content {
    background: transparent;
}

/* A gradient hairline across the very top, under the sticky bar. */
#menu-bar.menu-bar::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 2px;
    background: var(--k-grad);
    opacity: 0.9;
}

/* Three-column grid: sidebar (mdBook) | prose | On this page.
   Below 1200px the rail drops out and prose takes the full column. */
#content.content {
    padding: 0 clamp(24px, 3.2vw, 64px) 72px;
    /* mdBook sets `overflow: auto` here, which makes #content the scroll
       container and stops the sticky "On this page" rail from ever engaging.
       `clip` prevents a wide child from widening the page without creating a
       scroll container, so sticky keeps working. Wide content keeps its own
       scrollers (.table-wrapper, pre). */
    overflow: visible;
    overflow-x: clip;
}

#content.content main {
    min-width: 0;
    max-width: 820px;
    margin-inline: auto;
    padding-top: 8px;
}

@media (min-width: 1200px) {
    /* The content track is the wide measure, with the rail beside it and the
       pair centred. Prose sits at a readable width inside the track; tables,
       code and diagrams break out into the rest of it. That removes the dead
       zone between text and its own navigation without going back to fat
       margins on both sides. */
    #content.content {
        display: grid;
        grid-template-columns: minmax(0, var(--k-wide)) var(--k-toc-width);
        column-gap: clamp(32px, 3vw, 64px);
        align-items: start;
        max-width: calc(var(--k-wide) + var(--k-toc-width) + 64px);
        margin-inline: auto;
    }

    #content.content main {
        grid-column: 1;
        max-width: none;
        margin-inline: 0;
    }

    /* Hybrid measure.
       Prose caps at a readable line length — past roughly 100 characters the
       eye loses its place tracking back to the next line. Everything visual
       (code, tables, diagrams, cards) takes the full column, so the width is
       used where it helps and withheld where it hurts. */
    #content.content main > p,
    #content.content main > h1,
    #content.content main > h2,
    #content.content main > h3,
    #content.content main > h4,
    #content.content main > h5,
    #content.content main > h6,
    #content.content main > ul,
    #content.content main > ol,
    #content.content main > dl,
    #content.content main > blockquote,
    #content.content main > hr,
    #content.content main > details,
    #content.content main > .footnote-definition {
        max-width: var(--k-prose);
    }

    #content.content main > .k-cards {
        max-width: none;
    }

    /* Three across reads better than four at this measure. */
    #content.content main > .k-cards {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }

    /* Tables and diagrams size to their content between the prose measure and
       the wide ceiling: a three-column table stops where it stops instead of
       stretching its cells across the whole display. */
    #content.content main > .table-wrapper {
        width: fit-content;
        min-width: min(var(--k-prose), 100%);
        max-width: 100%;
    }

    /* The card hugs the drawing rather than framing it in whitespace. */
    #content.content main > .mermaid {
        width: fit-content;
        max-width: 100%;
    }

    /* Code sizes to its content: a one-line command stays at the prose
       measure instead of becoming a wide empty slab, while a long line can
       run out to the full column before it needs to scroll. */
    #content.content main > .k-code {
        width: fit-content;
        min-width: min(var(--k-prose), 100%);
        max-width: 100%;
    }

    /* The hero is a layout of its own; keep its text measured. */
    #content.content main > .k-hero {
        max-width: var(--k-prose);
    }
}

/* 4. Sidebar ============================================================= */

#sidebar.sidebar {
    background-color: var(--sidebar-bg);
    background-image: radial-gradient(620px 420px at 0% 0%, var(--k-sidebar-wash), transparent 68%);
    border-inline-end: 1px solid var(--k-line);
    font-size: 1.4rem;
}

.sidebar .sidebar-scrollbox {
    padding: 0 14px 40px;
}

/* Brand lockup, injected by ui.js */
.k-brand {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 -14px 10px;
    padding: 0 20px;
    height: var(--menu-bar-height);
    background: var(--sidebar-bg);
    border-block-end: 1px solid var(--k-line);
    text-decoration: none;
    font-family: var(--k-display);
    font-weight: 800;
    font-size: 1.792rem;
    letter-spacing: -0.03em;
    color: var(--k-ink);
}

.k-brand:hover {
    text-decoration: none;
}

.k-brand-mark {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--k-grad);
    color: #fff;
    font-size: 1.248rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    box-shadow: 0 2px 10px rgba(242, 85, 44, 0.32);
}

.k-brand-text {
    background: var(--k-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.k-brand-version {
    margin-left: auto;
    font-family: var(--k-body);
    font-size: 1.08rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--k-muted);
    background: var(--k-soft-2);
    border: 1px solid var(--k-line);
    border-radius: 999px;
    padding: 2px 8px;
}

.sidebar .chapter {
    padding: 0;
    line-height: 1.5;
}

.sidebar .chapter li {
    margin: 0;
}

.sidebar .chapter li a {
    display: flex;
    gap: 8px;
    padding: 6px 12px;
    margin: 1px 0;
    border-radius: var(--k-radius-xs);
    color: var(--k-ink-2);
    font-weight: 450;
    transition: background 0.14s ease, color 0.14s ease;
}

.sidebar .chapter li a:hover {
    background: var(--k-soft-2);
    color: var(--k-ink);
    text-decoration: none;
}

.sidebar .chapter li a.active {
    position: relative;
    background: var(--k-brand-bg);
    color: var(--k-brand-fg);
    font-weight: 600;
}

.sidebar .chapter li a.active::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    inset-block: 6px;
    width: 3px;
    border-radius: 999px;
    background: var(--k-grad);
}

/* Chapter numbers are structural noise in a doc site — the section grouping
   already carries the ordering. */
.sidebar .chapter li a strong {
    display: none;
}

/* Section groups — `li.part-title` becomes a collapsible header (ui.js). */
.sidebar .part-title {
    margin: 22px 0 4px;
    padding: 0 12px;
    color: var(--k-faint);
    font-family: var(--k-body);
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.k-section-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 20px 0 2px;
    padding: 6px 12px;
    border: 0;
    border-radius: var(--k-radius-xs);
    background: none;
    color: var(--k-faint);
    font-family: var(--k-body);
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    text-align: start;
    cursor: pointer;
    transition: color 0.14s ease, background 0.14s ease;
}

.k-section-toggle:hover {
    background: var(--k-soft-2);
    color: var(--k-ink-2);
}

.k-section-toggle .k-caret {
    margin-inline-start: auto;
    width: 6px;
    height: 6px;
    border: solid currentColor;
    border-width: 0 1.6px 1.6px 0;
    transform: rotate(45deg) translateY(-1px);
    transition: transform 0.18s ease;
}

.k-section-toggle[aria-expanded="false"] .k-caret {
    transform: rotate(-45deg) translateX(-1px);
}

/* mdBook styles `.chapter li` as a flex row; a section is a stack. */
.sidebar .chapter li.k-section {
    display: block;
}

.sidebar .chapter .k-section-items {
    display: block;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: hidden;
}

/* Must out-specify the rule above, or the `hidden` attribute does nothing. */
.sidebar .chapter .k-section-items[hidden] {
    display: none;
}

.k-section-items[hidden] {
    display: none;
}

/* A collapsed section that contains the current page keeps a hint of accent. */
.k-section-toggle.has-current {
    color: var(--k-accent-fg);
}

/* 5. Top bar ============================================================= */

#menu-bar.menu-bar {
    background: var(--k-glass);
    border-block-end: 1px solid transparent;
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#menu-bar.menu-bar.k-scrolled {
    border-block-end-color: var(--k-line);
    box-shadow: 0 1px 12px rgba(16, 18, 30, 0.05);
}

#menu-bar .menu-title {
    font-family: var(--k-display);
    font-weight: 700;
    font-size: 1.52rem;
    letter-spacing: -0.015em;
    color: var(--k-muted);
    opacity: 1;
}

#menu-bar .icon-button {
    border-radius: var(--k-radius-xs);
    color: var(--icons);
    transition: background 0.14s ease, color 0.14s ease;
}

#menu-bar .icon-button:hover {
    background: var(--k-soft-2);
    color: var(--k-ink);
}

.theme-popup {
    border-radius: var(--k-radius-sm);
    border-color: var(--theme-popup-border);
    box-shadow: var(--k-shadow);
    overflow: hidden;
    padding: 6px;
}

.theme-popup .theme {
    border-radius: var(--k-radius-xs);
    font-family: var(--k-body);
    font-size: 1.4rem;
    padding: 7px 12px;
}

/* Search */
#searchbar {
    border-radius: var(--k-radius-sm);
    border: 1px solid var(--searchbar-border-color);
    background: var(--searchbar-bg);
    font-family: var(--k-body);
    font-size: 1.52rem;
    padding: 11px 14px;
    box-shadow: var(--k-shadow);
}

#searchbar:focus {
    outline: none;
    border-color: var(--k-c2);
    box-shadow: 0 0 0 3px var(--searchbar-shadow-color);
}

#searchresults {
    border-radius: var(--k-radius-sm);
}

#searchresults li {
    border-radius: var(--k-radius-xs);
    padding: 10px 12px;
}

/* 6. Headings and prose ================================================== */

.content h1,
.content h2,
.content h3,
.content h4,
.content h5 {
    font-family: var(--k-display);
    color: var(--k-ink);
    letter-spacing: -0.022em;
    line-height: 1.2;
}

.content h1 {
    margin: 12px 0 18px;
    font-size: clamp(3.36rem, 4.4vw, 4.64rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    background: var(--k-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    /* Gradient text paints only inside the box — extend it so descenders
       are not clipped. */
    padding-block-end: 0.12em;
    margin-block-end: calc(18px - 0.12em);
}

.content h2 {
    margin-block: 4.8rem 1.76rem;
    padding-block-end: 0.72rem;
    font-size: 2.48rem;
    font-weight: 700;
    border-block-end: 1px solid var(--k-line);
}

.content h3 {
    margin-block: 3.36rem 1.28rem;
    font-size: 1.92rem;
    font-weight: 700;
}

.content h4 {
    margin-block: 2.56rem 0.96rem;
    font-size: 1.632rem;
    font-weight: 600;
}

.content h1 + h2,
.content h2 + h3 {
    margin-block-start: 2.24rem;
}

/* mdBook wraps every heading in <a class="header"> and colours it, which
   paints over the h1's clipped gradient. Make the anchor's own text
   transparent so the parent's background shows through the glyphs. */
.content h1 a.header {
    color: transparent;
    -webkit-text-fill-color: transparent;
}

/* The hover anchor glyph still needs a colour of its own. */
.content .header:hover::after {
    color: var(--k-faint);
    -webkit-text-fill-color: var(--k-faint);
}

.content p,
.content li {
    color: var(--k-ink-2);
}

.content p {
    margin-block: 0 1.68rem;
}

.content ul,
.content ol {
    padding-inline-start: 2.16rem;
}

.content li {
    margin-block: 0.48rem;
}

.content li::marker {
    color: var(--k-faint);
}

.content a {
    color: var(--k-accent-fg);
    text-decoration-color: color-mix(in srgb, var(--k-accent-fg) 32%, transparent);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 2.5px;
    transition: color 0.14s ease, text-decoration-color 0.14s ease;
}

.content a:hover {
    text-decoration-color: var(--k-accent-fg);
}

.content strong {
    color: var(--k-ink);
    font-weight: 650;
}

.content hr {
    height: 1px;
    border: 0;
    margin-block: 4.16rem;
    background: var(--k-line);
}

.content img {
    max-width: 100%;
    border-radius: var(--k-radius-sm);
}

/* 7. Code ================================================================ */

/* Inline code is brand-coloured, never link-coloured: blue means clickable on
   this site, and an unlinked `code` span rendered in blue reads as a link that
   does nothing. Code inside a link is restored to blue below. */
.content :not(pre) > code {
    font-family: var(--k-mono);
    font-size: 0.855em;
    font-weight: 500;
    color: var(--k-brand-fg);
    background: var(--k-brand-bg);
    border-radius: 5px;
    /* Keep the horizontal padding small: a wide inline box reads as a gap
       before the following comma or period. */
    padding: 0.1em 0.28em;
    white-space: nowrap;
}

/* A code span that *is* a link keeps the link colour, so clickability stays
   readable either way. */
.content a code,
.content a:hover code {
    color: var(--k-accent-fg);
    background: var(--k-accent-bg);
}

.content h1 :not(pre) > code,
.content h2 :not(pre) > code,
.content h3 :not(pre) > code {
    font-size: 0.9em;
    background: none;
    padding: 0;
    color: inherit;
}

/* Block code: dark in both themes, inside a bordered card with a chrome bar
   carrying the language label (added by ui.js). */
.k-code {
    position: relative;
    max-width: 100%;
    margin-block: 2.24rem;
    border-radius: var(--k-radius-sm);
    border: 1px solid var(--k-code-border);
    background-color: var(--k-code-bg);
    background-image: var(--k-code-grad);
    box-shadow: var(--k-shadow);
    overflow: hidden;
}

.k-code-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px 7px;
    background: var(--k-code-head-bg);
    border-block-end: 1px solid var(--k-code-rule);
}

.k-code-dots {
    display: inline-flex;
    gap: 5px;
}

.k-code-dots i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--k-code-dot);
}

.k-code-lang {
    margin-inline-start: auto;
    font-family: var(--k-mono);
    font-size: 1.056rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--k-code-label);
}

.content pre {
    margin: 0;
    padding: 16px 18px;
    background: transparent;
    border-radius: 0;
    overflow-x: auto;
}

.k-code .content pre,
.k-code pre {
    background: transparent;
}

.content pre > code {
    font-family: var(--k-mono);
    font-size: 0.855em;
    line-height: 1.65;
    background: transparent;
    color: var(--k-code-fg);
}

.content pre code.hljs {
    background: transparent;
    padding: 0;
}

/* Copy button sits in the chrome bar. */
.k-code .buttons {
    top: 7px;
    inset-inline-end: 56px;
}

.k-code .clip-button,
.content pre > .buttons .clip-button {
    color: var(--k-code-label);
}

/* Syntax tokens — JetBrains Darcula in dark, IntelliJ Light in light. The
   values live in the theme blocks above, so switching theme switches the
   editor palette with it. */
.content pre code.hljs {
    color: var(--k-code-fg);
}

.hljs-keyword,
.hljs-literal,
.hljs-selector-tag,
.hljs-built_in,
.hljs-operator {
    color: var(--k-hl-keyword);
}

.hljs-string,
.hljs-addition,
.hljs-regexp,
.hljs-char.escape_ {
    color: var(--k-hl-string);
}

.hljs-number,
.hljs-symbol,
.hljs-bullet,
.hljs-link {
    color: var(--k-hl-number);
}

.hljs-comment,
.hljs-quote {
    color: var(--k-hl-comment);
}

.hljs-doctag {
    color: var(--k-hl-comment);
    font-weight: 600;
}

.hljs-title,
.hljs-title.function_,
.hljs-title.class_,
.hljs-function .hljs-title,
.hljs-name {
    color: var(--k-hl-function);
}

.hljs-meta,
.hljs-meta .hljs-keyword {
    color: var(--k-hl-meta);
}

.hljs-variable,
.hljs-template-variable,
.hljs-params .hljs-variable {
    color: var(--k-hl-field);
}

.hljs-type,
.hljs-class .hljs-title,
.hljs-tag,
.hljs-attr,
.hljs-attribute,
.hljs-property,
.hljs-params,
.hljs-punctuation {
    color: var(--k-hl-type);
}

.hljs-section,
.hljs-selector-id,
.hljs-selector-class {
    color: var(--k-hl-section);
}

.hljs-deletion {
    color: #c75450;
}

.hljs-emphasis {
    font-style: italic;
}

.hljs-strong {
    font-weight: 600;
}

/* 8. Tables ============================================================== */

.content .table-wrapper {
    overflow-x: auto;
    margin-block: 2.24rem;
    border: 1px solid var(--k-line);
    border-radius: var(--k-radius-sm);
    background: var(--k-surface);
    box-shadow: var(--k-shadow);
}

.content table {
    display: table;
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    border: 0;
    font-size: 1.48rem;
}

.content table thead th {
    background: var(--k-soft);
    border: 0;
    border-block-end: 1px solid var(--k-line);
    padding: 11px 16px;
    color: var(--k-muted);
    font-family: var(--k-body);
    font-size: 1.12rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    text-align: start;
    white-space: nowrap;
}

.content table td {
    border: 0;
    border-block-end: 1px solid var(--k-line);
    padding: 11px 16px;
    vertical-align: top;
}

.content table tbody tr:last-child td {
    border-block-end: 0;
}

.content table tbody tr {
    background: transparent;
}

.content table tbody tr:hover {
    background: var(--k-soft);
}

.content table td:first-child code {
    white-space: nowrap;
}

/* 9. Status callouts and pills =========================================== */

/* Plain blockquote */
.content blockquote {
    margin-block: 2.24rem;
    padding: 14px 18px;
    border: 1px solid var(--k-line);
    border-inline-start: 3px solid var(--k-c2);
    border-radius: var(--k-radius-sm);
    background: var(--k-soft);
    color: var(--k-ink-2);
}

.content blockquote > :last-child {
    margin-block-end: 0;
}

/* Status callout — ui.js tags these from the leading "Status:" text. */
.content blockquote.k-status {
    position: relative;
    border: 1px solid var(--k-line);
    border-inline-start-width: 1px;
    background: var(--k-surface);
    box-shadow: var(--k-shadow);
    padding: 16px 18px 16px 20px;
    overflow: hidden;
    font-size: 1.512rem;
}

/* 3px accent bar across the top, per status. */
.content blockquote.k-status::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: var(--k-grad);
}

.content blockquote.k-status.is-done::before {
    background: linear-gradient(90deg, #16a36a, #5bd99a);
}

.content blockquote.k-status.is-partial::before {
    background: linear-gradient(90deg, #e8930c, #ffc861);
}

.content blockquote.k-status.is-planned::before {
    background: linear-gradient(90deg, #6b7280, #9aa0b0);
}

/* Status pill, replacing the bare emoji. */
.k-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 999px;
    padding: 2px 9px;
    font-family: var(--k-body);
    font-size: 1.152rem;
    font-weight: 650;
    letter-spacing: 0.01em;
    line-height: 1.5;
    white-space: nowrap;
    vertical-align: 0.06em;
}

.k-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.k-pill.is-done {
    color: var(--k-green-fg);
    background: var(--k-green-bg);
}

.k-pill.is-partial {
    color: var(--k-amber-fg);
    background: var(--k-amber-bg);
}

.k-pill.is-planned {
    color: var(--k-slate-fg);
    background: var(--k-slate-bg);
}

/* In tables the pill is the whole cell — keep it tight. */
.content table .k-pill {
    font-size: 1.12rem;
}

/* 10. On this page ======================================================= */

.k-toc {
    display: none;
}

@media (min-width: 1200px) {
    .k-toc {
        display: block;
        grid-column: 2;
        grid-row: 1;
        position: sticky;
        top: calc(var(--menu-bar-height) + 28px);
        align-self: start;
        max-height: calc(100vh - var(--menu-bar-height) - 56px);
        overflow-y: auto;
        padding-block: 8px 24px;
        font-size: 1.352rem;
        line-height: 1.45;
        scrollbar-width: thin;
    }
}

.k-toc.is-dense ul {
    font-size: 0.95em;
}

.k-toc.is-dense a {
    padding-block: 3px;
}

.k-toc-title {
    margin: 0 0 10px;
    padding-inline-start: 13px;
    color: var(--k-faint);
    font-family: var(--k-body);
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.k-toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
    border-inline-start: 1px solid var(--k-line);
}

.k-toc li {
    margin: 0;
}

.k-toc a {
    display: block;
    padding: 5px 0 5px 13px;
    margin-inline-start: -1px;
    border-inline-start: 2px solid transparent;
    color: var(--k-muted);
    font-weight: 450;
    text-decoration: none;
    transition: color 0.14s ease, border-color 0.14s ease;
}

.k-toc a:hover {
    color: var(--k-ink);
    text-decoration: none;
}

.k-toc .k-toc-h3 a {
    padding-inline-start: 26px;
    font-size: 0.94em;
}

.k-toc a.is-active {
    color: var(--k-brand-fg);
    border-inline-start-color: var(--k-c2);
    font-weight: 600;
}

/* 11. Page nav, hero, misc =============================================== */

/* Prev / next navigation is hidden: the sidebar and the "On this page" rail
   already cover navigation, and the floating pair at the end of every page was
   noise. mdBook has no switch for it, so it goes here. */
.nav-wrapper,
.mobile-nav-chapters,
.nav-chapters {
    display: none !important;
}

/* Hero — used on the landing page only. */
.k-hero {
    position: relative;
    margin-block: 8px 4.4rem;
}

/* Soft glow behind the hero, so the gradient reads as light in the page
   rather than paint on a few components. */
.k-hero::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: -80px -120px auto -140px;
    height: 420px;
    background: radial-gradient(620px 300px at 20% 30%, var(--k-brand-bg), transparent 70%);
    pointer-events: none;
}

.k-hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-block-end: 18px;
    padding: 4px 12px 4px 10px;
    border: 1px solid var(--k-line);
    border-radius: 999px;
    background: var(--k-surface);
    box-shadow: var(--k-shadow);
    color: var(--k-muted);
    font-size: 1.24rem;
    font-weight: 600;
}

.k-hero-eyebrow b {
    color: var(--k-brand-fg);
    font-weight: 700;
}

.k-hero h1,
.content .k-hero h1 {
    margin: 0;
    font-size: clamp(4.16rem, 6vw, 6.08rem);
    font-weight: 800;
    letter-spacing: -0.034em;
    line-height: 1.02;
}

.k-hero-lede {
    margin: 22px 0 0;
    /* Wide enough to read as a subtitle rather than a narrow block of body
       text stacked under a very large word. */
    max-width: 64ch;
    font-size: clamp(1.9rem, 1.6vw, 2.24rem);
    font-weight: 400;
    line-height: 1.55;
    letter-spacing: -0.004em;
    color: var(--k-muted);
    text-wrap: pretty;
}

/* A tinted code chip mid-sentence is noise at subtitle size. */
.content .k-hero-lede code,
.content .k-hero-lede :not(pre) > code {
    background: none;
    padding: 0;
    font-size: 0.93em;
    font-weight: 500;
    color: var(--k-ink-2);
}

.k-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-block-start: 26px;
}

.k-btn,
.content a.k-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-family: var(--k-display);
    font-weight: 700;
    font-size: 1.512rem;
    letter-spacing: -0.012em;
    text-decoration: none;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.k-btn-primary,
.content a.k-btn-primary {
    background: var(--k-grad);
    color: #fff;
    box-shadow: 0 2px 14px rgba(242, 85, 44, 0.32);
}

.k-btn-primary:hover,
.content a.k-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(242, 85, 44, 0.42);
    text-decoration: none;
}

.k-btn-ghost,
.content a.k-btn-ghost {
    background: var(--k-surface);
    border-color: var(--k-line-2);
    color: var(--k-ink);
}

.k-btn-ghost:hover,
.content a.k-btn-ghost:hover {
    border-color: color-mix(in srgb, var(--k-c2) 45%, var(--k-line-2));
    box-shadow: var(--k-shadow);
    text-decoration: none;
}

/* Feature cards */
.k-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
    margin-block: 2.8rem;
}

.k-card {
    position: relative;
    display: block;
    padding: 20px;
    border: 1px solid var(--k-line);
    border-radius: var(--k-radius);
    background: var(--k-surface);
    box-shadow: var(--k-shadow);
    overflow: hidden;
    text-decoration: none;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

a.k-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--k-c2) 40%, var(--k-line));
    box-shadow: var(--k-shadow-lg);
    text-decoration: none;
}

.k-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: var(--k-grad);
    opacity: 0.45;
    transition: opacity 0.16s ease;
}

a.k-card:hover::before {
    opacity: 1;
}

.k-card-title,
.content .k-card-title {
    display: block;
    margin: 0 0 6px;
    font-size: 1.632rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--k-ink);
}

.k-card p,
.content .k-card p {
    margin: 0;
    font-size: 1.44rem;
    line-height: 1.55;
    color: var(--k-muted);
}

.k-card-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin-block-end: 12px;
    border-radius: 9px;
    background: var(--k-grad-soft);
    border: 1px solid var(--k-line);
    font-size: 1.52rem;
}

/* Mermaid */
.mermaid {
    display: flex;
    justify-content: center;
    margin-block: 2.8rem;
    padding: 20px 16px;
    border: 1px solid var(--k-line);
    border-radius: var(--k-radius-sm);
    background: var(--k-surface);
    overflow-x: auto;
}

.mermaid > svg {
    max-width: 100%;
    height: auto;
}

/* Footnotes, keyboard hints, scrollbars */
.footnote-definition {
    font-size: 1.44rem;
    color: var(--k-muted);
}

::selection {
    background: rgba(255, 122, 61, 0.26);
}

.sidebar-scrollbox::-webkit-scrollbar,
.k-toc::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scrollbox::-webkit-scrollbar-thumb,
.k-toc::-webkit-scrollbar-thumb {
    background: var(--scrollbar);
    border-radius: 999px;
}

/* Mobile */
@media (max-width: 760px) {
    body {
        font-size: 15.5px;
    }

    #content.content {
        padding-inline: 18px;
    }

    .content h1 {
        font-size: 3.2rem;
    }

    .content h2 {
        margin-block-start: 3.6rem;
    }

    .content :not(pre) > code {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

@media print {
    #sidebar.sidebar,
    .k-toc,
    #menu-bar.menu-bar,
    .nav-wrapper {
        display: none;
    }

    .content h1 {
        -webkit-text-fill-color: #0d0e14;
        color: #0d0e14;
    }

    .k-code {
        border-color: #ddd;
        background: #fff;
    }

    .content pre > code {
        color: #111;
    }
}

/* 12. Pieces ui.js injects ============================================== */

.k-brand-mark svg {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
}

/* The mark carries its own gradient, so drop the tile background. */
.k-brand .k-brand-mark {
    background: none;
    box-shadow: 0 2px 10px rgba(242, 85, 44, 0.3);
    overflow: hidden;
}

/* Status dot — replaces a bare emoji inside prose. */
.k-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-inline-end: 2px;
    vertical-align: 0.07em;
    box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 18%, transparent);
}

.k-dot.is-done {
    background: var(--k-green);
    color: var(--k-green);
}

.k-dot.is-partial {
    background: #f0a73c;
    color: #f0a73c;
}

.k-dot.is-planned {
    background: var(--k-faint);
    color: var(--k-faint);
}

.k-status-cell {
    white-space: nowrap;
}

/* Status callout: the leading "Status:" label reads as a label, not prose. */
.content blockquote.k-status > p:first-child > strong:first-child {
    display: inline-block;
    margin-inline-end: 4px;
    color: var(--k-muted);
    font-family: var(--k-body);
    font-size: 1.152rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    vertical-align: 0.08em;
}

/* Hero logo */
.k-hero-logo {
    display: block;
    width: 56px;
    height: 56px;
    margin-block-end: 18px;
    border-radius: 14px;
    box-shadow: 0 6px 24px rgba(255, 122, 61, 0.28);
}

/* The hero's h1 comes from markdown, so re-tighten it here. */
.content .k-hero > h1 {
    margin-block: 0 0;
}
