:root {
  color-scheme: light;
  --text: #171717;
  --muted: #666666;
  --link: #1746a2;
  --border: #e2e2e2;
  --code-bg: #f7f7f7;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #FFFFF0;
  color: var(--text);
}

body {
  font-family: Charter, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  line-height: 1.72;
  font-size: 19px;
}

.page {
  width: min(760px, calc(100% - 2.25rem));
  margin: 2.5rem auto 4rem;
}

.site-nav {
  margin-bottom: 1.8rem;
  font-size: 0.95rem;
}

.site-nav a {
  color: var(--muted);
}

.post-header h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(2rem, 5.5vw, 2.75rem);
  line-height: 1.2;
  font-weight: 700;
}

.post-date {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

h2,
h3,
h4 {
  margin-top: 2rem;
  margin-bottom: 0.7rem;
  line-height: 1.3;
}

p {
  margin: 0.95rem 0;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

blockquote {
  margin: 1.1rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
  color: #333333;
}

pre,
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 0.95rem;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.5;
}

code {
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.08rem 0.25rem;
  font-size: 0.88em;
}

pre code {
  background: transparent;
  padding: 0;
}

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

img {
  max-width: 100%;
  height: auto;
}

figure {
  margin: 1.4rem 0;
}

figcaption {
  font-size: 0.9rem;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.9rem;
}

th,
td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.55rem;
  text-align: left;
}

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

.index-title {
  margin: 0 0 0.4rem;
  font-size: clamp(2rem, 5.5vw, 2.75rem);
  line-height: 1.2;
}

.index-subtitle {
  margin: 0 0 0.6rem;
  color: var(--muted);
}

.social-links {
  display: flex;
  gap: 1.2rem;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

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

.post-list li {
  margin: 0 0 1.7rem;
  padding-bottom: 1.3rem;
  border-bottom: 1px solid var(--border);
}

.post-list h2 {
  margin: 0 0 0.2rem;
  font-size: 1.28rem;
}

.post-list .meta {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.references {
  font-size: 0.93rem;
}

.algorithm-box {
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
  margin: 1.5rem 0;
  padding: 0.5rem 0;
}

.algorithm-box .algorithm-header {
  padding: 0 0 0.35rem;
  margin: 0 0 0.15rem;
  border-bottom: 0.5px solid #000;
  font-size: 0.95rem;
}

.algorithm-box table.algorithm-body {
  width: 100%;
  border-collapse: collapse;
}

.algorithm-box .algorithm-body td {
  padding: 0.06rem 0.1;
  border: none;
  vertical-align: top;
  line-height: 1.2;
}

.algorithm-box .alg-line-no {
  text-align: right;
  color: var(--muted);
  user-select: none;
  white-space: nowrap;
  width: 2.5em;
  padding-right: 0.8em;
  font-size: 0.9em;
}

.algorithm-box .alg-line {
  font-size: 0.95rem;
}

.algorithm-box .alg-header-line {
  padding-top: 0.15rem;
}

.algorithm-box .alg-spacer td {
  padding-top: 0.4rem;
}

.alg-sc {
  font-variant: small-caps;
}

.alg-comment {
  color: #888;
  font-style: italic;
}

mjx-container {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

@media (max-width: 640px) {
  body {
    font-size: 17.5px;
  }

  .page {
    width: calc(100% - 1.35rem);
    margin-top: 1.5rem;
  }
}
