:root {
  --text-color: #111;
  --muted-color: #767676;
  --bg-color: #fdfdfd;
  --link-color: #3a5ccc;
  --border-color: #e8e8e8;
  --code-bg: #f6f6f6;
  --code-border: #ddd;
}

[data-theme="dark"] {
  --text-color: #d4d4d4;
  --muted-color: #8b8b8b;
  --bg-color: #161616;
  --link-color: #7aa2f7;
  --border-color: #2c2c2c;
  --code-bg: #1e1e1e;
  --code-border: #333;
}

* {
  box-sizing: border-box;
}

body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
ol,
figure,
blockquote {
  margin: 0;
  padding: 0;
}

body {
  font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text-color);
  background-color: var(--bg-color);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.25;
  margin-top: 1.2rem;
  margin-bottom: 0.4rem;
}

p, ul, ol, pre, blockquote, table {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

img {
  max-width: 100%;
}

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

a:hover {
  text-decoration: underline;
}

ul, ol {
  padding-left: 1.4em;
}

blockquote {
  border-left: 3px solid var(--border-color);
  padding-left: 1em;
  color: var(--muted-color);
  font-style: italic;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background-color: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 0.7em 0.9em;
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
}

table {
  border-collapse: collapse;
  width: 100%;
}

table:not(.post-table) th,
table:not(.post-table) td {
  border-bottom: 1px solid var(--border-color);
  padding: 0.4em 0.8em;
  text-align: left;
}

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1.5em 0;
}

/* Layout */

.site {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 0 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9em 0 0.5em;
}

.site-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-color);
}

.site-title:hover {
  text-decoration: none;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 2em;
  height: 2em;
  color: var(--text-color);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}

.site-body {
  display: flex;
  flex: 1;
  padding: 0.75em 0 1.5em;
  border-top: 1px solid var(--border-color);
}

.site-nav {
  flex: 0 0 110px;
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  padding-top: 0.85em;
}

.nav-link {
  color: var(--text-color);
}

.nav-link.active {
  color: var(--link-color);
  font-weight: 600;
}

.page-content {
  flex: 1;
  min-width: 0;
  padding-top: 0.85em;
}

.site-footer {
  color: var(--muted-color);
  font-size: 0.85rem;
  padding: 1em 0;
  border-top: 1px solid var(--border-color);
}

.site-footer p {
  margin: 0;
}

@media (max-width: 640px) {
  .site-body {
    flex-direction: column;
  }

  .site-nav {
    flex: 0 0 25px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1em;
    padding-top: 0;
  }
}

/* Post listing */

.post-table {
  border-collapse: collapse;
}

.post-table td {
  border: none;
  padding: 0.25em 0;
}

.post-list-date {
  white-space: nowrap;
  padding-right: 1.5em !important;
  color: var(--muted-color);
  font-size: 0.9rem;
}

.draft-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.4;
  color: #fff;
  background-color: #e8720c;
  border-radius: 3px;
  padding: 0.05em 0.6em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Post / page */

.post-title,
.page-title {
  font-size: 1.6rem;
  margin-top: 0;
  margin-bottom: 0.15em;
}

.post-meta {
  color: var(--muted-color);
  font-size: 0.9rem;
  margin-bottom: 0.9em;
}

.post-content h1, .page-body h1 { font-size: 1.3rem; }
.post-content h2, .page-body h2 { font-size: 1.15rem; }
.post-content h3, .page-body h3 { font-size: 1.05rem; }
.post-content h4, .page-body h4,
.post-content h5, .page-body h5,
.post-content h6, .page-body h6 { font-size: 1rem; }

.post-tags {
  margin-top: 1.2em;
  padding-top: 0.6em;
  border-top: 1px solid var(--border-color);
}

.tag {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--muted-color);
  margin-right: 0.8em;
}

.back-link {
  margin-top: 1.5em;
  font-size: 0.9rem;
}

/* Footnotes (markdown-it-footnote) */

.footnotes-sep {
  margin-top: 1.2em;
}

.footnotes {
  font-size: 0.85rem;
  color: var(--muted-color);
}

.footnote-backref {
  margin-left: 0.3em;
}
