:root {
  color-scheme: light;
  --background: #faf9f7;
  --text: #2c2c2c;
  --muted: #646464;
  --link: #245a8d;
  --link-hover: #143b60;
  --border: #dcdad7;
  --spoiler-background: #bbb;
  --code-background: #efeeeb;
  --code-text: #303030;
  --syntax-comment: #666666;
  --syntax-keyword: #715489;
  --syntax-string: #795a2e;
  --syntax-type: #3e6087;
  --syntax-name: #3b3b3b;
  --syntax-number: #86514c;
  --syntax-punctuation: #606060;
  --copied: #303030;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #161616;
  --text: #d6d6d6;
  --muted: #a3a3a3;
  --link: #a7c7ed;
  --link-hover: #c5ddf7;
  --border: #3b3b3b;
  --spoiler-background: #000;
  --code-background: #242424;
  --code-text: #dedede;
  --syntax-comment: #9b9b9b;
  --syntax-keyword: #c3b1e1;
  --syntax-string: #d8bd91;
  --syntax-type: #a8c7e8;
  --syntax-name: #d0d0d0;
  --syntax-number: #d9aaa4;
  --syntax-punctuation: #b8b8b8;
  --copied: #dedede;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--background);
  color: var(--text);
  font-size: 16px;
}

body {
  max-width: 56rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

a {
  color: inherit;
}

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

:is(.post, .about-content) a {
  color: var(--link);
  text-decoration: underline;
}

:is(.post, .about-content) a:is(:hover, :focus-visible) {
  color: var(--link-hover);
}

a:focus-visible,
button:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 4px;
}

.site-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}

.site-name {
  font-size: 1.5rem;
  font-weight: 600;
  text-decoration: none;
}

.primary-navigation {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  color: var(--muted);
}

.primary-navigation a,
.site-footer a {
  text-decoration: none;
}

[aria-current] {
  color: var(--text);
}

.primary-navigation a:hover,
.site-footer a:hover,
.site-footer button:hover {
  color: var(--text);
}

main {
  padding: 1.5rem 0;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  line-height: 1.4;
  margin: 2rem 0 0.75rem;
}

h1 {
  margin-top: 0;
  font-size: 1.5rem;
}

h2,
h3,
h4 {
  font-size: inherit;
}

p,
ul,
ol {
  margin: 0 0 1.25rem;
}

ul,
ol {
  padding-left: 1.5rem;
}

li + li {
  margin-top: 0.35rem;
}

.post-list {
  display: table;
  width: 100%;
  margin: 0;
  font-size: inherit;
  line-height: 1.6;
}

.post-list td {
  padding: 0.2rem 0;
  border: 0;
  vertical-align: baseline;
}

.post-list td:first-child:not([colspan]) {
  width: 1%;
  padding-right: 1.5rem;
  white-space: nowrap;
}

.post-list time,
.meta {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color: var(--muted);
  font-size: 0.875rem;
}

.post-heading {
  margin-bottom: 2rem;
}

.post-heading h1 {
  margin-bottom: 0.5rem;
}

.post-heading .meta {
  margin: 0;
}

blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
  color: var(--muted);
}

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

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

main img {
  max-width: 100%;
  height: auto;
}

main table {
  display: block;
  max-width: 100%;
  margin: 1.5rem 0;
  overflow-x: auto;
  border-collapse: collapse;
}

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

code,
pre,
kbd,
samp {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.875rem;
}

:not(pre) > code {
  padding: 0.1em 0.25em;
  background: var(--code-background);
}

pre {
  margin: 1.5rem 0;
  padding: 1.25rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--code-background);
  color: var(--code-text);
  line-height: 1.7;
  text-align: left;
  tab-size: 2;
}

pre code {
  display: block;
  font-family: inherit;
}

.spoiler[data-revealed] {
  background: var(--spoiler-background);
}

.spoiler[data-revealed="false"] > .spoiler-content {
  visibility: hidden;
}

.spoiler[data-revealed="true"] {
  background: transparent;
}

.spoiler:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 2px;
}

pre code :is(.c, .ch, .cm, .cp, .cpf, .c1, .cs) {
  color: var(--syntax-comment);
  font-style: italic;
}

pre code :is(.k, .kd, .kn, .kp, .kr, .ow) {
  color: var(--syntax-keyword);
}

pre code :is(.s, .sa, .sb, .sc, .dl, .sd, .s2, .se, .sh, .si, .sx, .sr, .s1, .ss) {
  color: var(--syntax-string);
}

pre code :is(.na, .nb, .bp, .nd, .ne, .nn, .nt) {
  color: var(--syntax-name);
}

pre code :is(.nc, .kt, .nf, .fm) {
  color: var(--syntax-type);
}

pre code :is(.p, .pm, .o) {
  color: var(--syntax-punctuation);
}

pre code :is(.m, .mb, .mf, .mh, .mi, .il, .mo, .kc, .no) {
  color: var(--syntax-number);
}

.code-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.5rem 0;
  padding: 0.75rem 1.25rem 1.25rem;
  background: var(--code-background);
}

.code-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  color: var(--syntax-comment);
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.75rem;
  line-height: 1.5;
}

.code-block pre {
  min-width: 0;
  margin: 0;
  padding: 0;
}

.code-copy,
.site-footer button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.code-copy {
  flex-shrink: 0;
  color: var(--syntax-comment);
}

.code-copy:hover {
  color: var(--code-text);
}

.code-copy[data-state="copied"] {
  color: var(--copied);
}

.back-link {
  margin: 2.5rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.site-footer a:hover,
.site-footer button:hover {
  text-decoration: underline;
}

.skip-link {
  position: absolute;
  top: -4rem;
  padding: 0.5rem;
  background: var(--background);
}

.skip-link:focus {
  top: 0.5rem;
}

@media (max-width: 32rem) {
  body {
    padding: 1.25rem;
  }
}

@media print {
  :root,
  :root[data-theme="dark"] {
    color-scheme: light;
    --background: #fff;
    --text: #000;
    --muted: #444;
    --link: #000;
    --link-hover: #000;
    --border: #bbb;
    --code-background: #f5f5f5;
    --code-text: #000;
    --syntax-comment: #555;
  }

  body {
    max-width: none;
    padding: 0;
  }

  .site-header,
  .site-footer,
  .skip-link,
  .code-copy {
    display: none;
  }

  main {
    padding: 0;
  }

  pre code span {
    color: inherit !important;
  }

  .spoiler[data-revealed] {
    background: transparent;
  }

  .spoiler > .spoiler-content {
    visibility: visible !important;
  }
}
