:root {
  color-scheme: light;
  --paper: #ffffff;
  --canvas: #f1f5f4;
  --text: #1c2a2d;
  --muted: #4f6568;
  --line: #d5e2e0;
  --subtle: #f1f7f6;
  --accent: #00665e;
  --accent-strong: #004943;
  --nav: #102c31;
  --nav-light: #a8ded3;
  --header-height: 3.6rem;
  --content-width: 88rem;
  --font-sans: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  --font-mono: "Cascadia Code", Consolas, "Microsoft YaHei UI", monospace;
}

* { box-sizing: border-box; }

html {
  scroll-padding-top: calc(var(--header-height) + 1.4rem);
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 1rem/1.76 var(--font-sans);
  overflow-wrap: anywhere;
}

a {
  color: var(--accent);
  text-decoration-thickness: .07em;
  text-underline-offset: .18em;
}

a:hover { color: var(--accent-strong); }

:focus-visible {
  outline: 2px solid #078b81;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: .45rem;
  left: .55rem;
  z-index: 10;
  padding: .3rem .7rem;
  transform: translateY(-150%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .35rem;
}

.skip-link:focus { transform: none; }

.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  min-height: var(--header-height);
  background: var(--nav);
  border-bottom: 2px solid #258379;
}

.topbar-inner {
  min-height: calc(var(--header-height) - 2px);
  max-width: var(--content-width);
  margin: auto;
  padding: .45rem clamp(.9rem, 3.5vw, 2.8rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  color: #fff;
  font-size: 1.12rem;
  font-weight: 720;
  letter-spacing: .04em;
  text-decoration: none;
}

.source-link {
  color: #e3f8f3;
  font-size: .83rem;
  font-weight: 590;
  text-decoration: none;
  padding: .35rem .65rem;
  border: 1px solid #587a7a;
  border-radius: .34rem;
}

.topbar a:hover {
  color: var(--nav-light);
}

.document-layout {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2rem clamp(.9rem, 3.5vw, 2.8rem) 4rem;
  display: grid;
  grid-template-columns: minmax(11rem, 15rem) minmax(0, 1fr);
  align-items: start;
  gap: clamp(1rem, 2.8vw, 2.7rem);
}

.sidebar {
  position: sticky;
  top: calc(var(--header-height) + 1.5rem);
}

.contents > summary {
  color: var(--muted);
  font-size: .87rem;
  font-weight: 730;
  list-style: none;
  padding: .2rem .6rem .65rem;
  cursor: pointer;
}

.contents > summary::marker { content: ""; }
.contents > summary::-webkit-details-marker { display: none; }

.toc {
  max-height: calc(100vh - var(--header-height) - 4.5rem);
  max-height: calc(100dvh - var(--header-height) - 4.5rem);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #a4bfba transparent;
}

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

.toc ul ul {
  padding-left: .65rem;
}

.toc a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  font-size: .88rem;
  line-height: 1.42;
  padding: .5rem .6rem;
  margin-block: .13rem;
  border-left: 2px solid transparent;
  border-radius: .18rem;
}

.toc ul ul a { font-size: .81rem; }

.toc a:hover {
  background: #e7efed;
  color: var(--accent-strong);
}

.toc a[aria-current="location"] {
  color: var(--accent-strong);
  background: #dfeeea;
  border-left-color: #108d80;
  font-weight: 670;
}

.doc-article {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .65rem;
  box-shadow: 0 3px 18px #244b4810;
  padding: clamp(1.35rem, 4vw, 3.45rem);
}

.doc-article:focus { outline: none; }

.doc-article h1, .doc-article h2, .doc-article h3, .doc-article h4 {
  color: #143f43;
  line-height: 1.38;
  font-weight: 730;
  text-wrap: balance;
}

.doc-article h1 {
  font-size: clamp(1.85rem, 3.2vw, 2.75rem);
  letter-spacing: -.02em;
  margin: 0 0 1.25rem;
  text-wrap: wrap;
  word-break: keep-all;
}

.doc-article h2 {
  margin: 2.45rem 0 .85rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
  font-size: clamp(1.35rem, 2.35vw, 1.72rem);
}

.doc-article h3 {
  margin: 1.65rem 0 .6rem;
  font-size: 1.14rem;
}

.doc-article h4 {
  margin: 1.4rem 0 .4rem;
  font-size: 1rem;
}

.doc-article p, .doc-article ul, .doc-article ol {
  margin: .75em 0;
}

.doc-article ul, .doc-article ol { padding-left: 1.55rem; }
.doc-article li + li { margin-top: .29rem; }

.doc-article blockquote {
  border-left: 3px solid #46a999;
  background: var(--subtle);
  color: #2b4f50;
  margin: 1.25rem 0;
  padding: .55rem .95rem;
  border-radius: 0 .28rem .28rem 0;
}

.doc-article blockquote > :first-child { margin-top: 0; }
.doc-article blockquote > :last-child { margin-bottom: 0; }

.doc-article hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin-block: 2rem;
}

.table-scroll {
  margin: 1.2rem 0 1.55rem;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: .42rem;
}

.doc-article table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: .93rem;
  line-height: 1.55;
}

.doc-article th, .doc-article td {
  padding: .62rem .78rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.doc-article th {
  background: #e7f2ef;
  font-weight: 730;
  color: #214b4b;
  text-align: left;
}

.doc-article td + td, .doc-article th + th { border-left: 1px solid var(--line); }
.doc-article tbody tr:nth-child(even) > td { background: #f7faf9; }
.doc-article tbody tr:last-child > td { border-bottom: 0; }
.doc-article table:has(thead th:nth-child(4)) thead th:first-child { min-width: 6.7rem; }

.doc-article .image-table table {
  min-width: 0;
  table-layout: fixed;
}

.image-table th, .image-table td {
  text-align: center;
}

.image-table td > a {
  display: inline-block;
  max-width: 100%;
}

.doc-article .image-table img {
  max-height: 20rem;
  min-width: 0;
  object-fit: contain;
}

.doc-article code {
  font-family: var(--font-mono);
  font-size: .92em;
}

.doc-article :not(pre) > code {
  color: #005d56;
  background: #edf5f3;
  border: 1px solid #dfecea;
  padding: .07em .26em;
  border-radius: .2rem;
}

.doc-article pre {
  overflow: auto;
  padding: .95rem 1.05rem;
  margin: 1.1rem 0;
  border: 1px solid #24494d;
  border-radius: .42rem;
  background: #173438;
  color: #edf9f7;
  font: .92rem/1.53 var(--font-mono);
  overflow-wrap: normal;
}

.code-wrap {
  margin: 1.1rem 0 1.3rem;
  border: 1px solid #24494d;
  border-radius: .42rem;
  background: #173438;
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: .33rem .55rem;
  border-bottom: 1px solid #315255;
}

.code-wrap pre {
  margin: 0;
  border: 0;
  background: transparent;
}

.copy-button, .viewer-close {
  appearance: none;
  background: transparent;
  border: 1px solid #688888;
  color: #f2fbf9;
  border-radius: .28rem;
  font: 650 .78rem/1.38 var(--font-sans);
  padding: .3rem .55rem;
  cursor: pointer;
}

.copy-button:hover, .viewer-close:hover {
  background: #31595a;
}

.doc-article img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

.doc-article figure {
  margin: 1.25rem 0;
}

.doc-article figcaption {
  color: var(--muted);
  font-size: .88rem;
  text-align: center;
  margin-top: .45rem;
}

.doc-article .photo-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(.65rem, 2vw, 1.4rem);
  align-items: stretch;
}

.doc-article .photo-pair > figure {
  margin: 0;
  text-align: center;
}

.doc-article .photo-pair img {
  max-height: min(34rem, 70vh);
  object-fit: contain;
}

.image-zoom {
  appearance: none;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: .24rem;
  color: inherit;
  display: inline-block;
  max-width: 100%;
  cursor: zoom-in;
  vertical-align: middle;
}

.viewer {
  padding: 0;
  width: min(94vw, 92rem);
  max-width: 94vw;
  max-height: 94vh;
  border: 1px solid #416264;
  border-radius: .48rem;
  background: var(--nav);
  color: #ecf8f6;
}

.viewer::backdrop { background: #0b2426c9; }

.viewer header {
  padding: .48rem .85rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

.viewer header a {
  color: #e1f9f4;
  font-size: .88rem;
}

.viewer-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(93vh - 3.1rem);
  object-fit: contain;
  background: #f9fcfb;
}

@media (max-width: 53rem) {
  .document-layout {
    display: block;
    max-width: 47rem;
    padding-top: .85rem;
  }
  .sidebar { position: static; margin-bottom: .85rem; }
  .contents {
    border: 1px solid var(--line);
    border-radius: .46rem;
    background: var(--paper);
  }
  .contents > summary {
    cursor: pointer;
    padding: .62rem .9rem;
  }
  .contents > summary::after {
    float: right;
    content: "＋";
  }
  .contents[open] > summary::after { content: "−"; }
  .toc { max-height: 56vh; padding: 0 .6rem .55rem; }
}

@media (max-width: 35rem) {
  .doc-article { padding: 1.1rem; }
  .doc-article table { min-width: 30rem; }
  .doc-article td, .doc-article th { padding: .48rem .56rem; }
  .image-table td { padding-inline: .32rem; }
  .doc-article pre { font-size: .82rem; }
}

@media print {
  :root { --text: #000; }
  body { background: #fff; font-size: 10.5pt; }
  .topbar, .sidebar, .skip-link, .code-bar, .viewer { display: none !important; }
  .document-layout { display: block; margin: 0; padding: 0; }
  .doc-article { border: 0; box-shadow: none; padding: 0; }
  .doc-article h1, .doc-article h2, .doc-article h3 { break-after: avoid; }
  .doc-article pre {
    border-color: #c2cbcb;
    background: #fff;
    color: #101818;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
  .code-wrap { border-color: #c2cbcb; background: #fff; }
  .table-scroll { overflow: visible; }
  .doc-article table { min-width: 0 !important; }
  .doc-article tr { break-inside: avoid; }
  .doc-article figure { break-inside: avoid; }
  a { color: #07534e; }
}
