:root {
  --bg: #fdfdfc;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --rule: #e6e4df;
  --accent: #a33636;
  --code-bg: #f3f2ee;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --fg: #ececec;
    --muted: #9a9a95;
    --rule: #2a2a28;
    --accent: #e98a8a;
    --code-bg: #1c1c1a;
  }
}

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

html {
  font-size: 112.5%;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: "Iowan Old Style", Charter, Georgia, ui-serif, serif;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  hyphens: none;
  overflow-wrap: break-word;
}

body > header,
body > main,
body > footer {
  width: 100%;
  max-width: 42rem;
  margin-inline: auto;
  padding-inline: 1.5rem;
}
body > main { flex: 1 0 auto; padding-block: 1.5rem 2.5rem; }

body > header,
body > footer,
section > header h1,
section > h2,
section > ol time,
article > header time,
article > header h1,
article h2,
article h3,
article h4,
article figcaption,
article th,
article > nav {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

article code,
article pre {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--rule);
  transition: color 120ms ease, text-decoration-color 120ms ease;
}
a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

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

body > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  flex-wrap: nowrap;
  padding-block: 2.5rem;
  font-size: 0.95rem;
  min-width: 0;
}
body > header > a.site-title {
  font-family: "Iowan Old Style", Charter, Georgia, ui-serif, serif;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
  text-transform: uppercase;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body > header nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  flex-shrink: 0;
}
body > header nav a {
  color: var(--fg);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 4px;
}
body > header nav a svg {
  width: auto;
  height: 0.95rem;
  display: block;
}
body > header nav a:hover { color: var(--accent); }

@media (max-width: 32rem) {
  body > header nav a { width: 1.75rem; height: 1.75rem; }
  body > header nav a svg { height: 0.85rem; }
}

@media (max-width: 40rem) {
  body > header nav a[aria-label="X"],
  body > header nav a[aria-label="GitHub"] {
    display: none;
  }
}

body > footer {
  padding-block: 0 2.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
body > footer p {
  margin: 0;
  padding-top: 2.5rem;
  border-top: 1px solid var(--rule);
}

article > header {
  margin-bottom: 1.25rem;
  padding-bottom: 0;
}
section > header {
  margin-bottom: 4rem;
}
section > header h1,
article > header h1 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: pretty;
  margin: 0;
}
section > header h1 { font-size: 2rem; }
article > header h1 { font-size: 1.75rem; }
section.home > header p {
  color: var(--fg);
  font-size: 1.05rem;
  margin: 0.5rem 0 0;
  text-wrap: pretty;
  hyphens: none;
  max-width: none;
  width: 100%;
}
section.home > header p a {
  white-space: normal;
  overflow-wrap: break-word;
}
@media (max-width: 40rem) {
  section.home > header {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: max(1.5rem, env(safe-area-inset-left, 0px));
    padding-right: max(1.5rem, env(safe-area-inset-right, 0px));
    box-sizing: border-box;
  }
}
article > header time {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

section > h2 {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.5rem;
}
section > ol {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--rule);
}
section > ol li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}
section > ol li:last-child {
  border-bottom: 0;
}
section > ol a {
  font-size: 1.05rem;
  color: var(--fg);
  text-decoration: none;
  text-wrap: pretty;
}
section > ol a:hover { color: var(--accent); }

article h2,
article h3,
article h4 {
  letter-spacing: -0.01em;
  line-height: 1.25;
  text-wrap: balance;
  margin: 2.5rem 0 0.5rem;
}
article h2 { font-size: 1.5rem; font-weight: 700; }
article h3 { font-size: 1.2rem; font-weight: 600; }
article h4 { font-size: 1rem;   font-weight: 600; }

article p { margin: 0 0 1rem; }
article > p:first-of-type,
article > :first-child + p { margin-top: 0; }

article ul, article ol { padding-left: 1.35rem; margin: 0 0 1rem; }
article li + li { margin-top: 0.35rem; }
article li > ul, article li > ol { margin: 0.35rem 0 0; }

article blockquote {
  margin: 1.5rem 0;
  padding: 0 0 0 1rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
  font-style: italic;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
article blockquote p:last-child { margin-bottom: 0; }

article hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.5rem auto;
  width: 4rem;
}

article img {
  width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border-radius: 6px;
  background: var(--code-bg);
  image-rendering: smooth;
  image-rendering: high-quality;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 4px 16px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  article img {
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.04),
      0 2px 20px rgba(0, 0, 0, 0.5);
  }
}
article figure { margin: 1.5rem 0; }
article figure img { margin: 0; }
article figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
  text-align: center;
  text-wrap: pretty;
}

article code {
  font-size: 0.9em;
  background: var(--code-bg);
  border-radius: 3px;
  padding: 0.1em 0.35em;
}
article pre {
  font-size: 0.9rem;
  line-height: 1.55;
  background: var(--code-bg);
  border-radius: 6px;
  padding: 1rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  tab-size: 2;
}
article pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

:root {
  --syn-comment: #6a737d;
  --syn-keyword: #d73a49;
  --syn-string:  #032f62;
  --syn-number:  #005cc5;
  --syn-name:    #6f42c1;
  --syn-type:    #005cc5;
  --syn-tag:     #22863a;
  --syn-attr:    #6f42c1;
  --syn-error:   #b31d28;
}
@media (prefers-color-scheme: dark) {
  :root {
    --syn-comment: #8b949e;
    --syn-keyword: #ff7b72;
    --syn-string:  #a5d6ff;
    --syn-number:  #79c0ff;
    --syn-name:    #d2a8ff;
    --syn-type:    #79c0ff;
    --syn-tag:     #7ee787;
    --syn-attr:    #d2a8ff;
    --syn-error:   #ffa198;
  }
}

article .highlight,
article div.highlighter-rouge {
  background: var(--code-bg);
  border-radius: 6px;
  margin: 1.5rem 0;
}
article .highlight pre,
article div.highlighter-rouge pre {
  margin: 0;
  background: transparent;
}
article .highlight .c,  article .highlight .ch, article .highlight .cm,
article .highlight .cp, article .highlight .cpf, article .highlight .c1,
article .highlight .cs { color: var(--syn-comment); font-style: italic; }
article .highlight .k,  article .highlight .kc, article .highlight .kd,
article .highlight .kn, article .highlight .kp, article .highlight .kr,
article .highlight .kt, article .highlight .o,  article .highlight .ow { color: var(--syn-keyword); }
article .highlight .s,  article .highlight .sa, article .highlight .sb,
article .highlight .sc, article .highlight .dl, article .highlight .sd,
article .highlight .s2, article .highlight .se, article .highlight .sh,
article .highlight .si, article .highlight .sx, article .highlight .sr,
article .highlight .s1, article .highlight .ss { color: var(--syn-string); }
article .highlight .m,  article .highlight .mb, article .highlight .mf,
article .highlight .mh, article .highlight .mi, article .highlight .il,
article .highlight .mo { color: var(--syn-number); }
article .highlight .nb, article .highlight .bp,
article .highlight .nf, article .highlight .fm { color: var(--syn-name); }
article .highlight .nc, article .highlight .nn { color: var(--syn-type); }
article .highlight .nt { color: var(--syn-tag); }
article .highlight .na { color: var(--syn-attr); }
article .highlight .err { color: var(--syn-error); }
article .highlight .ge { font-style: italic; }
article .highlight .gs { font-weight: 600; }

article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 1.5rem 0;
  font-variant-numeric: tabular-nums;
}
article th,
article td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}
article th { font-weight: 600; }

article > nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.9rem;
}
article > nav a {
  display: block;
  text-decoration: none;
  color: var(--muted);
}
article > nav a:hover { color: var(--accent); }
article > nav a + a { text-align: right; }
article > nav small {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
article > nav span { color: var(--fg); }

@media (max-width: 560px) {
  html { font-size: 106.25%; }
  body > header { padding-block: 2rem; }
  body > main  { padding-block: 1rem 2rem; }

  section > header h1 { font-size: 1.6rem; }
  article > header h1 { font-size: 1.4rem; }

  article > nav { grid-template-columns: 1fr; }
  article > nav a + a { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  :root {
    --bg: #fff; --fg: #000; --muted: #444; --rule: #ccc;
    --accent: #000; --code-bg: #f5f5f5;
  }
  body > header nav,
  article > nav { display: none; }
  a { color: inherit; text-decoration: none; }
  article img { page-break-inside: avoid; }
}
