:root {
  color-scheme: light;
  --paper: #fbfcfa;
  --surface: #eff3ef;
  --ink: #172924;
  --muted: #495c55;
  --line: #ccd6cf;
  --accent: #9a3c2a;
  --link: #11614e;
  --measure: 65ch;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; background: var(--paper); color: var(--ink); line-height: 1.65; }
a { color: var(--link); text-underline-offset: .22em; }
a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
h1, h2, h3, p, figure, ol { margin: 0; }
img { max-width: 100%; display: block; }
[id] { scroll-margin-top: 1.5rem; }
.wrap { width: min(100% - 4rem, 68rem); margin-inline: auto; }
.skip-link { position: absolute; z-index: 2; top: 1rem; left: 1rem; padding: .6rem 1rem; background: white; transform: translateY(-180%); }
.skip-link:focus { transform: translateY(0); }

.site-header { border-bottom: 1px solid var(--line); }
.header-row, .footer-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.header-row { min-height: 4.25rem; padding-block: .65rem; }
.site-mark { display: inline-flex; align-items: center; gap: .7rem; color: var(--ink); font-weight: 700; text-decoration: none; }
.monogram { display: grid; width: 2.1rem; height: 2.1rem; flex: 0 0 2.1rem; place-items: center; border-radius: 5px; background: var(--ink); color: white; font: 700 .84rem/1 Consolas, monospace; }
.site-header nav { display: flex; gap: 1.45rem; }
.site-header nav a, .footer-row a { font-size: .9rem; color: var(--muted); text-decoration: none; }
.site-header nav a:hover, .footer-row a:hover, .site-mark:hover { color: var(--link); text-decoration: underline; }

.home { min-height: calc(100svh - 11.3rem); }
.masthead { padding-block: 2.7rem 1.45rem; }
.masthead h1 { font-size: 2.7rem; line-height: 1.25; }
.github-profile {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .1rem .65rem;
  min-height: 2.75rem;
  max-width: 100%;
  margin-top: .8rem;
  padding: .35rem .75rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  font-size: .9rem;
  font-weight: 650;
  text-decoration: none;
}
.github-profile:hover { border-color: var(--link); }
.github-handle { color: var(--muted); font-weight: 400; }
.blog-grid { display: grid; align-items: start; grid-template-columns: minmax(0, 1fr) minmax(0, 15.5rem); gap: 3.25rem; padding-top: .15rem; }
.section-heading { padding-block: .58rem .65rem; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); font-size: 1.2rem; }
.blog-sidebar { display: grid; gap: 1.65rem; }
.blog-sidebar p { margin-top: .7rem; }
.blog-sidebar .section-heading { font-size: 1.04rem; }
.bio { font-weight: 650; }
.topics, .archive-list time { color: var(--muted); }
.archive-list { list-style: none; padding: 0; }
.archive-list li { display: grid; gap: .15rem; padding-block: .7rem; border-bottom: 1px solid var(--line); }
.archive-list time, .post-meta time { font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; }
.archive-list time { font-size: .86rem; }
.post-list { list-style: none; padding: 0; }
.post-entry { padding-block: 1.22rem 1.55rem; border-bottom: 1px solid var(--line); }
.post-cover { display: block; max-width: 29rem; margin-top: 1rem; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: var(--surface); }
.post-cover img { width: 100%; height: auto; }
.post-cover:hover { border-color: var(--link); }
.post-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; color: var(--muted); font-size: .9rem; }
.meta-divider { display: block; height: .85rem; width: 1px; background: var(--line); }
.view-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.site-views { margin-top: .5rem; font-size: .9rem; }
.post-meta .view-count::before { content: "·"; margin-inline-end: .45rem; }
.post-category { font-weight: 650; color: var(--accent); }
.post-entry h3 { font-size: 1.7rem; line-height: 1.45; margin-block: .4rem .6rem; text-wrap: balance; }
.post-entry h3 a { color: var(--link); text-decoration: none; }
.post-entry h3 a:hover { text-decoration: underline; }
.title-phrase { white-space: nowrap; }
.description { color: var(--muted); max-width: 39rem; }
.read-post { display: inline-block; margin-top: .7rem; font-weight: 650; }
.site-footer { margin-top: 3rem; border-top: 1px solid var(--line); }
.footer-row { min-height: 4rem; color: var(--muted); font-size: .88rem; }

.post-top { padding-block: 2rem 1.65rem; max-width: 53rem; }
.breadcrumb { display: inline-block; font-size: .9rem; margin-bottom: 1rem; }
.post-top h1 { font-size: 2.55rem; line-height: 1.4; margin-top: .5rem; text-wrap: balance; overflow-wrap: anywhere; }
.reading-grid { display: grid; align-items: start; grid-template-columns: minmax(0, 49rem) minmax(0, 15rem); gap: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.prose { min-width: 0; font-size: 1.06rem; line-height: 1.95; overflow-wrap: anywhere; }
.prose p, .prose figure, .prose ul, .prose ol { margin-bottom: 1.15rem; }
.prose p, .prose ul, .prose ol { max-width: var(--measure); }
.prose h2 { margin: 2.1rem 0 .8rem; font-size: 1.48rem; line-height: 1.45; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li + li { margin-top: .25rem; }
.prose code { font: .9em Consolas, monospace; border-radius: 4px; padding: .14em .3em; background: var(--surface); }
.migrated-prose h3 { margin: 1.35rem 0 .5rem; font-size: 1.15rem; line-height: 1.45; }
.migrated-prose blockquote, .post-note { margin: 0 0 1.15rem; padding: .55rem .9rem; border-left: 3px solid var(--line); color: var(--muted); background: var(--surface); }
.migrated-prose pre, .table-scroll { max-width: 100%; margin: 0 0 1.15rem; overflow-x: auto; }
.migrated-prose pre { padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); line-height: 1.6; }
.migrated-prose pre code { padding: 0; background: transparent; }
.prose .math.block { max-width: 100%; margin-bottom: 1.15rem; overflow-x: auto; padding-block: .25rem; }
.migrated-prose table { min-width: 29rem; border-collapse: collapse; }
.migrated-prose th, .migrated-prose td { padding: .4rem .65rem; border: 1px solid var(--line); text-align: left; }
.migrated-prose th { background: var(--surface); }
.migrated-prose .figure-source { color: var(--muted); font-size: .9rem; }
.migrated-prose .migration-source { padding-top: .85rem; border-top: 1px solid var(--line); }
.prose figure img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; }
.migrated-prose figure img { width: auto; }
.prose figcaption { margin-top: .55rem; color: var(--muted); font-size: .9rem; line-height: 1.65; }
.migrated-prose .sync-flow { padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.migrated-prose .sync-flow ol { margin-bottom: 0; }
.training-flow { display: grid; gap: .65rem; padding: .75rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.training-flow-row { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .45rem; font-size: .9rem; line-height: 1.45; }
.training-flow-row strong { margin-inline-end: .15rem; color: var(--link); }
.training-flow-row span:not([aria-hidden]) { padding: .22rem .45rem; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); }
.training-flow figcaption { margin-top: 0; }
.toc { position: sticky; top: 1.5rem; grid-row: 1; grid-column: 2; padding-left: 1rem; border-left: 1px solid var(--line); font-size: .92rem; }
.toc summary { font-weight: 700; cursor: pointer; }
.toc ol { list-style: none; padding: 0; margin-top: .65rem; }
.toc li + li { margin-top: .45rem; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--link); text-decoration: underline; }

@media (max-width: 55rem) {
  .blog-grid { gap: 1.65rem; grid-template-columns: minmax(0, 1fr) minmax(0, 12rem); }
  .reading-grid { grid-template-columns: minmax(0, 1fr); gap: 1.1rem; padding-top: .9rem; }
  .toc { position: static; grid-column: 1; border-left: 2px solid var(--line); }
}

@media (max-width: 40rem) {
  .wrap { width: calc(100% - 2rem); }
  .header-row { min-height: 3.75rem; }
  .site-mark { gap: .45rem; font-size: .9rem; }
  .site-header nav { gap: .85rem; }
  .masthead { padding-block: 1.8rem 1.15rem; }
  .masthead h1 { font-size: 2rem; }
  .blog-grid { grid-template-columns: minmax(0, 1fr); gap: 1.65rem; }
  .post-entry { padding-block: 1rem 1.2rem; }
  .post-entry h3 { font-size: 1.37rem; }
  .post-top { padding-block: 1.4rem 1rem; }
  .post-top h1 { font-size: 1.82rem; }
  .prose { font-size: 1rem; }
  .prose h2 { font-size: 1.3rem; }
}

/* Article discussion */
.discussion { width: min(100%, 49rem); margin-block: 2.5rem 0; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.discussion-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .65rem; }
.discussion-heading h2, .discussion-heading h3 { margin: 0; }
.comment-status { margin: .45rem 0; color: var(--muted); font-size: .9rem; }
.comment-status:empty { margin: 0; }
.comment-list, .comment-replies { list-style: none; padding: 0; }
.comment-replies:not(:empty) { margin-inline-start: .55rem; padding-inline-start: .9rem; border-inline-start: 1px solid var(--line); }
.comment-entry { padding-block: .8rem; border-bottom: 1px solid var(--line); min-width: 0; }
.comment-replies .comment-entry:last-child { border-bottom: 0; padding-bottom: 0; }
.comment-meta { display: flex; flex-wrap: wrap; gap: .4rem .65rem; font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; }
.comment-message { margin: .3rem 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-button, .comment-link { font: inherit; cursor: pointer; }
.comment-button { padding: .38rem .8rem; color: var(--paper); background: var(--link); border: 1px solid var(--link); border-radius: 5px; }
.comment-button:disabled, .comment-link:disabled { opacity: .65; cursor: wait; }
.comment-link { padding: 0; border: 0; background: transparent; color: var(--link); text-decoration: underline; text-underline-offset: .22em; }
.discussion > .comment-link { margin-top: .7rem; }
.comment-dialog { color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 1.15rem; width: min(32rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); }
.comment-dialog::backdrop { background: rgb(14 28 24 / .55); }
.comment-form { display: grid; gap: .85rem; }
.comment-form > .comment-button { justify-self: end; }
.comment-identity { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: .45rem 1rem; }
.comment-identity legend { font-size: .9rem; color: var(--muted); }
.comment-form input[type=text], .comment-form textarea { display: block; width: 100%; margin-top: .2rem; padding: .48rem .55rem; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink); font: inherit; }
.comment-form textarea { resize: vertical; }

.home-replies:not([hidden]) { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .7rem; margin-top: .35rem; font-size: .9rem; }
.home-replies > .comment-status { margin: 0; }
.reply-unread { margin-inline-start: .35rem; padding: .08rem .35rem; border-radius: .3rem; background: var(--link); color: var(--paper); font-size: .8em; white-space: nowrap; }
.reply-inbox .discussion-heading h2 { font-size: 1.25rem; }
.reply-items details { padding-block: .8rem; border-bottom: 1px solid var(--line); }
.reply-items summary { color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.reply-items details[open] summary { margin-bottom: .5rem; }
.reply-inbox > .comment-link { margin-top: .75rem; }
.comment-entry { scroll-margin-top: 1rem; }
.comment-entry:target { outline: 2px solid var(--link); outline-offset: .2rem; }
