:root {
  /* Color variables */
  --color-text: #212529;
  --color-text-light: #6c757d;
  --color-bg: #ffffff;
  --color-gray: #f7f7f7;
  --color-border: #eaecef;
  --color-selection: rgba(178, 224, 251, 0.5);
  --color-accent: #d73a49;
  --color-code-bg: rgba(169, 189, 215, 0.4);
  --color-pre-bg-light: #f6f8fa;
  --color-pre-bg-dark: #161b22;

  /* Font variables */
  --font-serif: "Times New Roman", Georgia, PMingLiu, SimSun, "WenQuanYi Bitmap Song", "Noto Serif CJK", serif;
  --font-sans: "Helvetica Neue", Roboto, "Segoe UI", SegoeUI, Helvetica, Arial, sans-serif;
  --font-mono: IBM Plex Mono, Consolas, Monaco, Andale Mono, monospace, "LXGW WenKai";

  /* Spacing variables */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 4rem;

  /* Font size variables */
  --font-size-base: 1.05em;
  --font-size-small: 0.90em;
  --font-size-large: 1.25em;
  --font-size-xl: 1.5em;
  --font-size-xxl: 2em;

  /* Layout variables */
  --max-width: 60rem;
  --content-width: 65%;
  --line-height: 1.8;
  --border-radius: 4px;
  --border-radius-large: 8px;

  text-autospace: normal;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-text: #f0f0f0;
    --color-bg: #212529;
    --color-border: #444;
    --color-code-bg: rgba(100, 120, 140, 0.3);
  }
}

* {
  margin: 0px;
  padding: 0px;
  color: var(--color-text);
}

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

html {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  line-height: var(--line-height);
  font-family: var(--font-serif);
  font-size: var(--font-size-base);
  font-weight: normal;
  -moz-osx-font-smoothing: grayscale;
  -moz-font-feature-settings: "liga" on;
  -webkit-font-smoothing: auto;
  width: var(--content-width);
  max-width: var(--max-width);
  margin: 0 auto;
  margin-top: var(--space-xl);
  padding-bottom: var(--space-xl);
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  font-feature-settings: "halt";
  background-color: var(--color-bg);
  text-rendering: optimizeLegibility;
}

a {
  background-color: transparent;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.section-title {
  display: block;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
  font-style: normal;
  font-size: var(--font-size-xl);
  font-weight: normal;
}

.section-title:first-child {
  margin-top: 0;
}

.content {
  display: flex;
  flex-wrap: nowrap;
  flex-direction: column;
  align-items: stretch;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  flex-direction: row;
  margin-top: 2rem;
}

code.has-jax {
  font: inherit;
  font-size: 100%;
  background: inherit;
  border: inherit;
  color: #515151;
}

::selection {
  background: var(--color-selection);
}

::-moz-selection {
  background: var(--color-selection);
}

::-webkit-selection {
  background: var(--color-selection);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin-top: var(--space-md);
  font-weight: 500;
  line-height: 1.25;
  padding-bottom: 0.3em;
}

h1 {
  font-size: var(--font-size-xxl);
}

h1:first-child {
  border-bottom: 0;
}

h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child,
h5:first-child,
h6:first-child {
  margin-top: 0;
}

h2 {
  font-size: var(--font-size-xl);
}

h3 {
  font-size: var(--font-size-large);
}

h4 {
  font-size: 1em;
}

a {
  margin: 0;
  padding: 0;
  vertical-align: baseline;
}

ul,
ol {
  padding: 0px;
  margin: 0;
  margin-left: 18px;
}

ul li:has(input[type="checkbox"]) {
  list-style: none;
  margin-left: 0px;
}

li input[type="checkbox"] {
  transform: scale(1.2);
  margin-right: 8px;
  margin-left: -16px;
}

li ul {
  margin-left: 32px;
}

ul li {
  list-style: disc;
}

code {
  font-family: var(--font-mono);
  line-height: 1.5;
  background: var(--color-code-bg);
  border-radius: var(--border-radius);
  padding: 2px 6px;
  font-size: var(--font-size-small);
  margin-left: 2px;
  margin-right: 2px;
}

pre {
  font-size: 16px;
  margin: 16px 0;
  padding: 16px;
  border-radius: var(--border-radius-large);
  overflow-x: scroll;
}

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

aside {
  display: block;
  float: right;
  width: 390px;
}

blockquote {
  background-color: var(--color-gray);
  border-left: 2px solid var(--color-accent);
  padding: var(--space-sm);
}

blockquote::before {
  margin-right: 0.25em;
  color: var(--color-accent);
  content: "\201C";
  vertical-align: -0.4em;
  font-size: var(--font-size-xxl);
  line-height: 0.8em;
}

hr {
  text-align: left;
  margin: 8px 0;
  color: var(--color-border);
  border-bottom: 0px;
}

table {
  border-collapse: collapse;
  margin: 1em 0.2em;
  border: 1px solid #CCC;
}

table thead {
  font-weight: bold;
}

table th,
table td {
  padding: 0px 8px;
  border: 1px solid #CCC;
}

blockquote,
details,
dl,
pre,
table {
  margin-top: 16px;
  margin-bottom: 8px;
}

p {
  margin-top: 8px;
  margin-bottom: 8px;
}

img {
  max-width: 100%;
  box-sizing: content-box;
  background-color: #fff;
  margin: 10px 0px;
}

.hljs {
  background-color: transparent !important;
}

@media screen and (prefers-color-scheme: light) {

  .highlight pre,
  pre {
    background-color: var(--color-pre-bg-light) !important;
  }
}

@media screen and (prefers-color-scheme: dark) {

  .highlight pre,
  pre {
    background-color: var(--color-pre-bg-dark) !important;
  }
}

/* Responsive design improvements */
@media screen and (max-width: 768px) {
  :root {
    --font-size-base: 1rem;
    --content-width: 90%;
    --space-xl: 2rem;
  }

  body {
    margin-top: var(--space-lg);
    text-align: left;
  }

  h1 {
    font-size: 1.8rem;
  }

  h2 {
    font-size: 1.4rem;
  }

  .navbar ul li {
    padding-left: 10px;
    padding-right: 10px;
  }
}

@media screen and (max-width: 480px) {
  :root {
    --font-size-base: 1rem;
    --content-width: 95%;
  }

  body {
    margin: 24px auto;
  }
}

.content .chroma {
  overflow: scroll;
}

.content-body h2:before,
.content-body h3:before,
.content-body h4:before,
.content-body h5:before,
.content-body h6:before {
  margin-right: 0.25em;
  color: var(--color-accent);
}

.content-body h2:before {
  content: "##";
}

.content-body h3:before {
  content: "###";
}

.content-body h4:before {
  content: "####";
}
