:root {
    --ink: #17201f;
    --muted: #687270;
    --gradient-start: #c5c7c3;
    --gradient-end: #71928b;
    --surface: #ffffff;
    --line: #dce4df;
    --brand: #397d7a;
    --brand-dark: #205a58;
    --brand-pale: #e7f1ef;
    --accent: #da7b35;
    --code: #172321;
    --header-height: 86px;
    color-scheme: light;
}

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

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: linear-gradient(
        to bottom right,
        var(--gradient-start) 0%,
        var(--gradient-end) 100%
    );
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
    line-height: 1.8;
}

a {
    color: var(--brand-dark);
}

.site-header {
    position: sticky;
    z-index: 20;
    top: 0;
    height: var(--header-height);
    border-bottom: 1px solid rgb(255 255 255 / 24%);
    background: rgba(40, 156, 71, 0.96);
    box-shadow: 0 6px 24px rgb(22 47 46 / 12%);
    backdrop-filter: blur(12px);
}

.top-nav {
    display: flex;
    align-items: center;
    width: min(1400px, 100%);
    height: 100%;
    margin: 0 auto;
    padding: 0 32px;
}

.site-logo {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 66px;
    height: 66px;
    border-radius: 18px;
    transition: background-color 160ms ease, transform 160ms ease;
}

.site-logo:hover,
.site-logo:focus-visible {
    background: rgb(255 255 255 / 12%);
    transform: translateY(-1px);
}

.site-logo img {
    display: block;
    max-width: 100%;
    object-fit: contain;
}

.top-nav__links {
    display: flex;
    align-self: stretch;
    gap: 8px;
    margin-left: 30px;
}

.top-nav__links a {
    position: relative;
    display: grid;
    place-items: center;
    padding: 0 22px;
    color: rgb(255 255 255 / 78%);
    font-size: 0.98rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-decoration: none;
    transition: color 160ms ease, background-color 160ms ease;
}

.top-nav__links a::after {
    position: absolute;
    right: 20px;
    bottom: 0;
    left: 20px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--accent);
    content: "";
    opacity: 0;
    transform: scaleX(0.35);
    transition: opacity 160ms ease, transform 160ms ease;
}

.top-nav__links a:hover,
.top-nav__links a:focus-visible,
.top-nav__links a.is-current {
    color: #fff;
    background: rgb(255 255 255 / 8%);
}

.top-nav__links a.is-current::after {
    opacity: 1;
    transform: scaleX(1);
}

.page-layout {
    display: grid;
    grid-template-columns: minmax(210px, 260px) minmax(0, 880px);
    gap: clamp(32px, 5vw, 80px);
    width: min(1240px, calc(100% - 64px));
    margin: 0 auto;
    padding: 54px 0 96px;
}

.toc {
    position: sticky;
    top: calc(var(--header-height) + 34px);
    align-self: start;
}

.toc__body {
    padding: 8px 0 8px 22px;
    border-left: 1px solid var(--line);
}

.toc__title {
    margin: 0 0 15px;
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.13em;
}

.toc__links {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.toc__links a {
    display: block;
    padding: 7px 11px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.5;
    text-decoration: none;
    transition: color 150ms ease, background-color 150ms ease;
}

.toc__links .toc__subitem a {
    padding-left: 24px;
    font-size: 0.82rem;
}

.toc__links a:hover,
.toc__links a:focus-visible {
    color: var(--brand-dark);
    background: var(--brand-pale);
}

.toc__links a.is-active {
    color: var(--brand-dark);
    background: var(--brand-pale);
    font-weight: 700;
}

.toc__toggle {
    display: none;
}

.article {
    min-width: 0;
    padding: clamp(28px, 5vw, 62px);
    border: 1px solid rgb(220 228 223 / 85%);
    border-radius: 18px;
    background: rgb(255 255 255 / 94%);
    box-shadow: 0 20px 55px rgb(33 66 63 / 8%);
}

.article__header {
    margin-bottom: 56px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--line);
}

.article__label {
    margin: 0 0 10px;
    color: var(--accent);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.16em;
}

.article h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3.35rem);
    line-height: 1.25;
    letter-spacing: -0.035em;
}

.article__lead {
    max-width: 650px;
    margin: 20px 0 0;
    color: var(--muted);
    font-size: 1.05rem;
}

.article section + section {
    margin-top: 58px;
}

.article h2,
.article h3 {
    scroll-margin-top: calc(var(--header-height) + 28px);
    line-height: 1.4;
}

.article h2 {
    margin: 0 0 20px;
    padding-bottom: 11px;
    border-bottom: 1px solid var(--line);
    font-size: clamp(1.45rem, 3vw, 1.85rem);
}

.article h2::before {
    display: inline-block;
    width: 8px;
    height: 0.9em;
    margin-right: 12px;
    border-radius: 2px;
    background: var(--brand);
    content: "";
}

.article h3 {
    margin: 36px 0 14px;
    font-size: 1.25rem;
}

.article p {
    margin: 0 0 1.25em;
}

.article img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.article pre {
    overflow-x: auto;
    margin: 0;
    padding: 54px 24px 22px;
    border: 1px solid rgb(255 255 255 / 8%);
    border-radius: 10px;
    color: #e7f0ed;
    background: var(--code);
    box-shadow: inset 4px 0 var(--accent);
    line-height: 1.7;
}

.code-block {
    position: relative;
    margin: 26px 0;
}

.code-copy-button {
    position: absolute;
    z-index: 1;
    top: 12px;
    right: 12px;
    min-width: 82px;
    padding: 5px 11px;
    border: 1px solid rgb(231 240 237 / 42%);
    border-radius: 6px;
    color: #e7f0ed;
    background: rgb(255 255 255 / 8%);
    font: inherit;
    font-size: 0.75rem;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 150ms ease, background-color 150ms ease;
}

.code-copy-button:hover,
.code-copy-button:focus-visible {
    border-color: rgb(231 240 237 / 75%);
    background: rgb(255 255 255 / 15%);
}

.code-copy-button.is-copied {
    border-color: #87d5a7;
    color: #a9ebc3;
}

.article code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.9em;
}

@media (max-width: 780px) {
    :root {
        --header-height: 72px;
    }

    .top-nav {
        padding: 0 18px;
    }

    .site-logo {
        width: 54px;
        height: 54px;
    }

    .site-logo img {
        width: 50px;
        height: 50px;
    }

    .top-nav__links {
        gap: 0;
        margin-left: 12px;
    }

    .top-nav__links a {
        padding: 0 11px;
        font-size: 0.82rem;
        letter-spacing: 0;
        text-align: center;
    }

    .top-nav__links a::after {
        right: 10px;
        left: 10px;
    }

    .page-layout {
        display: block;
        width: min(100% - 28px, 720px);
        padding: 24px 0 60px;
    }

    .toc {
        position: static;
        margin-bottom: 16px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: var(--surface);
    }

    .toc__toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 14px 17px;
        border: 0;
        color: var(--ink);
        background: transparent;
        font: inherit;
        font-size: 0.86rem;
        font-weight: 700;
        cursor: pointer;
    }

    .toc__toggle-icon {
        width: 9px;
        height: 9px;
        border-right: 2px solid var(--brand);
        border-bottom: 2px solid var(--brand);
        transform: rotate(45deg) translate(-2px, 2px);
        transition: transform 160ms ease;
    }

    .toc__toggle[aria-expanded="true"] .toc__toggle-icon {
        transform: rotate(225deg) translate(-1px, -1px);
    }

    .toc__body {
        position: static;
        display: none;
        padding: 0 10px 12px;
        border: 0;
    }

    .toc__body.is-open {
        display: block;
    }

    .toc__title {
        display: none;
    }

    .article {
        padding: 30px 22px 40px;
        border-radius: 12px;
    }

    .article__header {
        margin-bottom: 42px;
    }
}

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

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
}
