:root {
  color-scheme: light;
  --theme: #f7f8fa;
  --entry: #ffffff;
  --primary: #1f2328;
  --secondary: #5d6673;
  --tertiary: #eef1f5;
  --content: #343941;
  --code-bg: #eef1f5;
  --border: #d9dee7;
  --accent: #b509ac;
  --accent-hover: #b509ac;
  --shadow: 0 16px 40px rgba(31, 35, 40, 0.06);
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

body.dark {
  color-scheme: dark;
  --theme: #1d1e20;
  --entry: #2a2c31;
  --primary: #eeeeef;
  --secondary: #a7abb3;
  --tertiary: #383b42;
  --content: #d2d5dc;
  --code-bg: #343740;
  --border: #3e424b;
  --accent: #2698ba;
  --accent-hover: #2698ba;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html.transition,
html.transition *,
html.transition *::before,
html.transition *::after {
  transition: all 750ms !important;
  transition-delay: 0ms !important;
}

@media (prefers-reduced-motion: reduce) {
  html.transition,
  html.transition *,
  html.transition *::before,
  html.transition *::after {
    transition-duration: 0ms !important;
  }
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--theme);
  color: var(--primary);
  font-family: var(--font-base);
  font-size: 18px;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--theme) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.nav {
  width: min(100% - 32px, 980px);
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-back {
  position: relative;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--secondary);
  font-size: 0;
  line-height: 1;
  overflow: hidden;
}

.home-back:hover {
  border-color: var(--accent);
  background: var(--tertiary);
  color: var(--accent);
}

.home-back::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 9px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translate(-35%, -50%) rotate(45deg);
}

.logo {
  font-family: var(--font-base);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--secondary);
  font-family: var(--font-base);
  font-size: 0.92rem;
  font-weight: 500;
}

.nav-actions a[aria-current="page"] {
  color: var(--accent);
}

.theme-toggle {
  position: relative;
  width: 22px;
  height: 22px;
  margin-left: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 22px;
  padding: 0;
  border: 0;
  background-color: inherit;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  line-height: 1;
}

.theme-toggle:hover {
  color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 4px;
  border-radius: 4px;
}

.theme-toggle__icon {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  display: block;
  flex: 0 0 18px;
  opacity: 0;
}

.theme-toggle__icon--sun {
  opacity: 1;
}

body.dark .theme-toggle__icon--sun {
  opacity: 0;
}

body.dark .theme-toggle__icon--moon {
  opacity: 1;
}

.theme-toggle__icon--sun::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.theme-toggle__icon--sun::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
  box-shadow:
    0 -8px 0 currentColor,
    0 8px 0 currentColor,
    8px 0 0 currentColor,
    -8px 0 0 currentColor,
    5.65px 5.65px 0 currentColor,
    -5.65px 5.65px 0 currentColor,
    5.65px -5.65px 0 currentColor,
    -5.65px -5.65px 0 currentColor;
  transform: translate(-50%, -50%);
}

.theme-toggle__icon--moon::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 50%;
  background: currentColor;
}

.theme-toggle__icon--moon::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--theme);
}

.main {
  width: min(100% - 32px, 760px);
  margin: 0 auto;
  padding: 34px 0 72px;
}

.main--post {
  width: min(100% - 32px, 980px);
}

.post-entry,
.post-single,
.not-found {
  background: var(--entry);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.home-info {
  padding: 12px 0 28px;
  margin-bottom: 0;
}

.home-info h1 {
  margin: 0 0 10px;
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.25;
}

.home-info p {
  margin: 0;
  color: var(--secondary);
}

.post-list {
  display: grid;
  gap: 16px;
}

.post-entry {
  position: relative;
  padding: 24px;
  transition: border-color 150ms ease, transform 150ms ease;
}

.post-entry:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.entry-header h2 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.3;
}

.entry-content {
  color: var(--secondary);
  font-size: 0.98rem;
}

.entry-content p {
  margin: 12px 0;
}

.entry-footer,
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--secondary);
  font-family: var(--font-base);
  font-size: 0.86rem;
}

.entry-tags {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tag {
  position: relative;
  z-index: 1;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--tertiary);
  color: var(--secondary);
  font-size: 0.84rem;
  line-height: 1.5;
}

.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tag--large {
  min-height: 32px;
  padding: 3px 12px;
  font-size: 0.95rem;
}

.entry-link {
  position: absolute;
  inset: 0;
  border-radius: 8px;
}

.page-header {
  margin: 8px 0 28px;
}

.page-header h1 {
  margin: 0;
  font-size: 2.25rem;
}

.archive-year h2 {
  margin: 0 0 14px;
  font-size: 1.5rem;
}

.archive-date-group {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 18px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.archive-date {
  color: var(--secondary);
  font-size: 0.92rem;
  line-height: 1.7;
}

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

.archive-list li {
  padding: 0;
}

.archive-list li + li {
  margin-top: 10px;
}

.search-box {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
  color: var(--secondary);
  font-family: var(--font-base);
  font-size: 0.92rem;
}

.search-box input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--entry);
  color: var(--primary);
  font: inherit;
}

.search-box input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

.topics-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.search-post-results {
  margin-top: 22px;
}

.search-post-list {
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--border);
  list-style: none;
}

.search-post-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.search-post-list a {
  font-weight: 650;
}

.search-post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
  color: var(--secondary);
  font-size: 0.86rem;
}

.search-empty {
  margin: 14px 0 0;
  color: var(--secondary);
}

.post-single {
  padding: 34px;
}

.post-header {
  margin-bottom: 30px;
}

.post-header h1 {
  margin: 0 0 12px;
  font-size: 2.55rem;
  line-height: 1.2;
}

.post-content {
  color: var(--content);
}

.post-content h2,
.post-content h3 {
  margin-top: 2rem;
  line-height: 1.25;
  color: var(--primary);
}

.post-content p,
.post-content ol,
.post-content ul {
  margin: 0 0 1.2rem;
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

code {
  padding: 0.12em 0.3em;
  border-radius: 4px;
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: 0.92em;
}

pre {
  overflow-x: auto;
  padding: 16px;
  border-radius: 8px;
  background: var(--code-bg);
}

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

.post-single--typora {
  padding: 0;
  background: #ffffff;
  color: #333333;
}

.post-single--typora .post-header {
  padding: 34px 34px 0;
  margin-bottom: 0;
}

.typora-content {
  max-width: 860px;
  margin: 0 auto;
  padding: 30px 30px 100px;
  color: #333333;
  font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, "Segoe UI Emoji", "SF Pro", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word;
  word-break: normal;
}

@media only screen and (min-width: 1400px) {
  .typora-content {
    max-width: 1024px;
  }
}

@media only screen and (min-width: 1800px) {
  .typora-content {
    max-width: 1200px;
  }
}

@media (max-width: 720px) {
  .post-single--typora .post-header {
    padding: 22px 22px 0;
  }

  .typora-content {
    padding: 22px 22px 72px;
  }
}

.typora-content h1,
.typora-content h2,
.typora-content h3,
.typora-content h4,
.typora-content h5,
.typora-content h6 {
  position: relative;
  margin-top: 1rem;
  margin-bottom: 1rem;
  color: #333333;
  font-weight: 700;
  line-height: 1.4;
  white-space: pre-wrap;
}

.typora-content h1 {
  font-size: 2.25em;
  line-height: 1.2;
  border-bottom: 1px solid #eeeeee;
}

.typora-content h2 {
  font-size: 1.75em;
  line-height: 1.225;
  border-bottom: 1px solid #eeeeee;
}

.typora-content h3 {
  font-size: 1.5em;
  line-height: 1.43;
}

.typora-content h4 {
  font-size: 1.25em;
}

.typora-content h5 {
  font-size: 1em;
}

.typora-content h6 {
  font-size: 1em;
  color: #777777;
}

.typora-content p,
.typora-content blockquote,
.typora-content ul,
.typora-content ol,
.typora-content dl,
.typora-content table,
.typora-content .md-math-block,
.typora-content .md-rawblock {
  margin: 0.8em 0;
}

.typora-content p,
.typora-content li {
  white-space: normal;
}

.typora-content ul,
.typora-content ol {
  position: relative;
  padding-left: 40px;
  white-space: normal;
}

.typora-content li {
  margin: 0;
}

.typora-content li > ol,
.typora-content li > ul {
  margin: 0;
}

.typora-content li p {
  margin: 0.35rem 0;
}

.typora-content a {
  color: #4183c4;
}

.typora-content blockquote {
  padding: 0 15px;
  border-left: 4px solid #dfe2e5;
  color: #777777;
}

.typora-content blockquote > :first-child,
.typora-content li > :first-child {
  margin-top: 0;
}

.typora-content blockquote > :last-child {
  margin-bottom: 0;
}

.typora-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0;
  vertical-align: middle;
}

.typora-content p > img:only-child {
  display: block;
  margin: auto;
}

.typora-content table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  overflow: auto;
  text-align: left;
  word-break: initial;
}

.typora-content table tr {
  border: 1px solid #dfe2e5;
}

.typora-content table tr:nth-child(2n),
.typora-content thead {
  background-color: #f8f8f8;
}

.typora-content table th,
.typora-content table td {
  padding: 6px 13px;
  border: 1px solid #dfe2e5;
}

.typora-content table th {
  font-weight: 700;
  border-bottom: 0;
}

.typora-content code,
.typora-content tt,
.typora-content .md-fences {
  padding: 2px 4px 0;
  border: 1px solid #e7eaed;
  border-radius: 3px;
  background-color: #f8f8f8;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.typora-content code {
  padding: 0 2px;
  background-color: #f3f4f4;
}

.typora-content pre,
.typora-content .md-fences {
  margin: 15px 0;
  padding: 8px 4px 6px;
  border: 1px solid #e7eaed;
  border-radius: 3px;
  background-color: #f8f8f8;
  overflow-x: auto;
  color: #333333;
  font-family: var(--font-mono);
  font-size: 0.9em;
  white-space: pre-wrap;
}

.typora-content pre code {
  padding: 0;
  border: 0;
  background: transparent;
}

.typora-content .mathjax-block,
.typora-content .md-math-block {
  width: 100%;
  overflow-x: auto;
}

.typora-content mjx-container {
  break-inside: avoid;
}

.typora-content mjx-container[jax="SVG"][display="true"] {
  display: block;
  margin: 1em 0;
  text-align: center;
}

.typora-content mjx-container[jax="SVG"] > svg {
  max-width: 100%;
}

.post-toc {
  display: none;
}

.not-found {
  padding: 54px 30px;
  text-align: center;
}

.not-found h1 {
  margin: 0 0 10px;
  font-size: 4rem;
}

.site-footer {
  width: min(100% - 32px, 980px);
  margin: 0 auto;
  padding: 28px 0 40px;
  color: var(--secondary);
  font-family: var(--font-base);
  font-size: 0.86rem;
  text-align: center;
  border-top: 1px solid var(--border);
}

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--entry);
  color: var(--secondary);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 720px) {
  body {
    font-size: 16px;
  }

  .nav {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 0;
  }

  .nav-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 12px 16px;
  }

  .theme-toggle {
    margin-left: auto;
  }

  .post-entry,
  .post-single {
    padding: 22px;
  }

  .post-header h1 {
    font-size: 2rem;
  }

  .archive-date-group {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

@media (min-width: 1500px) {
  .post-toc {
    position: fixed;
    top: 110px;
    left: max(24px, calc((100vw - 980px) / 2 - 250px));
    width: 220px;
    max-height: calc(100vh - 140px);
    display: block;
    overflow-y: auto;
    padding: 2px 0 14px;
    color: var(--secondary);
    font-family: var(--font-base);
    font-size: 0.84rem;
    line-height: 1.35;
  }

  .post-toc__title {
    margin-bottom: 10px;
    color: var(--primary);
    font-weight: 700;
  }

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

  .post-toc__link {
    display: block;
    padding: 5px 0 5px 10px;
    border-left: 2px solid var(--border);
    color: var(--secondary);
  }

  .post-toc__link:hover,
  .post-toc__link:focus {
    border-left-color: var(--accent);
    color: var(--accent);
  }

  .post-toc__link--level-1 {
    padding-left: 24px;
  }

  .post-toc__link--level-2 {
    padding-left: 38px;
  }

  .post-toc__link--level-3 {
    padding-left: 52px;
  }
}
