:root {
  color-scheme: light dark;
  --paper: #f5f7fb;
  --paper-raised: #ffffff;
  --ink: #17202b;
  --muted: #697386;
  --line: #dbe1ea;
  --accent: #315bea;
  --accent-soft: #e8edff;
  --quote: #28364a;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: "Iowan Old Style", "Songti SC", STSong, "Noto Serif CJK SC", serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 0, transparent calc(50% - .5px), rgba(49, 91, 234, .035) 50%, transparent calc(50% + .5px)),
    var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  padding: 9px 13px;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.page-shell {
  width: min(1180px, calc(100% - 64px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  justify-content: flex-end;
  align-items: start;
  padding: 34px 0 30px;
  border-bottom: 1px solid var(--line);
}

.site-header nav { display: flex; gap: 22px; }

.site-header nav a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a:focus-visible { color: var(--accent); }

.home-main {
  display: grid;
  grid-template-columns: minmax(260px, .72fr) minmax(480px, 1.28fr);
  gap: clamp(64px, 9vw, 140px);
  padding: clamp(70px, 10vw, 132px) 0 110px;
}

.intro { position: sticky; top: 48px; align-self: start; }

.eyebrow {
  margin: 0 0 30px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .11em;
}

.intro h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(34px, 3.6vw, 50px);
  font-weight: 600;
  line-height: 1.38;
  letter-spacing: -.035em;
}

.intro h1 span { display: block; }

.intro > p:last-child {
  max-width: 29em;
  margin: 40px 0 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.9;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 0 18px;
  border-bottom: 2px solid var(--ink);
}

.section-heading h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: .08em;
}

.section-heading span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

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

.archive-row { border-bottom: 1px solid var(--line); }

.archive-row a {
  display: grid;
  grid-template-columns: 96px 1fr 20px;
  gap: 20px;
  align-items: start;
  padding: 27px 0 30px;
  text-decoration: none;
}

.archive-row time {
  padding-top: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
}

.archive-copy { display: grid; gap: 10px; }

.archive-title {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  line-height: 1.35;
  transition: color .2s ease;
}

.archive-excerpt {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.8;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.archive-arrow {
  color: var(--line);
  font-size: 15px;
  transform: translate(-6px, 2px);
  transition: color .2s ease, transform .2s ease;
}

.archive-row a:hover .archive-title,
.archive-row a:focus-visible .archive-title { color: var(--accent); }

.archive-row a:hover .archive-arrow,
.archive-row a:focus-visible .archive-arrow {
  color: var(--accent);
  transform: translate(0, -3px);
}

.archive-row--latest { border-left: 3px solid var(--accent); }
.archive-row--latest a { padding-left: 22px; }

.post-main {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: clamp(68px, 9vw, 116px) 0 100px;
}

.reading-progress {
  position: fixed;
  top: 0;
  bottom: 0;
  left: max(18px, calc((100vw - 1180px) / 2));
  width: 2px;
  z-index: 5;
  background: var(--line);
}

.reading-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  will-change: transform;
}

.back-link {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible { color: var(--accent); }

.post-meta {
  display: flex;
  gap: 18px;
  margin: 48px 0 19px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .05em;
}

.post-meta span::before { content: "·"; margin-right: 18px; }

.post-header h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(38px, 5.2vw, 67px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.045em;
}

.post-body {
  margin-top: 70px;
  font-family: var(--serif);
  font-size: clamp(17px, 1.45vw, 19px);
  line-height: 2;
  text-wrap: pretty;
}

.post-body p { margin: 0 0 1.65em; }

.post-body h2,
.post-body h3,
.post-body h4 {
  margin: 2.9em 0 1em;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.45;
}

.post-body h2 { font-size: 1.35em; }
.post-body h3 { font-size: 1.1em; }

.post-body a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
}

.post-body blockquote {
  margin: 2.4em 0;
  padding: .2em 0 .2em 1.4em;
  border-left: 3px solid var(--accent);
  color: var(--quote);
  font-size: 1.08em;
  font-style: italic;
}

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

.post-body ul,
.post-body ol { margin: 0 0 1.7em; padding-left: 1.4em; }
.post-body li { margin: .5em 0; padding-left: .25em; }
.post-body li p { margin: 0; }

.post-body hr {
  width: 56px;
  margin: 3.8em auto;
  border: 0;
  border-top: 2px solid var(--accent);
}

.callout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  margin: 2.3em 0;
  padding: 20px 22px;
  border: 1px solid #ccd7ff;
  background: var(--accent-soft);
}

.callout-marker { line-height: 2; }
.callout p:last-child { margin-bottom: 0; }

.post-body pre {
  overflow-x: auto;
  margin: 2.2em 0;
  padding: 20px 22px;
  background: #162033;
  color: #ecf1ff;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
}

.code-block { margin: 2.2em 0; }
.code-block pre { margin: 0; }
.code-block figcaption {
  margin: 0 0 9px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
}

.todo {
  display: grid;
  grid-template-columns: 1.2em 1fr;
  gap: .55em;
}

.todo > span { color: var(--accent); font-family: var(--sans); }
.todo--done { color: var(--muted); text-decoration: line-through; }

.post-body :not(pre) > code {
  padding: .08em .34em;
  background: var(--accent-soft);
  color: #2448be;
  font-family: var(--mono);
  font-size: .84em;
}

.post-body table {
  width: 100%;
  margin: 2em 0;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: .8em;
}

.post-body th,
.post-body td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; }

.post-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 90px;
  background: var(--line);
  border: 1px solid var(--line);
}

.post-nav-link {
  display: grid;
  gap: 9px;
  min-height: 132px;
  padding: 22px;
  background: var(--paper);
  text-decoration: none;
}

.post-nav-link--newer { grid-column: 2; text-align: right; }
.post-nav-link span { color: var(--muted); font-size: 11px; }
.post-nav-link strong { font-family: var(--serif); line-height: 1.5; }
.post-nav-link:hover strong,
.post-nav-link:focus-visible strong { color: var(--accent); }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  padding: 28px 0 42px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.site-footer p { margin: 0; }
.site-footer a { text-underline-offset: .2em; }

.not-found {
  min-height: 64vh;
  padding: 120px 0;
}

.not-found h1 {
  max-width: 720px;
  margin: 0 0 38px;
  font-family: var(--serif);
  font-size: clamp(42px, 7vw, 84px);
  font-weight: 600;
  line-height: 1.15;
}

.not-found a { color: var(--accent); }

@media (max-width: 820px) {
  .page-shell { width: min(100% - 40px, 680px); }
  .home-main { grid-template-columns: 1fr; gap: 70px; padding-top: 64px; }
  .intro { position: static; }
  .intro h1 { max-width: 12em; }
  .reading-progress { left: 0; }
}

@media (max-width: 560px) {
  .page-shell { width: min(100% - 28px, 680px); }
  .site-header { padding-top: 24px; }
  .site-header nav { gap: 16px; }
  .archive-row a { grid-template-columns: 1fr 20px; gap: 9px 14px; }
  .archive-row time { grid-column: 1 / -1; padding-top: 0; }
  .archive-title { font-size: 20px; }
  .archive-row--latest a { padding-left: 15px; }
  .post-main { padding-top: 56px; }
  .post-meta { margin-top: 38px; }
  .post-header h1 { font-size: clamp(34px, 10.5vw, 52px); }
  .post-body { margin-top: 52px; line-height: 1.92; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-link--newer { grid-column: 1; text-align: left; }
  .site-footer { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #11151d;
    --paper-raised: #171d27;
    --ink: #edf1f8;
    --muted: #99a4b5;
    --line: #2d3542;
    --accent: #7896ff;
    --accent-soft: #1d294d;
    --quote: #ccd5e3;
  }
  body { background: var(--paper); }
  .callout { border-color: #334879; }
  .post-body :not(pre) > code { color: #b7c6ff; }
}
