:root {
    --light: #faf9f5;
    --lightgray: #e8e6dc;
    --gray: #87867f;
    --darkgray: #30302e;
    --dark: #141413;
    --secondary: #c96442;
    --tertiary: #d97757;
    --highlight: color-mix(in srgb, var(--secondary) 9%, transparent);
    --text-highlight: color-mix(in srgb, var(--secondary) 16%, transparent);
    --radius-sm: .375rem;
    --radius-md: .5rem;
    --radius-lg: .75rem;
    --radius-pill: 999px;
    --shadow-soft: 0 4px 14px #1414130a;
    --shadow-float: 0 6px 24px #1414130f, 0 0 0 1px #14141305;
    --title-font: "LXGW WenKai Mono TC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
    --body-font: "LXGW WenKai Mono TC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
    --code-font: "LXGW WenKai Mono TC", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
    --light: #141413;
    --lightgray: #3d3d3a;
    --gray: #73726c;
    --darkgray: #dedcd1;
    --dark: #faf9f5;
    --tertiary: #f09a7d;
    --highlight: color-mix(in srgb, var(--secondary) 22%, transparent);
    --text-highlight: color-mix(in srgb, var(--secondary) 32%, transparent);
    --shadow-soft: 0 4px 14px #00000040;
    --shadow-float: 0 6px 24px #00000059, 0 0 0 1px #faf9f50a;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    margin: 0;
    background: var(--light);
    color: var(--darkgray);
    font: 16px/1.7 var(--body-font);
    letter-spacing: 0;
}

body.nav-open,
body.search-open {
    overflow: hidden;
}

a {
    color: var(--secondary);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--secondary) 35%, transparent);
    text-underline-offset: 3px;
    transition: color .16s ease, text-decoration-color .16s ease, background .16s ease;
}

a:hover {
    color: var(--tertiary);
    text-decoration-color: currentColor;
}

button,
input,
textarea {
    font: inherit;
}

button,
a {
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--secondary) 50%, transparent);
    outline-offset: 3px;
}

img,
video {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
}

::selection {
    background: color-mix(in srgb, var(--secondary) 45%, transparent);
}

.skip-link,
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.skip-link:focus {
    z-index: 1000;
    top: 1rem;
    left: 1rem;
    width: auto;
    height: auto;
    clip: auto;
    padding: .55rem .8rem;
    border-radius: var(--radius-md);
    background: var(--dark);
    color: var(--light);
}

.page {
    max-width: 1500px;
    margin: 0 auto;
}

.navigation-progress {
    position: fixed;
    z-index: 1200;
    top: 0;
    left: 0;
    width: 0;
    height: 2px;
    opacity: 0;
    background: var(--secondary);
    transition: width .28s ease, opacity .18s ease;
}

.navigation-progress.is-active {
    opacity: 1;
}

.mobile-bar,
.nav-scrim {
    display: none;
}

.layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 280px;
    gap: 5px 2rem;
    align-items: start;
}

.is-home .layout {
    grid-template-columns: 280px minmax(0, 1fr);
}

.is-home .center,
.is-home .site-footer {
    margin-right: auto;
    margin-left: auto;
    transform: translateX(calc((-280px - 2rem) / 2));
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    height: 100vh;
    padding: 4rem 2rem 2rem;
    overflow: hidden auto;
    transition: opacity .22s ease;
}

.content-shell {
    min-width: 0;
    padding-top: 4rem;
}

.center,
.site-footer {
    width: min(100%, 820px);
    margin: 0 auto;
}

.brand {
    border-bottom: 1px solid var(--lightgray);
    padding-bottom: 1rem;
}

.page-title {
    margin: 0;
    font-family: var(--title-font);
    font-size: 1.35rem;
    line-height: 1.2;
}

.page-title a {
    color: var(--dark);
    text-decoration: none;
}

.brand p {
    margin: .55rem 0 0;
    color: var(--gray);
    font-size: .92rem;
    line-height: 1.5;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: .7rem;
}

.search-trigger {
    display: flex;
    align-items: center;
    min-width: 0;
    height: 2.25rem;
    flex: 1;
    gap: .45rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 0 .45rem 0 .7rem;
    background: color-mix(in srgb, var(--lightgray) 34%, transparent);
    color: var(--gray);
    text-align: left;
    transition: border-color .16s ease, background .16s ease, color .16s ease;
}

.search-trigger:hover {
    border-color: var(--lightgray);
    background: color-mix(in srgb, var(--lightgray) 55%, transparent);
    color: var(--darkgray);
}

.search-trigger svg {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.search-trigger span {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.search-trigger kbd {
    border: 1px solid var(--lightgray);
    border-radius: .3rem;
    padding: .02rem .28rem;
    color: var(--gray);
    font-family: var(--code-font);
    font-size: .68rem;
    line-height: 1.4;
}

.search {
    display: flex;
    align-items: center;
    min-width: 0;
    height: 2.25rem;
    flex: 1;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--lightgray) 34%, transparent);
    transition: border-color .16s ease, background .16s ease;
}

.search:focus-within,
.search:hover {
    border-color: var(--lightgray);
    background: color-mix(in srgb, var(--lightgray) 55%, transparent);
}

.search input {
    min-width: 0;
    width: 100%;
    border: 0;
    outline: 0;
    padding: 0 .25rem 0 .75rem;
    background: transparent;
    color: var(--darkgray);
}

.search button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    flex: 0 0 2.25rem;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--darkgray);
}

.icon-button {
    border: 1px solid var(--lightgray);
}

.search svg,
.icon-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

:root[data-theme="light"] [data-theme-icon="dark"],
:root[data-theme="dark"] [data-theme-icon="light"] {
    display: none;
}

.icon-button:hover {
    background: color-mix(in srgb, var(--lightgray) 45%, transparent);
}

.icon-button:active,
.search-trigger:active,
.toc-toggle:active,
.explorer-folder-toggle:active {
    transform: scale(.97);
}

.explorer h2,
.widget h2,
.section-heading h2 {
    margin: 0;
    color: var(--gray);
    font-family: var(--body-font);
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .08em;
    line-height: 1.3;
    text-transform: uppercase;
}

.explorer ul,
.compact-list {
    margin: .65rem 0 0;
    padding: 0;
    list-style: none;
}

.explorer li + li,
.compact-list li + li {
    margin-top: .25rem;
}

.explorer a {
    display: block;
    border-radius: var(--radius-md);
    padding: .27rem .55rem;
    color: color-mix(in srgb, var(--darkgray) 82%, transparent);
    font-size: .9rem;
    line-height: 1.45;
    text-decoration: none;
    transition: transform .16s ease, background .16s ease, color .16s ease;
}

.explorer a:hover {
    transform: translateX(2px);
    background: color-mix(in srgb, var(--lightgray) 42%, transparent);
    color: var(--dark);
}

.explorer a.active {
    background: var(--highlight);
    color: var(--secondary);
}

.explorer-folder + .explorer-folder {
    margin-top: .2rem;
}

.explorer-folder-toggle {
    display: grid;
    grid-template-columns: 1rem minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
    border: 0;
    border-radius: var(--radius-md);
    padding: .3rem .55rem .3rem .35rem;
    background: transparent;
    color: color-mix(in srgb, var(--darkgray) 86%, transparent);
    font-size: .9rem;
    line-height: 1.45;
    text-align: left;
    transition: background .16s ease, color .16s ease, transform .16s ease;
}

.explorer a.explorer-folder-toggle:hover {
    transform: none;
}

.explorer-folder-toggle:hover {
    background: color-mix(in srgb, var(--lightgray) 42%, transparent);
    color: var(--dark);
}

.explorer-folder-toggle svg {
    width: 13px;
    height: 13px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transform: rotate(-90deg);
    transition: transform .3s ease-in-out;
}

.explorer-folder.is-open .explorer-folder-toggle svg {
    transform: rotate(0deg);
}

.explorer-folder-toggle span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.explorer-folder-toggle em {
    color: var(--gray);
    font-style: normal;
    font-size: .74rem;
}

.explorer-children {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .3s ease-in-out;
}

.explorer-children > div {
    overflow: hidden;
}

.explorer-folder.is-open .explorer-children {
    grid-template-rows: 1fr;
}

.explorer-children a {
    margin: .12rem 0 .12rem 1rem;
    padding-left: .65rem;
    border-left: 1px solid var(--lightgray);
    font-size: .84rem;
}

.homepage-about-header,
.archive-header,
.article-header {
    border-bottom: 1px solid var(--lightgray);
    margin-bottom: 2rem;
    padding-bottom: 1.75rem;
}

.eyebrow {
    margin: 0 0 .45rem;
    color: var(--secondary);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.homepage-about-header h1,
.archive-header h1,
.article-header h1,
.empty-state h1 {
    margin: 0;
    color: var(--dark);
    font-family: var(--title-font);
    font-size: clamp(2rem, 5vw, 3.25rem);
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.12;
}

.homepage-about-header p:last-child,
.archive-header p:last-child {
    max-width: 650px;
    margin: .9rem 0 0;
    color: var(--gray);
    font-size: 1.08rem;
    line-height: 1.65;
}

.random-fragments {
    border-bottom: 1px solid var(--lightgray);
    margin: 0 0 1.5rem;
    padding-bottom: 1.5rem;
}

.random-fragments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.random-fragments h2 {
    margin: 0;
    color: var(--gray);
    font-family: var(--body-font);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .05em;
    line-height: 1.3;
    text-transform: uppercase;
}

.random-fragments-refresh {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-pill);
    padding: .3rem .7rem;
    background: transparent;
    color: var(--gray);
    font-size: .75rem;
    line-height: 1.3;
    transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}

.random-fragments-refresh svg {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.random-fragments-refresh.is-spinning svg {
    animation: refresh-spin .4s ease;
}

.random-fragments-refresh:hover {
    border-color: var(--secondary);
    background: color-mix(in srgb, var(--secondary) 5%, transparent);
    color: var(--secondary);
}

.random-fragments-refresh:active {
    transform: scale(.97);
}

.random-fragments-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-md);
    background: var(--lightgray);
    gap: 1px;
}

.random-fragments-grid.is-refreshing {
    animation: fragment-fade .3s ease;
}

.random-fragment-card {
    display: flex;
    min-height: 7rem;
    flex-direction: column;
    gap: .35rem;
    padding: 1rem 1.2rem;
    background: var(--light);
    color: var(--darkgray);
    text-decoration: none;
    transition: background .16s ease;
}

.random-fragment-card:hover {
    background: color-mix(in srgb, var(--lightgray) 22%, var(--light));
}

.random-fragment-title {
    display: -webkit-box;
    overflow: hidden;
    color: var(--darkgray);
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.random-fragment-date {
    margin-top: auto;
    color: var(--gray);
    font-size: .72rem;
}

.homepage-about {
    margin-bottom: 2.5rem;
}

.homepage-about > p {
    margin: 0 0 1.5rem;
    color: var(--darkgray);
    line-height: 1.7;
}

.knowledge-section {
    margin-bottom: 2.5rem;
}

.knowledge-section > h2 {
    margin: 0 0 1.5rem;
    border: 0;
    padding: 0;
    color: var(--gray);
    font-family: var(--body-font);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: .05em;
    line-height: 1.3;
    text-transform: uppercase;
}

.knowledge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    overflow: hidden;
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-lg);
    background: var(--lightgray);
    gap: 1px;
}

.knowledge-card {
    display: flex;
    min-height: 12rem;
    flex-direction: column;
    padding: 1.5rem;
    background: var(--light);
    color: var(--darkgray);
    text-decoration: none;
    transition: background .16s ease;
}

.knowledge-card:hover {
    background: color-mix(in srgb, var(--lightgray) 22%, var(--light));
}

.knowledge-card h3 {
    margin: 0 0 .8rem;
    color: var(--dark);
    font-family: var(--title-font);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
}

.knowledge-card p {
    margin: 0;
    color: var(--gray);
    font-size: .9rem;
    line-height: 1.55;
}

.knowledge-card span {
    margin-top: auto;
    color: var(--secondary);
    font-size: .82rem;
    font-weight: 700;
}

@keyframes fragment-fade {
    from {
        opacity: .35;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes refresh-spin {
    to {
        transform: rotate(360deg);
    }
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-heading span {
    color: var(--gray);
    font-size: .82rem;
}

.post-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-lg);
    background: var(--lightgray);
    gap: 1px;
}

.post-card {
    display: flex;
    min-height: 250px;
    flex-direction: column;
    padding: 1.35rem;
    background: var(--light);
    transition: background .16s ease;
}

.post-card:hover {
    background: color-mix(in srgb, var(--lightgray) 22%, var(--light));
}

.post-meta,
.content-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .65rem;
    color: var(--gray);
    font-size: .82rem;
}

.post-meta a,
.content-meta a {
    color: inherit;
    text-decoration: none;
}

.post-card h3 {
    margin: .7rem 0 .55rem;
    font-family: var(--title-font);
    font-size: 1.2rem;
    line-height: 1.3;
}

.post-card h3 a,
.archive-item h2 a,
.article-header h1 a {
    color: var(--dark);
    text-decoration: none;
}

.post-card p,
.archive-item p {
    display: -webkit-box;
    overflow: hidden;
    margin: 0;
    color: var(--gray);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.post-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: auto;
    padding-top: 1rem;
    color: var(--gray);
    font-size: .85rem;
}

.archive-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid var(--lightgray);
}

.archive-item {
    display: grid;
    grid-template-columns: 8rem minmax(0, 1fr);
    gap: 1rem;
    border-bottom: 1px solid var(--lightgray);
    padding: 1.15rem 0;
}

.archive-item time {
    color: var(--gray);
    font-family: var(--code-font);
    font-size: .82rem;
}

.archive-item h2 {
    margin: 0 0 .35rem;
    color: var(--dark);
    font-family: var(--title-font);
    font-size: 1.25rem;
    line-height: 1.35;
}

.archive-tags,
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-top: .8rem;
}

.archive-tags a,
.tags a,
.tag-cloud a {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-pill);
    padding: .18rem .55rem;
    background: color-mix(in srgb, var(--lightgray) 34%, transparent);
    color: var(--darkgray);
    font-size: .8rem;
    line-height: 1.5;
    text-decoration: none;
}

.archive-tags a::before,
.tags a::before,
.tag-cloud a::before {
    content: "#";
    margin-right: .08rem;
    opacity: .45;
}

.archive-tags a:hover,
.tags a:hover,
.tag-cloud a:hover {
    border-color: var(--secondary);
    background: var(--secondary);
    color: var(--light);
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .8rem;
    color: var(--gray);
    font-size: .86rem;
}

.breadcrumb a,
.breadcrumb span {
    color: inherit;
    text-decoration: none;
}

.content-meta {
    margin-top: .9rem;
}

.article-content {
    color: var(--darkgray);
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
    color: var(--dark);
    font-family: var(--title-font);
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.3;
}

.article-content h2 {
    border-bottom: 1px solid var(--lightgray);
    margin-top: 2.6rem;
    padding-bottom: .45rem;
    font-size: 1.55rem;
}

.article-content h3 {
    margin-top: 2rem;
    font-size: 1.25rem;
}

.article-content h1 a.internal,
.article-content h2 a.internal,
.article-content h3 a.internal,
.article-content h4 a.internal,
.article-content h5 a.internal,
.article-content h6 a.internal {
    display: inline-flex;
    align-items: center;
    margin-left: .18rem;
    opacity: 0;
    visibility: hidden;
    background: transparent;
    color: var(--secondary);
    text-decoration: none;
    transition: opacity .18s ease, visibility .18s ease, color .18s ease;
}

.article-content h1:hover a.internal,
.article-content h2:hover a.internal,
.article-content h3:hover a.internal,
.article-content h4:hover a.internal,
.article-content h5:hover a.internal,
.article-content h6:hover a.internal,
.article-content h1:focus-within a.internal,
.article-content h2:focus-within a.internal,
.article-content h3:focus-within a.internal,
.article-content h4:focus-within a.internal,
.article-content h5:focus-within a.internal,
.article-content h6:focus-within a.internal {
    opacity: 1;
    visibility: visible;
}

.article-content h1 a.internal:hover,
.article-content h2 a.internal:hover,
.article-content h3 a.internal:hover,
.article-content h4 a.internal:hover,
.article-content h5 a.internal:hover,
.article-content h6 a.internal:hover {
    background: transparent;
    color: var(--tertiary);
}

.article-content p,
.article-content li {
    line-height: 1.78;
}

.article-content p {
    margin: 0 0 1.45rem;
}

.article-content a {
    border-radius: .18rem;
    overflow-wrap: anywhere;
}

.article-content a:hover {
    background: var(--text-highlight);
}

.article-content blockquote {
    margin: 2rem 0;
    border-left: 3px solid var(--secondary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: 1rem 1.35rem;
    background: color-mix(in srgb, var(--secondary) 5%, transparent);
    color: var(--darkgray);
    font-style: italic;
}

.article-content code {
    border-radius: var(--radius-sm);
    padding: .12rem .32rem;
    background: color-mix(in srgb, var(--lightgray) 55%, transparent);
    color: var(--dark);
    font-family: var(--code-font);
    font-size: .9em;
}

.article-content pre {
    overflow-x: auto;
    margin: 2rem 0;
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-lg);
    padding: 1.1rem;
    background: color-mix(in srgb, var(--lightgray) 25%, var(--light));
}

.article-content pre code {
    padding: 0;
    background: transparent;
    color: var(--darkgray);
    font-size: .88rem;
    line-height: 1.65;
}

.article-content table {
    display: block;
    overflow-x: auto;
    width: 100%;
    border-collapse: collapse;
}

.article-content th,
.article-content td {
    border-bottom: 1px solid var(--lightgray);
    padding: .45rem .65rem;
    text-align: left;
}

.article-footer {
    margin-top: 2.5rem;
    border-top: 1px solid var(--lightgray);
    padding-top: 1.2rem;
}

.post-near {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.post-near div {
    min-width: 0;
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-md);
    padding: .9rem;
    color: var(--gray);
}

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

.comment-list {
    margin: 0 0 1.5rem;
    padding-left: 1.25rem;
}

.comment-list li {
    margin: .8rem 0;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .8rem;
}

.comment-form label {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    color: var(--gray);
    font-size: .9rem;
}

.comment-form input,
.comment-form textarea {
    width: 100%;
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-md);
    padding: .65rem .75rem;
    background: color-mix(in srgb, var(--lightgray) 22%, var(--light));
    color: var(--darkgray);
}

.comment-form input:focus,
.comment-form textarea:focus {
    outline: 2px solid color-mix(in srgb, var(--secondary) 38%, transparent);
    border-color: var(--secondary);
}

.comment-form button,
.primary-link {
    width: fit-content;
    border: 1px solid var(--secondary);
    border-radius: var(--radius-pill);
    padding: .55rem 1rem;
    background: var(--secondary);
    color: var(--light);
    font-weight: 700;
    text-decoration: none;
}

.page-nav {
    margin: 1.6rem 0 0;
}

.page-nav-inner,
.comment-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.page-nav a,
.page-nav span,
.comment-nav a,
.comment-nav span {
    display: inline-flex;
    min-width: 2.1rem;
    justify-content: center;
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-md);
    padding: .32rem .65rem;
    color: var(--darkgray);
    text-decoration: none;
}

.page-nav .current,
.page-nav a:hover,
.comment-nav a:hover {
    border-color: var(--secondary);
    background: var(--highlight);
    color: var(--secondary);
}

.widget {
    position: relative;
}

.widget::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -1rem;
    width: 1px;
    background: var(--lightgray);
}

.sidebar-right .widget::before {
    display: none;
}

.widget p {
    margin: .65rem 0 0;
    color: var(--gray);
    font-size: .92rem;
    line-height: 1.55;
}

.compact-list a {
    display: block;
    color: var(--darkgray);
    font-size: .9rem;
    line-height: 1.4;
    text-decoration: none;
}

.compact-list time {
    display: block;
    color: var(--gray);
    font-size: .76rem;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-top: .75rem;
}

.pill-link {
    display: inline-flex;
    margin-top: .85rem;
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-pill);
    padding: .22rem .65rem;
    text-decoration: none;
}

.toc-widget {
    max-height: calc(100vh - 6rem);
    padding-bottom: .25rem;
}

.toc-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--gray);
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .08em;
    line-height: 1.3;
    text-transform: uppercase;
    transition: color .16s ease, transform .16s ease;
}

.toc-toggle:hover {
    color: var(--darkgray);
}

.toc-toggle svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform .2s ease;
}

.toc-widget.is-collapsed .toc-toggle svg {
    transform: rotate(-90deg);
}

.toc-list {
    display: grid;
    gap: .16rem;
    justify-items: start;
    max-height: calc(100vh - 8.4rem);
    margin-top: .65rem;
    overflow: hidden auto;
    padding: 0 .15rem 0 .7rem;
    scrollbar-color: color-mix(in srgb, var(--secondary) 32%, transparent) transparent;
    scrollbar-width: thin;
    transition: max-height .28s ease, margin-top .28s ease, opacity .2s ease;
}

.toc-widget.is-collapsed .toc-list {
    max-height: 0;
    margin-top: 0;
    opacity: 0;
    pointer-events: none;
}

.toc-list.has-overflow.gradient-active {
    mask-image: linear-gradient(to bottom, #000 calc(100% - 2.8rem), transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 2.8rem), transparent 100%);
}

.toc-link {
    position: relative;
    display: block;
    width: fit-content;
    max-width: 100%;
    border-radius: var(--radius-md);
    padding: .2rem .45rem;
    color: var(--gray);
    font-size: .82rem;
    line-height: 1.45;
    text-decoration: none;
    transition: background .2s ease, color .2s ease;
}

.toc-link::before {
    content: "";
    position: absolute;
    top: .42rem;
    bottom: .42rem;
    left: -.62rem;
    width: 2px;
    min-height: 1.1rem;
    border-radius: var(--radius-pill);
    opacity: 0;
    background: var(--secondary);
    transition: opacity .2s ease;
}

.toc-link:hover {
    background: color-mix(in srgb, var(--secondary) 6%, transparent);
    color: var(--darkgray);
}

.toc-link.in-view {
    background: color-mix(in srgb, var(--secondary) 6%, transparent);
    color: color-mix(in srgb, var(--secondary) 58%, var(--darkgray));
}

.toc-link.in-view::before {
    opacity: .75;
}

.toc-link.is-current {
    background: color-mix(in srgb, var(--secondary) 9%, transparent);
    color: var(--secondary);
}

.toc-h3 {
    padding-left: .95rem;
}

.toc-h4 {
    padding-left: 1.45rem;
    font-size: .78rem;
}

.search-modal {
    position: fixed;
    z-index: 1100;
    inset: 0;
    display: none;
}

.search-modal[aria-hidden="false"] {
    display: block;
}

.search-backdrop {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--light) 76%, transparent);
    backdrop-filter: blur(10px);
}

.search-panel {
    position: relative;
    width: min(1040px, calc(100vw - 2rem));
    margin: 12vh auto 0;
    animation: search-enter .22s ease;
}

.search-box {
    display: grid;
    grid-template-columns: 1.25rem minmax(0, 1fr) 2.25rem;
    align-items: center;
    gap: .75rem;
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-lg);
    padding: .75rem .85rem;
    background: var(--light);
    box-shadow: var(--shadow-float);
}

.search-box svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.search-box input {
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--darkgray);
    font-size: 1.05rem;
}

.search-box button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--gray);
}

.search-box button:hover {
    background: color-mix(in srgb, var(--lightgray) 45%, transparent);
    color: var(--darkgray);
}

.search-results-shell {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(280px, 1.1fr);
    overflow: hidden;
    min-height: 380px;
    max-height: min(68vh, 660px);
    margin-top: .8rem;
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-lg);
    background: var(--lightgray);
    gap: 1px;
    box-shadow: var(--shadow-float);
}

.search-results,
.search-preview {
    overflow: auto;
    background: var(--light);
}

.search-results {
    padding: .55rem;
}

.search-result {
    display: grid;
    gap: .18rem;
    border-radius: var(--radius-md);
    padding: .72rem .8rem;
    color: var(--darkgray);
    text-decoration: none;
    transition: background .16s ease, color .16s ease;
}

.search-result:hover,
.search-result.is-active {
    background: var(--highlight);
    color: var(--dark);
}

.search-result-title {
    overflow: hidden;
    font-weight: 700;
    line-height: 1.35;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.search-result-meta,
.search-result-tags,
.search-preview-meta,
.search-preview-tags {
    color: var(--gray);
    font-size: .78rem;
}

.search-result-tags,
.search-preview-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.search-preview {
    padding: 1.4rem;
}

.search-preview h3 {
    margin: .4rem 0 .75rem;
    color: var(--dark);
    font-family: var(--title-font);
    font-size: 1.35rem;
    line-height: 1.3;
}

.search-preview p {
    margin: 0 0 1rem;
    color: var(--darkgray);
}

.search-empty {
    padding: 1rem;
    color: var(--gray);
}

@keyframes search-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (min-width: 821px) {
    html[data-reader-mode="on"] .sidebar {
        opacity: 0;
    }

    html[data-reader-mode="on"] .sidebar:hover,
    html[data-reader-mode="on"] .sidebar:focus-within {
        opacity: 1;
    }
}

.empty-state {
    border: 1px solid var(--lightgray);
    border-radius: var(--radius-lg);
    padding: 2rem;
    background: color-mix(in srgb, var(--lightgray) 16%, transparent);
}

.empty-state h2 {
    margin: 0 0 .5rem;
    color: var(--dark);
    font-family: var(--title-font);
}

.site-footer {
    margin-top: 3rem;
    margin-bottom: 4rem;
    color: var(--gray);
    font-size: .86rem;
}

@media (max-width: 1200px) {
    .layout {
        grid-template-columns: 280px minmax(0, 1fr);
    }

    .sidebar-right {
        position: static;
        grid-column: 2;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        height: auto;
        padding: 0 0 2rem;
        overflow: visible;
    }

    .toc-widget {
        grid-column: 1 / -1;
        max-height: none;
    }

    .toc-list {
        max-height: 24rem;
    }
}

@media (max-width: 820px) {
    .page {
        padding: 0 1rem;
    }

    .mobile-bar {
        position: sticky;
        z-index: 900;
        top: 0;
        display: grid;
        grid-template-columns: 2.4rem minmax(0, 1fr) 2.4rem;
        align-items: center;
        gap: .75rem;
        border-bottom: 1px solid var(--lightgray);
        margin: 0 -1rem;
        padding: .75rem 1rem;
        background: color-mix(in srgb, var(--light) 88%, transparent);
        backdrop-filter: blur(10px);
    }

    .mobile-title {
        overflow: hidden;
        color: var(--dark);
        font-family: var(--title-font);
        font-weight: 700;
        text-align: center;
        text-decoration: none;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .nav-scrim {
        position: fixed;
        z-index: 930;
        inset: 0;
        display: block;
        pointer-events: none;
        opacity: 0;
        background: color-mix(in srgb, var(--dark) 20%, transparent);
        transition: opacity .22s ease;
    }

    body.nav-open .nav-scrim {
        pointer-events: auto;
        opacity: 1;
    }

    .layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .sidebar-left {
        position: fixed;
        z-index: 940;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(86vw, 22rem);
        height: 100vh;
        border-right: 1px solid var(--lightgray);
        padding: 1.2rem 1rem 2rem;
        overflow: hidden auto;
        background: var(--light);
        transform: translateX(-104%);
        transition: transform .3s ease-in-out;
    }

    body.nav-open .sidebar-left {
        transform: translateX(0);
    }

    .sidebar-right {
        position: static;
        grid-column: auto;
        grid-template-columns: minmax(0, 1fr);
        height: auto;
        border-top: 1px solid var(--lightgray);
        margin-top: 2rem;
        padding: 1.4rem 0 2rem;
        overflow: visible;
    }

    .content-shell {
        padding-top: 1.2rem;
    }

    .center,
    .site-footer {
        width: 100%;
    }

    .is-home .center,
    .is-home .site-footer {
        transform: none;
    }

    .random-fragments-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .random-fragment-card {
        min-height: 6.4rem;
        padding: .85rem;
    }

    .post-grid,
    .form-grid,
    .post-near {
        grid-template-columns: minmax(0, 1fr);
    }

    .post-card {
        min-height: auto;
    }

    .archive-item {
        grid-template-columns: minmax(0, 1fr);
        gap: .35rem;
    }

    .widget::before {
        display: none;
    }

    .search-panel {
        width: min(100vw - 1rem, 44rem);
        margin-top: 8vh;
    }

    .search-results-shell {
        grid-template-columns: minmax(0, 1fr);
        min-height: 340px;
        max-height: 70vh;
    }

    .search-preview {
        display: none;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 15px;
    }

    .homepage-about-header h1,
    .archive-header h1,
    .article-header h1,
    .empty-state h1 {
        font-size: 2rem;
    }

    .random-fragments-header,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .knowledge-grid,
    .post-grid {
        border-radius: var(--radius-md);
    }

    .knowledge-card,
    .post-card {
        min-height: auto;
        padding: 1rem;
    }

    .search-trigger kbd {
        display: none;
    }

    .search-box {
        grid-template-columns: 1.15rem minmax(0, 1fr) 2rem;
        gap: .55rem;
        padding: .65rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
