:root {
  color-scheme: light;
  --canvas: #f4f8fc;
  --surface: #fff;
  --ink: #142c41;
  --muted: #485d71;
  --line: #d9e4ec;
  --accent: #006884;
  --accent-wash: #e0f2f8;
  --navy: #102941;
  --ice: #bff3f8;
  --utility-font: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --bar-height: 60px;
  --anchor-offset: calc(var(--bar-height) + 22px);
  --page-width: 1440px;
  --page-gutter: clamp(19px, 3vw, 42px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 16px/1.7 system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link,
.copy-status {
  position: fixed;
  z-index: 5;
  padding: 8px 13px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
}

.skip-link { top: 8px; left: 12px; }
.copy-status { right: 12px; bottom: 12px; }

.skip-link:not(:focus),
.copy-status:empty {
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.site-header {
  position: sticky;
  z-index: 3;
  top: 0;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line);
}

.site-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  max-width: var(--page-width);
  min-height: var(--bar-height);
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}

.brand,
.home-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
}

.brand { font-weight: 730; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--navy);
  color: var(--ice);
  font: 700 13px var(--utility-font);
}

.home-link {
  min-height: 44px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 650;
}

.home-link:hover { text-decoration: underline; }

.reading-progress {
  position: absolute;
  inset: auto 0 -1px;
  width: 100%;
  height: 2px;
  appearance: none;
  border: 0;
  background: transparent;
}

.reading-progress::-webkit-progress-bar { background: transparent; }
.reading-progress::-webkit-progress-value { background: linear-gradient(90deg, #17a9ae, var(--accent)); }
.reading-progress::-moz-progress-bar { background: linear-gradient(90deg, #17a9ae, var(--accent)); }

.post-shell {
  max-width: var(--page-width);
  margin-inline: auto;
  padding: clamp(22px, 4vw, 48px) var(--page-gutter) 26px;
}

.post-header {
  margin-bottom: clamp(22px, 3vw, 36px);
  padding: clamp(22px, 4vw, 48px);
  border: 1px solid #d5e8f6;
  border-radius: 19px;
  background: linear-gradient(112deg, #edf7fe 26%, #deeff9);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 13px;
  color: var(--muted);
  font-size: 13px;
}

.post-meta time {
  font: 550 12px var(--utility-font);
  font-variant-numeric: tabular-nums;
}

.category-link {
  padding: 4px 11px;
  border-radius: 20px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 680;
  text-decoration: none;
}

.category-link:hover { text-decoration: underline; }

.post-header h1 {
  margin: 13px 0 0;
  font-size: clamp(2.06rem, 5vw, 3.42rem);
  font-weight: 820;
  line-height: 1.15;
  letter-spacing: -0.026em;
  overflow-wrap: anywhere;
}

.post-grid {
  display: grid;
  grid-template-columns: clamp(178px, 18vw, 220px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(16px, 2.1vw, 30px);
}

.post-toc {
  position: sticky;
  top: calc(var(--bar-height) + 20px);
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.post-toc summary {
  min-height: 44px;
  padding: 10px 13px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 740;
}

.post-toc summary::marker { color: var(--accent); }

.post-toc nav {
  max-height: calc(100dvh - var(--bar-height) - 88px);
  padding: 4px 7px 9px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #acc4d5 transparent;
}

.toc-list,
.toc-children {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.toc-children {
  margin: 1px 0 5px 7px;
  border-inline-start: 1px solid var(--line);
}

.toc-toggle {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.toc-toggle::before {
  width: 6px;
  height: 6px;
  margin-inline-end: 3px;
  border-inline-end: 1.5px solid currentColor;
  border-block-end: 1.5px solid currentColor;
  transform: rotate(-45deg);
  content: "";
}

.toc-toggle[aria-expanded="true"]::before {
  margin-inline-end: 0;
  margin-bottom: 3px;
  transform: rotate(45deg);
}

.toc-toggle:hover {
  background: var(--accent-wash);
  color: var(--accent);
}

.toc-link {
  display: block;
  padding: 6px 9px 6px calc(9px + 10px * var(--toc-depth, 0));
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.toc-link[data-top-level] {
  color: var(--ink);
  font-weight: 670;
}

.toc-link:hover { background: var(--canvas); }

.toc-link[aria-current="location"] {
  box-shadow: inset 2px 0 0 var(--accent);
  background: var(--accent-wash);
  color: var(--accent);
}

.toc-link:focus-visible { outline-offset: -2px; }

.post-content {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  padding: clamp(19px, 3.5vw, 43px);
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  font-size: clamp(1rem, 1.45vw, 1.0625rem);
  line-height: 1.83;
  overflow-wrap: anywhere;
}

.post-toc[hidden] + .post-content { grid-column: 1 / -1; }

.post-content :is(h1, h2, h3, h4, h5, h6) {
  margin: 1.6em 0 0.7em;
  color: var(--ink);
  font-weight: 760;
  line-height: 1.28;
}

.post-content :is(h1, h2) {
  padding-bottom: 0.36em;
  border-bottom: 1px solid var(--line);
  font-size: clamp(1.45rem, 2.6vw, 1.85rem);
}

.post-content h3 { font-size: clamp(1.19rem, 2.1vw, 1.42rem); }
.post-content h4 { font-size: 1.125rem; }
.post-content :is(h5, h6) { font-size: 1rem; }

.post-content,
.post-content [id] {
  scroll-margin-top: var(--anchor-offset);
}

.post-content > :first-child { margin-top: 0; }
.post-content > :last-child { margin-bottom: 0; }

.post-content :is(p, ul, ol, dl, blockquote, pre, table) {
  margin-block: 0 1em;
}

.post-content a {
  color: var(--accent);
  text-underline-offset: 0.2em;
}

.post-content ul,
.post-content ol { padding-inline-start: 1.6em; }
.post-content li + li { margin-top: 0.2em; }
.post-content :is(ol, ul) :is(ol, ul) { margin-bottom: 0.3em; }

.post-content blockquote {
  padding: 9px 15px;
  border-inline-start: 3px solid #5fadc3;
  border-radius: 0 8px 8px 0;
  background: #edf7fb;
  color: #37566c;
}

.post-content blockquote > :last-child { margin-bottom: 0; }

.post-content hr {
  margin: 1.8em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.post-content :is(img, video, iframe) { max-width: 100%; }
.post-content :is(img, video) { height: auto; }
.post-content figure { margin-inline: 0; }

.post-content code,
.post-content pre { font-family: var(--utility-font); }

.post-content :not(pre) > code {
  padding: 0.13em 0.34em;
  border-radius: 4px;
  background: #eaf2f7;
  color: #173f59;
  font-size: 0.9em;
}

.post-content pre {
  max-width: 100%;
  padding: 13px 15px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f5f8fb;
  color: #16354c;
  font-size: 0.84em;
  line-height: 1.64;
  tab-size: 4;
  overflow-wrap: normal;
}

.post-content pre code { font: inherit; }

.highlight :is(.c, .cm, .c1, .cd, .cs, .cp, .go, .w) { color: #536a7b; }

.post-code {
  margin-bottom: 1.25em;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f5f8fb;
}

.post-code-tools {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 41px;
  padding: 3px 7px 3px 14px;
  border-bottom: 1px solid var(--line);
  background: #edf4fa;
  border-radius: 9px 9px 0 0;
  color: var(--muted);
  font: 600 12px var(--utility-font);
}

.post-copy {
  min-height: 34px;
  margin-inline-start: auto;
  padding-inline: 10px;
  border: 1px solid #c4d7e5;
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  font: 650 12px system-ui, sans-serif;
}

.post-copy:hover { background: var(--accent-wash); }

.post-code :is(pre, figure) { margin: 0; }
.post-code pre { border: 0; border-radius: 0 0 9px 9px; }

.post-table {
  margin-bottom: 1.25em;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink);
  font-size: 0.92em;
}

.post-table table { margin-bottom: 0; }
.post-content table p:last-child { margin-bottom: 0; }

.post-content :is(th, td) {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
  overflow-wrap: normal;
}

.post-content th { background: #edf4fa; }
.post-content tbody tr:nth-child(even) { background: #f8fbfd; }
.post-content tbody tr:last-child td { border-bottom: 0; }

.post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: clamp(24px, 4vw, 40px);
  padding: 14px clamp(15px, 2.8vw, 30px);
  border-radius: 13px;
  background: var(--navy);
  color: #dbedf8;
  font-size: 13px;
}

.post-footer a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding-inline: 11px;
  border: 1px solid #cae6f559;
  border-radius: 8px;
  color: var(--ice);
  text-decoration: none;
}

.post-footer a:hover { background: #ffffff20; }
.post-footer a:focus-visible { outline-color: var(--ice); }

@media (max-width: 820px) {
  :root {
    --bar-height: 54px;
    --anchor-offset: calc(var(--bar-height) + 59px);
  }

  .post-grid {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .post-toc { z-index: 2; top: var(--bar-height); }
  .post-toc nav { max-height: min(55dvh, 410px); }
  .post-content { padding: clamp(14px, 3.5vw, 24px); }
}

@media print {
  :root { --anchor-offset: 0px; }
  body, .post-header, .post-content { background: #fff; }
  .post-header, .post-content { border: 0; padding: 0; }
  .post-shell { padding: 0; }
  .post-grid { display: block; }

  .skip-link, .site-header, .post-toc, .post-code-tools, .copy-status, .post-footer { display: none; }
  .post-content { font-size: 11pt; }
  .post-content pre { white-space: pre-wrap; overflow-wrap: anywhere; }
}
