*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --toc-width: 408px;
  --header-height: 78px;
  --gap: 2rem;
  --fg: #111;
  --muted: #555;
  --border: #d0d0d0;
  --toc-active: #000;
  --link: #7a004b;
  --font-sans: system-ui, -apple-system, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

a {
  color: var(--link);
}

body {
  font-family: var(--font-sans);
  color: var(--fg);
  background: #fff;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

#site-title {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

#site-title a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: inherit;
  text-decoration: none;
}

#site-logo {
  height: 28px;
  width: 28px;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}

#site-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

#site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

#site-nav a {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.3rem 1.18rem;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

#site-nav a:hover {
  background: var(--fg);
  color: #fff;
  border-color: var(--fg);
}

#site-nav a.nav-primary {
  background: var(--link);
  border-color: var(--link);
  color: #fff;
}

#site-nav a.nav-primary:hover {
  background: var(--fg);
  border-color: var(--fg);
}

#toc {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--toc-width);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 2rem 1.25rem 2rem 1.5rem;
  font-size: 16.4px;
  line-height: 1.45;
}

#toc nav {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#toc ul {
  list-style: none;
  padding-left: 0;
}

#toc ul ul {
  padding-left: 0.875rem;
  border-left: 1px solid var(--border);
  margin-left: 0.25rem;
}

#toc li {
  margin: 0;
}

#toc a {
  display: block;
  padding: 0.25rem 0;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.1s;
}

#toc a:hover,
#toc a.active {
  color: var(--toc-active);
}

#toc-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

#content {
  margin-left: var(--toc-width);
  margin-top: var(--header-height);
  padding: 2.5rem 3rem 4rem calc(var(--gap) + 0.5rem);
  max-width: 820px;
  width: 100%;
}

#content h1,
#content h2,
#content h3,
#content h4,
#content h5,
#content h6 {
  scroll-margin-top: calc(var(--header-height) + 1rem);
}

#content h1 {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

#content h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

#content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 0.4rem;
}

#content h4,
#content h5,
#content h6 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.3rem;
}

#content p {
  margin-bottom: 0.9rem;
  hyphenate-limit-chars:7;
  -webkit-hyphens:auto;
  -moz-hyphens:auto;
  hyphens:auto;
  text-align:justify;
  text-wrap:pretty
}

#content ul,
#content ol {
  padding-left: 1.5rem;
  margin-bottom: 0.9rem;
}

#content li {
  margin-bottom: 0.2rem;
}

#content a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--link) 30%, transparent);
  text-underline-offset: 2px;
}

#content a:hover {
  text-decoration-color: var(--link);
}

#content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: #f3f3f3;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

#content pre {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: #f7f7f7;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  line-height: 1.55;
}

#content pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

#content blockquote {
  border-left: 3px solid var(--border);
  margin: 1rem 0;
  padding: 0.25rem 1rem;
  color: var(--muted);
}

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

#content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

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

#content th {
  background: #f7f7f7;
  font-weight: 600;
}

#toc a.active {
  font-weight: 600;
  color: var(--toc-active);
}

#toc-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

#toc-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--fg);
  border-radius: 2px;
}

#toc-overlay {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 149;
  opacity: 0;
  transition: opacity 0.25s;
}

#toc-overlay.open {
  opacity: 1;
}

@media (max-width: 700px) {
  #toc-toggle {
    display: flex;
  }

  #site-subtitle {
    display: none;
  }

  #site-nav a:not(.nav-primary) {
    display: none;
  }

  #toc-overlay {
    display: block;
    pointer-events: none;
  }

  #toc-overlay.open {
    pointer-events: auto;
  }

  #toc {
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 150;
    background: #fff;
    width: min(var(--toc-width), 85vw);
  }

  #toc.open {
    transform: translateX(0);
  }

  #content {
    margin-left: 0;
    padding: 1.5rem 1.25rem 3rem;
  }
}

body:not(.has-toc) #toc-toggle {
  display: none;
}

#content.wide {
  margin-left: 0;
  padding-left: 3rem;
}

@media (max-width: 700px) {
  #content.wide {
    padding-left: 1.25rem;
  }
}

#content .post-list {
  list-style: none;
  padding: 0;
  margin-top: 1.5rem;
}

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

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

.post-date {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

#content .post-title {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  line-height: 1.3;
  margin-bottom: 0.65rem;
}

#content .post-title:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--fg);
}

.post-excerpt {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.65;
}

.post-read-more {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--link);
}

.post-read-more:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-empty {
  color: var(--muted);
  margin-top: 2rem;
}

.post-back {
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.post-back-end {
  margin-top: 3rem;
  margin-bottom: 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

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

.pagination {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2.5rem;
  font-size: 0.9rem;
}

.pagination-link {
  color: var(--fg);
  text-decoration: none;
  font-weight: 500;
}

.pagination-link:hover {
  text-decoration: underline;
}

.pagination-info {
  color: var(--muted);
}

#site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1.5rem 3rem 1.5rem calc(var(--gap) + 0.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
}

body.has-toc #site-footer {
  margin-left: var(--toc-width);
}

#site-footer a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 1.5rem;
}

#site-footer a:hover {
  color: var(--fg);
}

@media (max-width: 700px) {
  #site-footer {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 1.25rem;
  }

  body.has-toc #site-footer {
    margin-left: 0;
  }

  #site-footer a {
    margin-left: 0;
    margin-right: 1.25rem;
  }

  #site-footer nav {
    display: flex;
  }
}
