:root {
  --bg: #fbfaf7;
  --fg: #161616;
  --muted: #6f6a62;
  --soft: #9b948b;
  --line: #e3ddd4;
  --line-strong: #cfc7bc;
  --code: #f2eee8;
  --page: 820px;
  --home: 760px;
  --text: 720px;
  --toc: 230px;
  --footer: 820px;
}

html.theme-dark {
  --bg: #111111;
  --fg: #eeeeee;
  --muted: #aaa39a;
  --soft: #7d766f;
  --line: #2d2d2d;
  --line-strong: #484848;
  --code: #1b1b1b;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--soft);
}

a:hover {
  border-bottom-color: currentColor;
}

.top,
main {
  width: min(var(--page), calc(100vw - 48px));
  margin: 0 auto;
}

.site-footer {
  width: min(var(--footer), calc(100vw - 48px));
  margin: 0 auto;
}

.top {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-strong);
}

.logo {
  border: 0;
  color: var(--fg);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

nav {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

nav a {
  color: var(--muted);
  border-bottom-color: transparent;
}

nav a:hover {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.theme-btn {
  width: auto;
  padding: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.theme-btn:hover {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

main {
  padding-bottom: 84px;
}

/* Home */
.home-hero {
  max-width: var(--home);
  margin: 0 auto;
  padding: 62px 0 48px;
}

.home-kicker {
  margin-bottom: 14px;
  color: var(--soft);
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.home-hero h1 {
  margin: 0;
  color: var(--fg);
  font-family: Georgia, "Times New Roman", "Noto Serif SC", serif;
  font-size: clamp(34px, 5.6vw, 58px);
  line-height: .98;
  letter-spacing: -.04em;
  font-weight: 500;
}

.home-hero p {
  max-width: 560px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 15.5px;
}

.post-list {
  max-width: var(--home);
  margin: 0 auto;
  border-top: 1px solid var(--line);
}

.post-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 28px;
  padding: 23px 0;
  border-bottom: 1px solid var(--line);
}

.date {
  color: var(--soft);
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding-top: 5px;
}

.post-content h2 {
  margin: 0;
  color: var(--fg);
  font-size: 19px;
  line-height: 1.35;
  letter-spacing: -.02em;
  font-weight: 650;
}

.post-content h2 a {
  border: 0;
}

.post-content p {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14.5px;
}

.post-meta {
  margin-top: 8px;
  color: var(--soft);
  font-size: 13px;
}

.post-meta a {
  color: var(--soft);
}

/* General pages */
.page-title {
  max-width: var(--text);
  margin: 0 auto;
  padding-top: 54px;
  padding-bottom: 28px;
  color: var(--fg);
  font-size: 24px;
  line-height: 1.22;
  letter-spacing: -.025em;
  font-weight: 650;
}

/* Article */
.article-page {
  padding-top: 52px;
}

.article-head {
  width: min(var(--text), 100%);
  margin: 0 auto 30px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line-strong);
}

.article-head h1 {
  margin: 0;
  color: var(--fg);
  font-size: clamp(26px, 3.4vw, 36px);
  line-height: 1.24;
  letter-spacing: -.035em;
  font-weight: 650;
}

.meta {
  margin-top: 12px;
  color: var(--soft);
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.tags {
  margin-top: 11px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
}

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

/* Body is centered; TOC floats to the right of it */
.article-grid {
  width: min(var(--text), 100%);
  margin: 0 auto;
  position: relative;
}

.toc-side {
  position: fixed;
  top: 112px;
  left: calc(50vw + (var(--text) / 2) + 56px);
  width: var(--toc);
  color: var(--muted);
  z-index: 5;
}

.toc {
  position: static;
  margin: 0;
  padding-left: 16px;
  border-left: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.55;
}

.toc strong {
  display: block;
  margin-bottom: 8px;
  color: var(--soft);
  font: 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.toc ol {
  margin: 0;
  padding-left: 1.15em;
}

.toc li {
  margin: 5px 0;
  max-width: 200px;
}

.toc a {
  display: block;
  max-width: 100%;
  color: var(--muted);
  border-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc a:hover {
  color: var(--fg);
}

.markdown {
  max-width: var(--text);
  color: var(--fg);
}

.markdown img,
.upload-preview img,
.image-list img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 24px auto;
  border: 1px solid var(--line);
}

/* Forms / Admin */
.form {
  max-width: var(--text);
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

input,
textarea,
select,
button {
  width: 100%;
  font: inherit;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--fg);
  padding: 10px 11px;
}

textarea {
  min-height: 380px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
}

.form button {
  cursor: pointer;
  border-color: var(--fg);
  background: var(--fg);
  color: var(--bg);
  font-weight: 700;
}

.admin-links {
  max-width: var(--text);
  display: flex;
  gap: 10px;
  margin: 50px auto 26px;
  flex-wrap: wrap;
}

.admin-links a {
  border: 1px solid var(--line-strong);
  padding: 5px 9px;
  color: var(--fg);
  font-size: 14px;
}

.notice,
.success,
.small {
  max-width: var(--text);
  margin-left: auto;
  margin-right: auto;
}

.notice {
  padding: 8px 0;
  color: #c03;
}

.success {
  padding: 8px 0;
  color: #087a2d;
}

.small {
  color: var(--muted);
  font-size: 13px;
}

.copy-code {
  max-width: var(--text);
  margin-left: auto;
  margin-right: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 10px;
  background: var(--code);
  border: 1px solid var(--line);
  word-break: break-all;
}

.image-list {
  max-width: var(--text);
  margin: 0 auto;
  display: grid;
  gap: 24px;
}

.image-item {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

/* Footer */
.site-footer {
  margin-top: 0;
  padding: 34px 0 48px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 48px;
}

.footer-label {
  margin-bottom: 10px;
  color: var(--soft);
  font: 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.footer-name {
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.site-footer p {
  margin: 0 0 6px;
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
  border-bottom-color: transparent;
}

.site-footer a:hover {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--soft);
  font-size: 12px;
}

.footer-records {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  color: var(--soft);
}

.footer-records a {
  color: var(--soft);
}

.footer-records em {
  font-style: normal;
  color: var(--soft);
}

@media (max-width: 1240px) {
  .toc-side {
    position: static;
    width: auto;
    margin-bottom: 26px;
  }

  .toc {
    position: static;
    padding: 14px 0;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .toc li {
    max-width: none;
  }

  .toc a {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .toc ol {
    columns: 2;
    column-gap: 32px;
  }
}

@media (max-width: 720px) {
  .top,
  main,
  .site-footer {
    width: calc(100vw - 32px);
  }

  .top {
    min-height: auto;
    padding: 22px 0 16px;
    align-items: flex-start;
    gap: 14px;
    flex-direction: column;
  }

  nav {
    gap: 11px;
  }

  .home-hero {
    padding: 48px 0 38px;
  }

  .home-hero h1 {
    font-size: clamp(34px, 12vw, 48px);
  }

  .post-row {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 22px 0;
  }

  .article-page {
    padding-top: 36px;
  }

  .article-head h1 {
    font-size: 25px;
  }

  .toc ol {
    columns: 1;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .footer-bottom {
    align-items: flex-start;
    flex-direction: column;
  }

  .footer-records {
    margin-left: 0;
    white-space: normal;
  }
}
