/* 公差 · TOLERANCE
   关于标准、误差与量度的边注
   排版：Palatino / 宋体；纸色与朱砂
*/

:root {
  --paper: #f5f3ed;
  --paper-2: #efece3;
  --ink: #1a1915;
  --ink-2: #46433b;
  --ink-3: #7c766a;
  --rule: #d6d0c2;
  --rule-2: #e4dfd3;
  --accent: #8f2b1e;
  --accent-soft: #b8635222;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia,
    "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", "Noto Sans CJK SC",
    "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

html[data-theme="dark"] {
  --paper: #16150f;
  --paper-2: #1c1b14;
  --ink: #e9e4d6;
  --ink-2: #bdb6a5;
  --ink-3: #8a8474;
  --rule: #322f26;
  --rule-2: #262419;
  --accent: #dc8f7a;
  --accent-soft: #dc8f7a1f;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --paper: #16150f;
    --paper-2: #1c1b14;
    --ink: #e9e4d6;
    --ink-2: #bdb6a5;
    --ink-3: #8a8474;
    --rule: #322f26;
    --rule-2: #262419;
    --accent: #dc8f7a;
    --accent-soft: #dc8f7a1f;
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.92;
  font-feature-settings: "palt" 1, "kern" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

::selection { background: var(--accent); color: var(--paper); }

a { color: inherit; text-decoration: none; }

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

/* ---------- 阅读进度 ---------- */

.progress {
  position: fixed;
  inset: 0 auto auto 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 50;
  transition: width .1s linear;
}

/* ---------- 骨架 ---------- */

.shell {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 1.6rem;
}

@media (min-width: 1080px) {
  .shell {
    display: grid;
    grid-template-columns: 15.5rem minmax(0, 1fr);
    gap: 3.2rem;
    padding: 0 2.4rem;
  }
}

/* ---------- 左侧版口 ---------- */

.rail {
  font-family: var(--sans);
  font-size: .82rem;
  line-height: 1.5;
}

@media (min-width: 1080px) {
  .rail {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3.4rem 0 2.4rem;
  }
}

@media (max-width: 1079px) {
  .rail {
    padding: 1.6rem 0 1.2rem;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 2.4rem;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
  }
}

.mark {
  display: block;
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: .18em;
  color: var(--ink);
}

@media (min-width: 1080px) {
  .mark {
    font-size: 1.7rem;
    line-height: 1.1;
    writing-mode: vertical-rl;
    text-orientation: upright;
    letter-spacing: .34em;
    margin-bottom: 1.1rem;
  }
}

@media (max-width: 1079px) {
  .mark { font-size: 1.15rem; }
  .mark span { padding-left: .5em; }
}

.mark span {
  display: block;
  font-family: var(--mono);
  font-size: .58rem;
  font-weight: 400;
  letter-spacing: .26em;
  color: var(--ink-3);
  text-transform: uppercase;
}

@media (min-width: 1080px) {
  .mark span { writing-mode: horizontal-tb; margin-top: .8rem; }
}

.rail .sub {
  font-size: .74rem;
  color: var(--ink-3);
  letter-spacing: .04em;
  line-height: 1.7;
  max-width: 12rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  margin: 1.6rem 0;
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
}

@media (max-width: 1079px) {
  .nav {
    flex-direction: row;
    gap: .2rem 1.1rem;
    flex-wrap: wrap;
    border: 0;
    padding: 0;
    margin: 0;
  }
  .rail .sub { display: none; }
  .rail-note { display: none; }
  .rail-foot {
    border: 0;
    padding: 0;
    margin: 0;
  }
  .theme { margin-top: 0; }
}

.nav a {
  display: flex;
  gap: .6em;
  align-items: baseline;
  padding: .34rem 0;
  color: var(--ink-2);
  transition: color .18s ease;
}

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

.nav a[aria-current="page"] { color: var(--ink); }

.nav a[aria-current="page"] .n { color: var(--accent); }

.nav .n {
  font-family: var(--mono);
  font-size: .62rem;
  color: var(--ink-3);
  letter-spacing: .06em;
  min-width: 1.4em;
}

.rail-foot {
  font-size: .7rem;
  color: var(--ink-3);
  letter-spacing: .03em;
  line-height: 1.85;
  border-top: 1px solid var(--rule);
  padding-top: .9rem;
}

.theme {
  appearance: none;
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  font: inherit;
  font-size: .68rem;
  letter-spacing: .1em;
  padding: .34rem .62rem;
  cursor: pointer;
  margin-top: .9rem;
  transition: border-color .18s, color .18s;
}

.theme:hover { border-color: var(--ink-3); color: var(--ink); }

/* ---------- 正文栏 ---------- */

main { min-width: 0; padding-bottom: 5rem; }

@media (min-width: 1080px) {
  main { padding-right: 1rem; max-width: 47rem; }
}

/* ---------- 首页 ---------- */

.masthead {
  padding: 3.6rem 0 2.6rem;
  border-bottom: 1px solid var(--ink);
}

@media (max-width: 700px) { .masthead { padding-top: 1.4rem; } }

.kicker {
  font-family: var(--sans);
  font-size: .7rem;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.masthead h1 {
  font-size: clamp(2.5rem, 7vw, 4.1rem);
  font-weight: 600;
  letter-spacing: .1em;
  line-height: 1.14;
  margin: 1.1rem 0 .6rem;
}

.masthead .rule-deck {
  font-size: 1.06rem;
  color: var(--ink-2);
  max-width: 30rem;
  margin: 0;
  line-height: 1.9;
}

.lede { padding: 2.4rem 0 0; max-width: 34rem; }

.lede p { margin: 0 0 1.05em; }

.lede p:first-child::first-letter {
  float: left;
  font-size: 3.3em;
  line-height: .84;
  padding: .08em .12em 0 0;
  color: var(--accent);
  font-weight: 600;
}

/* 目录 */

.toc-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin: 4rem 0 1.2rem;
}

.toc-head h2 {
  font-family: var(--sans);
  font-size: .72rem;
  font-weight: 400;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0;
  white-space: nowrap;
}

.toc-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
  transform: translateY(-.25em);
}

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

.toc li { border-bottom: 1px solid var(--rule-2); }

.toc a {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) 8.5rem;
  gap: 1.2rem;
  align-items: baseline;
  padding: 1.35rem 0 1.3rem;
  transition: color .18s ease;
}

@media (max-width: 700px) {
  .toc a { grid-template-columns: 2.2rem minmax(0, 1fr); }
  .toc .reading { display: none; }
}

.toc a:hover .t-title { color: var(--accent); }

.toc .n {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--ink-3);
  letter-spacing: .08em;
}

.t-title {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.45;
  transition: color .18s ease;
}

.t-deck {
  display: block;
  font-size: .9rem;
  font-weight: 400;
  color: var(--ink-2);
  line-height: 1.75;
  margin-top: .35rem;
  max-width: 24rem;
}

.reading {
  font-family: var(--mono);
  font-size: .66rem;
  color: var(--ink-3);
  text-align: right;
  letter-spacing: .06em;
  line-height: 1.7;
}

.reading b {
  display: block;
  font-weight: 400;
  color: var(--ink-2);
  font-size: .72rem;
  letter-spacing: .02em;
}

/* ---------- 文章 ---------- */

.post-head {
  position: relative;
  padding: 3.4rem 0 2.2rem;
  border-bottom: 1px solid var(--rule);
}

@media (max-width: 700px) { .post-head { padding-top: 1.2rem; } }

.folio {
  position: absolute;
  top: 3rem;
  right: 0;
  font-family: var(--mono);
  font-size: 2.4rem;
  line-height: 1;
  color: var(--rule);
  letter-spacing: -.03em;
  user-select: none;
  pointer-events: none;
}

@media (max-width: 700px) {
  .folio {
    position: static;
    display: block;
    font-size: 1.4rem;
    margin-bottom: .5rem;
  }
}

.post-head h1 {
  font-size: clamp(1.95rem, 4.6vw, 2.9rem);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: .01em;
  margin: .9rem 0 0;
  max-width: 30ch;
}

.deck {
  font-size: 1.12rem;
  line-height: 1.9;
  color: var(--ink-2);
  margin: 1.35rem 0 0;
  max-width: 32rem;
}

.byline {
  font-family: var(--sans);
  font-size: .7rem;
  letter-spacing: .13em;
  color: var(--ink-3);
  margin-top: 1.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .9rem;
}

.byline span + span::before {
  content: "·";
  margin-right: .9rem;
  color: var(--rule);
}

.article {
  max-width: 34.5rem;
  padding-top: 2.1rem;
  font-size: 1.0625rem;
}

.article p {
  margin: 0 0 .92em;
  text-align: justify;
  text-justify: inter-ideograph;
}

/* 书刊式缩进：只在段与段相连时出现 */
.article p + p { text-indent: 2em; }

.article > p:first-of-type { text-indent: 0; }

.article h2 + p,
.article h3 + p,
.article blockquote + p,
.article figure + p,
.article .table-wrap + p,
.article ul + p,
.article ol + p { text-indent: 0; }

.article h2 {
  font-family: var(--sans);
  font-size: .74rem;
  font-weight: 400;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 3rem 0 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
}

.article h3 {
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: .02em;
  margin: 2.2rem 0 .8rem;
}

.article ul, .article ol { margin: 0 0 1.2em; padding-left: 1.4em; }
.article li { margin-bottom: .45em; }

.article li::marker { color: var(--ink-3); }

.article strong { font-weight: 600; }

.article em { font-style: italic; }

.article a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  transition: text-decoration-color .18s;
}

.article a:hover { text-decoration-color: var(--accent); }

.article sup.ref {
  font-size: .66em;
  line-height: 0;
  vertical-align: super;
  margin-left: .1em;
}

.article sup.ref a {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--mono);
  letter-spacing: -.02em;
  padding: 0 .06em;
}

.num {
  font-variant-numeric: oldstyle-nums proportional-nums;
  letter-spacing: .01em;
}

/* 引文 */

.article blockquote {
  margin: 2.2rem 0;
  padding: 0 0 0 1.4rem;
  border-left: 2px solid var(--accent);
  font-size: 1.16rem;
  line-height: 1.85;
  color: var(--ink);
}

.article blockquote p:last-child { margin-bottom: 0; }

.article blockquote cite {
  display: block;
  font-family: var(--sans);
  font-style: normal;
  font-size: .72rem;
  letter-spacing: .1em;
  color: var(--ink-3);
  margin-top: .8rem;
}

/* 图 */

figure {
  margin: 2.6rem 0;
  padding-top: .9rem;
  border-top: 1px solid var(--rule);
}

figure svg { display: block; width: 100%; height: auto; color: var(--ink-2); }

figcaption {
  font-family: var(--sans);
  font-size: .73rem;
  line-height: 1.75;
  color: var(--ink-3);
  margin-top: .85rem;
  max-width: 32rem;
}

figcaption b {
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: .06em;
}

/* 表 */

.table-wrap { margin: 2.2rem 0; overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

caption {
  font-family: var(--sans);
  font-size: .73rem;
  color: var(--ink-3);
  text-align: left;
  padding-bottom: .6rem;
  letter-spacing: .04em;
  caption-side: top;
}

th {
  font-family: var(--sans);
  font-size: .68rem;
  font-weight: 400;
  letter-spacing: .12em;
  color: var(--ink-3);
  text-align: left;
  padding: 0 0 .55rem;
  border-bottom: 1px solid var(--ink-3);
  white-space: nowrap;
}

td {
  padding: .5rem 0;
  border-bottom: 1px solid var(--rule-2);
  vertical-align: baseline;
}

th + th, td + td { padding-left: 1.2rem; }

.num-c, .num-r { text-align: right; font-variant-numeric: tabular-nums; }

.mark-row td { background: var(--accent-soft); }

/* 注释 */

.notes {
  margin: 3.4rem 0 0;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: .76rem;
  line-height: 1.85;
  color: var(--ink-3);
  counter-reset: note;
}

.notes h2 {
  font-size: .66rem;
  font-weight: 400;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 .8rem;
}

.notes ol { list-style: none; margin: 0; padding: 0; }

.notes li {
  position: relative;
  padding-left: 1.9rem;
  margin-bottom: .6rem;
  counter-increment: note;
}

.notes li::before {
  content: counter(note);
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--mono);
  font-size: .66rem;
  color: var(--ink-3);
}

.notes a { color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--rule); }

/* 下一篇 */

.next {
  margin-top: 3.4rem;
  border-top: 1px solid var(--ink);
  padding-top: 1.2rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--sans);
}

.next .lbl { font-size: .66rem; letter-spacing: .2em; color: var(--ink-3); }

.next a {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  transition: color .18s;
}

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

/* ---------- 页脚 ---------- */

.foot {
  margin-top: 4rem;
  padding: 1.4rem 0 3rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: .7rem;
  line-height: 1.9;
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 2rem;
  justify-content: space-between;
  letter-spacing: .04em;
}

.foot a { color: var(--ink-2); }
.foot a:hover { color: var(--accent); }

/* ---------- 关于页 ---------- */

.about { max-width: 34rem; }
.about p { margin: 0 0 1.05em; }

.colophon {
  margin-top: 2.6rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: .78rem;
  line-height: 1.95;
  color: var(--ink-2);
}

.colophon dl {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: .35rem 1rem;
  margin: 0;
}

.colophon dt {
  font-size: .68rem;
  letter-spacing: .12em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.colophon dd { margin: 0; }

@media print {
  .rail, .progress, .theme, .next { display: none; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .article { max-width: none; }
}