:root {
  color-scheme: light;

  --bg: #fffdf9;
  --fg: #222222;
  --muted: #6f6a63;
  --line: #e8e3da;
  --link: #0969da;
  --soft: #f7f3ec;
  --code-bg: #f5f2eb;
  --selection: #efe7d8;
  --max-width: 860px;

  --code-fg: #2a2a2a;
  --code-comment: #8a8175;
  --code-keyword: #8f3f71;
  --code-string: #567a30;
  --code-number: #9a4f2f;
  --code-title: #2f5f9e;
  --code-type: #6b46a3;
  --code-literal: #b2551f;
  --code-builtin: #2f5f9e;
  --code-variable: #9a4f2f;
  --code-operator: #6f6a63;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #141414;
  --fg: #f1ede7;
  --muted: #b3ada5;
  --line: #2b2b2b;
  --link: #d7a6e2;
  --soft: #1b1b1b;
  --code-bg: #1e1e1e;
  --selection: #3a3328;

  --code-fg: #e0def4;
  --code-comment: #6e6a86;
  --code-keyword: #c4a7e7;
  --code-string: #f6c177;
  --code-number: #ea9a97;
  --code-title: #c4a7e7;
  --code-type: #9ccfd8;
  --code-literal: #ebbcba;
  --code-builtin: #eb6f92;
  --code-variable: #e0def4;
  --code-operator: #56526e;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 17px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Noto Serif", "Times New Roman", Times, serif;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}

::selection {
  background: var(--selection);
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 30px 24px 88px;
}

/* topbar */

.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.35rem;
}

.theme-toggle {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0.28rem 0.68rem 0.4rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.2;
  cursor: pointer;
  min-width: 4rem;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.theme-toggle:hover {
  color: var(--fg);
  border-color: var(--muted);
  background: var(--soft);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

/* navigation */

.site-nav {
  display: flex;
  gap: 1rem;
  margin-bottom: 2.75rem;
  font-size: 0.94rem;
}

.site-nav .nav-link,
.site-nav .nav-link:visited,
.site-nav .nav-link:hover,
.site-nav .nav-link:active {
  color: var(--muted);
  text-decoration: none;
}

.site-nav .nav-link:hover {
  color: var(--fg);
  text-decoration: none;
}

.site-nav .nav-link.active,
.site-nav .nav-link.active:visited,
.site-nav .nav-link.active:hover,
.site-nav .nav-link.active:active {
  color: var(--fg);
}

/* meta */

.meta {
  color: var(--muted);
  font-size: 0.91rem;
}

/* home */

.hero {
  margin-bottom: 2.6rem;
}

.hero h1 {
  margin-bottom: 0.35rem;
}

.hero-intro {
  color: var(--muted);
  font-size: 0.98rem;
  margin: 0;
  max-width: 38rem;
}

.page-content {
  margin-top: 1.7rem;
}

/* blog index */

.site-header {
  margin-bottom: 2.2rem;
}

.site-subtitle {
  color: var(--muted);
  margin-top: 0.3rem;
  font-size: 0.98rem;
}

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

.post-item {
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--line);
}

.post-item:first-child {
  border-top: 1px solid var(--line);
}

.post-link {
  display: inline-block;
  font-size: 1.14rem;
  font-weight: 500;
  text-decoration: none;
}

.post-link,
.post-link:visited,
.post-link:hover,
.post-link:active {
  color: var(--fg);
}

.post-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 0.06em;
}

.item-desc {
  color: var(--muted);
  margin-top: 0.32rem;
  font-size: 0.9rem;
}

.post-item.empty {
  color: var(--muted);
}

/* post */

.post-header {
  margin-bottom: 2.2rem;
}

.post-header h1 {
  margin-bottom: 0.28rem;
}

.post-body > :first-child {
  margin-top: 0;
}

.post-footer {
  margin-top: 3.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.94rem;
}

/* typography */

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--fg);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 1.35em;
  margin-bottom: 0.5em;
}

h1 {
  font-size: 2rem;
  margin-top: 0;
}

h2 {
  font-size: 1.42rem;
}

h3 {
  font-size: 1.12rem;
}

p,
blockquote,
pre {
  margin: 0.82em 0;
}

ul,
ol {
  margin: 0.62em 0;
  padding-left: 1.35em;
}

li + li {
  margin-top: 0.04em;
}

a,
a:visited,
a:hover,
a:active {
  color: var(--link);
}

a,
a:visited {
  text-decoration: none;
}

a:hover,
a:active {
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 0.06em;
}

strong {
  font-weight: 600;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.8rem 0;
}

/* blockquote */

blockquote {
  margin-left: 0;
  padding-left: 0.95rem;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-style: italic;
}

/* code */

pre,
code {
  font-family: "Liberation Mono", Consolas, "Noto Sans Mono", Menlo, monospace;
  font-size: 0.92em;
}

code {
  background: var(--code-bg);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  padding: 0.85rem 0.95rem;
  overflow-x: auto;
  border-radius: 5px;
  line-height: 1.58;
}

pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.hljs {
  display: block;
  background: transparent;
  color: var(--code-fg);
}

pre code.hljs {
  display: block;
  padding: 0;
  background: transparent;
}

.hljs-comment,
.hljs-quote {
  color: var(--code-comment);
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
  color: var(--code-keyword);
}

.hljs-string,
.hljs-doctag,
.hljs-regexp {
  color: var(--code-string);
}

.hljs-number,
.hljs-literal,
.hljs-variable,
.hljs-template-variable {
  color: var(--code-number);
}

.hljs-title,
.hljs-title.function_,
.hljs-section,
.hljs-attr,
.hljs-attribute {
  color: var(--code-title);
}

.hljs-type,
.hljs-class .hljs-title,
.hljs-built_in {
  color: var(--code-type);
}

.hljs-symbol,
.hljs-bullet,
.hljs-link {
  color: var(--code-literal);
}

.hljs-built_in,
.hljs-builtin-name {
  color: var(--code-builtin);
}

.hljs-variable,
.hljs-template-variable,
.hljs-params {
  color: var(--code-variable);
}

.hljs-operator,
.hljs-punctuation {
  color: var(--code-operator);
}

/* media */

img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.35rem auto;
}

/* 404 */

.not-found {
  padding-top: 3.5rem;
}

.not-found h1 {
  margin-bottom: 0.45rem;
}

/* responsive */

@media (max-width: 640px) {
  html {
    font-size: 16px;
  }

  .wrap {
    padding: 24px 20px 72px;
  }

  .topbar {
    margin-bottom: 1rem;
  }

  .site-nav {
    margin-bottom: 2.3rem;
  }

  h1 {
    font-size: 1.72rem;
  }
}

/* icon */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.icon {
  width: 0.95em;
  height: 0.95em;
  flex: 0 0 auto;
}


/* katex */

.katex-display {
  margin: 1rem 0;
}

.katex {
  font-size: 1.15em;
}