:root {
    --accent: 332 100% 50%;
    --bg: 35 60% 98%;
    --fg: 20 35% 16%;
    --muted: 20 18% 42%;
    --card: 0 0% 100%;
    --ring: 332 80% 45%;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: 24 22% 10%;
        --fg: 30 30% 92%;
        --muted: 24 12% 70%;
        --card: 24 18% 14%;
    }
}

* {
    box-sizing: border-box
}

html {
    scroll-behavior: smooth
}

body {
    margin: 0;
    font: 16px/1.55 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    background:
        radial-gradient(1200px 600px at 60% -20%, hsl(332 100% 97% / .45), transparent 60%),
        linear-gradient(180deg, hsl(var(--bg)) 0%, hsl(35 60% 97%) 100%);
    color: hsl(var(--fg));
}

a {
    color: hsl(216 100% 45%);
    text-decoration: none
}

a:visited {
    color: hsl(216 90% 38%);
}

a:hover {
    text-decoration: underline
}

.wrap {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 28px;
    max-width: 1200px;
    padding: 24px;
    margin-inline: auto
}

header.site {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0 8px
}

header.site img.avatar {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 6px 20px hsl(var(--fg)/.15);
    outline: 3px solid hsl(var(--accent) / .25);
}

header.site .title {
    font-weight: 700;
    font-size: clamp(22px, 2.4vw, 32px)
}

header.site .subtitle {
    color: hsl(var(--muted));
    font-size: 14px
}

nav.toc {
    position: sticky;
    top: 16px;
    align-self: start;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--fg)/.08);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 6px 24px hsl(var(--fg)/.06)
}

nav.toc h2 {
    font-size: 14px;
    margin: 0 0 8px;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: hsl(var(--muted))
}

nav.toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 70vh;
    overflow: auto;
    counter-reset: toc;
}

nav.toc li {
    list-style: none;
}

nav.toc a {
    display: block;
    padding: 8px 10px 8px 20px;
    border-radius: 10px;
    color: hsl(var(--fg));
    position: relative;
}

nav.toc a:visited {
    color: hsl(var(--fg));
}

nav.toc a::before { content: none; }

nav.toc a:hover {
    background: hsl(var(--fg)/.06);
    text-decoration: none;
}

nav.toc a.active {
    background: hsl(var(--fg)/.08);
    box-shadow: inset 3px 0 0 0 hsl(var(--fg)/.35);
}

nav.toc a.active::before { content: none; }


main {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--fg)/.08);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 28px hsl(var(--fg)/.06);
    max-width: calc(72ch + 48px);
    margin-inline: 0;
    justify-self: start;
}

main h1 {
    font-size: clamp(28px, 3vw, 40px);
    margin-top: 0
}

main h2 {
    margin-top: 2.2em;
    border-top: 1px solid hsl(var(--fg)/.08);
    padding-top: 1.2em
}

main h3 {
    margin-top: 1.6em
}

details {
    background: hsl(var(--fg)/.04);
    padding: 12px 14px;
    border-radius: 12px
}

summary {
    cursor: pointer;
    user-select: none;
}

.quick {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0 6px
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid hsl(var(--accent)/.28);
    background: hsl(332 100% 98% / .65);
    color: hsl(332 40% 28%);
    font-size: 14px;
    transition: background .2s ease, transform .06s ease;
}

.chip:visited {
    color: hsl(332 40% 28%);
}

.chip:hover {
    background: hsl(var(--accent)/.18);
    text-decoration: none
}

.chip:active {
    transform: translateY(1px)
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid hsl(var(--fg)/.12);
    background: hsl(var(--bg));
    text-decoration: none;
    font-weight: 600;
    color: hsl(var(--fg));
}

.btn:visited {
    color: hsl(var(--fg));
}

.btn.primary {
    background: hsl(var(--accent));
    color: white;
    border: none;
    box-shadow: 0 8px 24px hsl(var(--accent)/.35);
}

.btn.ghost {
    background: transparent
}

.kbd {
    font: 12px/1.3 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    background: hsl(var(--fg)/.08);
    padding: .2em .5em;
    border-radius: 6px
}

.emergency {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 50
}

.emergency a {
    box-shadow: 0 10px 32px hsl(var(--ring)/.4)
}

footer {
    grid-column: 1/-1;
    color: hsl(var(--muted));
    font-size: 13px;
    padding: 12px 0 30px
}

/* Rendered Markdown defaults */
.content {
    max-width: 72ch;
    margin-inline: auto;
}

.content img {
    max-width: 100%;
    border-radius: 12px
}

.content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0
}

.content th,
.content td {
    border: 1px solid hsl(var(--fg)/.15);
    padding: 8px;
    text-align: left
}

/* Small screens */
@media (max-width: 880px) {
    .wrap {
        grid-template-columns: 1fr;
    }

    nav.toc {
        position: fixed;
        top: 6px;
        right: 8px;
        z-index: 60;
        padding: 6px 8px;
        width: auto;
        max-width: 90vw;
    }

    nav.toc h2 {
        margin: 0;
        display: flex;
        align-items: center;
        gap: 8px;
        cursor: pointer;
    }

    nav.toc h2::after {
        content: "▾";
        font-size: 14px;
        line-height: 1;
        opacity: .7;
    }

    nav.toc ul {
        display: none;
        margin-top: 6px;
        max-height: 60vh;
    }

    nav.toc.open ul {
        display: flex;
    }

    main {
        margin-top: 16px;
        margin-inline: 12px;
        max-width: 100%;
    }
}

@media print {

    nav.toc,
    .emergency,
    .subtitle,
    .btn,
    .chip {
        display: none !important
    }

    body {
        background: white
    }

    main {
        box-shadow: none;
        border: none;
        padding: 0
    }

    a {
        text-decoration: none;
        color: black
    }

    h2 {
        break-after: avoid
    }
}