/* === Zed Mono Extended === */

@font-face {
  font-family: "Zed Mono Extended";
  src: url("/fonts/zed-mono-extended.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-stretch: 125%;
  font-display: swap;
}

@font-face {
  font-family: "Zed Mono Extended";
  src: url("/fonts/zed-mono-extendedbold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-stretch: 125%;
  font-display: swap;
}

/* =============================================================
   doom-flatwhite (light) — known for colored background tints
   ============================================================= */
[data-theme="light"] {
  /* base grayscale */
  --bg: #f7f3ee;
  --bg-alt: #f1ece4;
  --fg: #605a52;
  --fg-dim: #93836c;
  --fg-faint: #b9a992;
  --border: #dcd3c6;

  /* accent */
  --accent: #6a4dff;

  /* flatwhite colored backgrounds + text pairs */
  --purple-text: #614c61;
  --purple-blend: #f1ddf1;
  --green-text: #525643;
  --green-blend: #e2e9c1;
  --orange-text: #5b5143;
  --orange-blend: #f7e0c3;
  --blue-text: #4c5361;
  --blue-blend: #dde4f2;
  --teal-text: #465953;
  --teal-blend: #d2ebe3;
  --red-text: #5b4343;
  --red-blend: #f6cfcb;

  /* bright versions for interactive elements */
  --purple-bright: #ce5cff;
  --green-bright: #84bd00;
  --orange-bright: #f08c00;
  --blue-bright: #75a3ff;
  --teal-bright: #00bda4;
  --red-bright: #f00000;

  /* semantic mappings */
  --heading-color: #614c61;
  --heading-h2-bg: #f1ddf1;
  --heading-h3-color: #4c5361;
  --heading-h3-bg: #dde4f2;

  --link: #4c5361;
  --link-hover: #465953;

  --code-fg: #465953;
  --code-bg: #d2ebe3;
  --code-border: transparent;
  --pre-bg: #f1ece4;
  --pre-border: #dcd3c6;

  --badge-fg: #525643;
  --badge-bg: #e2e9c1;
  --badge-border: transparent;
  --badge-hover-bg: #d6dfb0;

  --marker-color: #5b5143;
  --time-color: #465953;
  --blockquote-border: #dde4f2;
  --blockquote-color: #4c5361;
  --blockquote-bg: rgba(221,228,242,0.3);

  --nav-color: #93836c;
  --nav-hover: #614c61;
  --nav-active: #614c61;

  --title-color: #605a52;

  --social-color: #93836c;
  --social-hover: #614c61;

  --statusbar-bg: #e4ddd2;
  --statusbar-fg: #605a52;
  --statusbar-mode-bg: #525643;
  --statusbar-mode-fg: #f7f3ee;

  --hr-color: #dcd3c6;
  --th-color: #5b5143;
  --td-border: #f1ece4;

  --toggle-color: #93836c;
  --toggle-hover: #614c61;
  --toggle-border: #dcd3c6;

  --strong-color: #605a52;
  --em-color: #614c61;
}

/* =============================================================
   doom-gruvbox (dark) — warm retro palette, many distinct colors
   ============================================================= */
[data-theme="dark"] {
  /* base */
  --bg: #282828;
  --bg-alt: #1d2021;
  --fg: #ebdbb2;
  --fg-dim: #928374;
  --fg-faint: #504945;
  --border: #3c3836;

  /* gruvbox colors */
  --red: #fb4934;
  --orange: #fe8019;
  --yellow: #fabd2f;
  --green: #b8bb26;
  --teal: #8ec07c;
  --blue: #83a598;
  --purple: #d3869b;
  --magenta: #b16286;
  --dark-yellow: #d79921;
  --dark-green: #98971a;
  --dark-blue: #458588;
  --dark-cyan: #689d6a;

  /* semantic mappings */
  --accent: #fabd2f;

  --heading-color: #fabd2f;
  --heading-h2-bg: transparent;
  --heading-h3-color: #fe8019;
  --heading-h3-bg: transparent;

  --link: #83a598;
  --link-hover: #fabd2f;

  --code-fg: #fe8019;
  --code-bg: rgba(254,128,25,0.1);
  --code-border: rgba(254,128,25,0.2);
  --pre-bg: #1d2021;
  --pre-border: #3c3836;

  --badge-fg: #b8bb26;
  --badge-bg: rgba(184,187,38,0.12);
  --badge-border: rgba(184,187,38,0.25);
  --badge-hover-bg: rgba(184,187,38,0.22);

  --marker-color: #fb4934;
  --time-color: #d3869b;
  --blockquote-border: #83a598;
  --blockquote-color: #928374;
  --blockquote-bg: transparent;

  --nav-color: #928374;
  --nav-hover: #fabd2f;
  --nav-active: #fabd2f;

  --title-color: #fabd2f;

  --social-color: #928374;
  --social-hover: #fe8019;

  --statusbar-bg: #3c3836;
  --statusbar-fg: #ebdbb2;
  --statusbar-mode-bg: #b8bb26;
  --statusbar-mode-fg: #282828;

  --hr-color: #504945;
  --th-color: #fabd2f;
  --td-border: #3c3836;

  --toggle-color: #928374;
  --toggle-hover: #fabd2f;
  --toggle-border: #504945;

  --strong-color: #fbf1c7;
  --em-color: #d3869b;
}

/* === Chroma syntax highlighting (dark: gruvbox) === */

[data-theme="dark"] .chroma { color: #ebdbb2; background: var(--pre-bg); }
[data-theme="dark"] .chroma .hl { background-color: #3d3d3d; }
[data-theme="dark"] .chroma .lnt,
[data-theme="dark"] .chroma .ln { color: #756d59; }
[data-theme="dark"] .chroma .k,
[data-theme="dark"] .chroma .kc,
[data-theme="dark"] .chroma .kd,
[data-theme="dark"] .chroma .kn,
[data-theme="dark"] .chroma .kp,
[data-theme="dark"] .chroma .kr { color: #fe8019; }
[data-theme="dark"] .chroma .kt { color: #fabd2f; }
[data-theme="dark"] .chroma .na { color: #b8bb26; font-weight: bold; }
[data-theme="dark"] .chroma .nb,
[data-theme="dark"] .chroma .bp,
[data-theme="dark"] .chroma .nf,
[data-theme="dark"] .chroma .fm,
[data-theme="dark"] .chroma .ni { color: #fabd2f; }
[data-theme="dark"] .chroma .no { color: #d3869b; }
[data-theme="dark"] .chroma .ne,
[data-theme="dark"] .chroma .nl,
[data-theme="dark"] .chroma .nt { color: #fb4934; }
[data-theme="dark"] .chroma .s,
[data-theme="dark"] .chroma .sa,
[data-theme="dark"] .chroma .sb,
[data-theme="dark"] .chroma .sc,
[data-theme="dark"] .chroma .dl,
[data-theme="dark"] .chroma .sd,
[data-theme="dark"] .chroma .s2,
[data-theme="dark"] .chroma .se,
[data-theme="dark"] .chroma .sh,
[data-theme="dark"] .chroma .si,
[data-theme="dark"] .chroma .sx,
[data-theme="dark"] .chroma .sr,
[data-theme="dark"] .chroma .s1 { color: #b8bb26; }
[data-theme="dark"] .chroma .ss { color: #83a598; }
[data-theme="dark"] .chroma .m,
[data-theme="dark"] .chroma .mb,
[data-theme="dark"] .chroma .mf,
[data-theme="dark"] .chroma .mh,
[data-theme="dark"] .chroma .mi,
[data-theme="dark"] .chroma .il,
[data-theme="dark"] .chroma .mo { color: #d3869b; }
[data-theme="dark"] .chroma .o,
[data-theme="dark"] .chroma .ow { color: #fe8019; }
[data-theme="dark"] .chroma .c,
[data-theme="dark"] .chroma .ch,
[data-theme="dark"] .chroma .cm,
[data-theme="dark"] .chroma .c1,
[data-theme="dark"] .chroma .cs { color: #928374; font-style: italic; }
[data-theme="dark"] .chroma .cp,
[data-theme="dark"] .chroma .cpf { color: #8ec07c; }
[data-theme="dark"] .chroma .gd { color: #282828; background-color: #fb4934; }
[data-theme="dark"] .chroma .gi { color: #282828; background-color: #b8bb26; }
[data-theme="dark"] .chroma .ge { color: #83a598; text-decoration: underline; }
[data-theme="dark"] .chroma .gh,
[data-theme="dark"] .chroma .gu { color: #b8bb26; font-weight: bold; }

/* === Chroma syntax highlighting (light: flatwhite) === */

[data-theme="light"] .chroma { color: #605a52; background: var(--pre-bg); }
[data-theme="light"] .chroma .hl { background-color: #e4ddd2; }
[data-theme="light"] .chroma .lnt,
[data-theme="light"] .chroma .ln { color: #b9a992; }
[data-theme="light"] .chroma .k,
[data-theme="light"] .chroma .kc,
[data-theme="light"] .chroma .kd,
[data-theme="light"] .chroma .kn,
[data-theme="light"] .chroma .kp,
[data-theme="light"] .chroma .kr { color: #9a3d7a; }
[data-theme="light"] .chroma .kt { color: #7b59a0; }
[data-theme="light"] .chroma .na { color: #5a7a20; font-weight: bold; }
[data-theme="light"] .chroma .nb,
[data-theme="light"] .chroma .bp { color: #7b59a0; }
[data-theme="light"] .chroma .nf,
[data-theme="light"] .chroma .fm { color: #3568b8; }
[data-theme="light"] .chroma .ni { color: #b07800; }
[data-theme="light"] .chroma .no { color: #b07800; }
[data-theme="light"] .chroma .ne,
[data-theme="light"] .chroma .nl,
[data-theme="light"] .chroma .nt { color: #b34040; }
[data-theme="light"] .chroma .s,
[data-theme="light"] .chroma .sa,
[data-theme="light"] .chroma .sb,
[data-theme="light"] .chroma .sc,
[data-theme="light"] .chroma .dl,
[data-theme="light"] .chroma .sd,
[data-theme="light"] .chroma .s2,
[data-theme="light"] .chroma .se,
[data-theme="light"] .chroma .sh,
[data-theme="light"] .chroma .si,
[data-theme="light"] .chroma .sx,
[data-theme="light"] .chroma .sr,
[data-theme="light"] .chroma .s1 { color: #5a7a20; }
[data-theme="light"] .chroma .ss { color: #1a8a6a; }
[data-theme="light"] .chroma .m,
[data-theme="light"] .chroma .mb,
[data-theme="light"] .chroma .mf,
[data-theme="light"] .chroma .mh,
[data-theme="light"] .chroma .mi,
[data-theme="light"] .chroma .il,
[data-theme="light"] .chroma .mo { color: #3568b8; }
[data-theme="light"] .chroma .o,
[data-theme="light"] .chroma .ow { color: #b07800; }
[data-theme="light"] .chroma .c,
[data-theme="light"] .chroma .ch,
[data-theme="light"] .chroma .cm,
[data-theme="light"] .chroma .c1,
[data-theme="light"] .chroma .cs { color: #93836c; font-style: italic; }
[data-theme="light"] .chroma .cp,
[data-theme="light"] .chroma .cpf { color: #1a8a6a; }
[data-theme="light"] .chroma .gd { color: #b34040; background-color: #f6cfcb; }
[data-theme="light"] .chroma .gi { color: #5a7a20; background-color: #e2e9c1; }
[data-theme="light"] .chroma .ge { color: #3568b8; text-decoration: underline; }
[data-theme="light"] .chroma .gh,
[data-theme="light"] .chroma .gu { color: #9a3d7a; font-weight: bold; }

/* === highlight.js — TLA+ only === */

[data-theme="dark"] .hljs-keyword  { color: #fabd2f; }
[data-theme="dark"] .hljs-literal  { color: #fe8019; }
[data-theme="dark"] .hljs-built_in { color: #8ec07c; }
[data-theme="dark"] .hljs-string   { color: #b8bb26; }
[data-theme="dark"] .hljs-number   { color: #d3869b; }
[data-theme="dark"] .hljs-comment  { color: #928374; font-style: italic; }
[data-theme="dark"] .hljs-operator { color: #fe8019; }
[data-theme="dark"] .hljs-title    { color: #83a598; }
[data-theme="dark"] .hljs-punctuation { color: #928374; }

[data-theme="light"] .hljs-keyword  { color: #9a3d7a; }
[data-theme="light"] .hljs-literal  { color: #b07800; }
[data-theme="light"] .hljs-built_in { color: #1a8a6a; }
[data-theme="light"] .hljs-string   { color: #5a7a20; }
[data-theme="light"] .hljs-number   { color: #3568b8; }
[data-theme="light"] .hljs-comment  { color: #93836c; font-style: italic; }
[data-theme="light"] .hljs-operator { color: #b07800; }
[data-theme="light"] .hljs-title    { color: #3568b8; }
[data-theme="light"] .hljs-punctuation { color: #93836c; }

/* === Reset === */

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

/* === Base === */

html {
  font-family: "Zed Mono Extended", "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;
  font-stretch: 125%;
  line-height: 1.45;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

body {
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.15s, color 0.15s;
  padding-bottom: 1.75rem;
  overflow-x: clip;
}

/* === Layout === */

.container {
  width: 90%;
  max-width: min(90%, 78ch);
  margin: 0 auto;
}

main {
  flex: 1;
  min-width: 0;
  padding-bottom: 2rem;
}

/* === Header === */

.site-header {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
  margin-bottom: 2rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  margin-top: 0.25rem;
}

.site-title {
  font-size: 1.75rem;
  font-weight: bold;
  color: var(--title-color);
  letter-spacing: -1px;
}

.site-title::before {
  content: "~ ";
  color: var(--fg-dim);
  font-weight: normal;
}

.site-title a {
  color: inherit;
}

.site-description {
  font-size: 0.9375rem;
  font-weight: normal;
  color: var(--fg-dim);
  margin: 0.2rem 0 0;
}

/* Social links */

.social-links {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.social-links .btn {
  color: var(--social-color);
  transition: color 0.2s, transform 0.2s;
}

.social-links .btn:hover {
  color: var(--social-hover);
  transform: translateY(-1px);
}

/* Theme toggle */

.theme-toggle {
  background: none;
  border: 1px solid var(--toggle-border);
  color: var(--toggle-color);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.1em 0.4em;
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  line-height: 1.3;
}

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

/* Lang switcher */

.lang-link {
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--fg-dim);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: color 0.2s;
}

.lang-link:hover {
  color: var(--accent);
}

/* Site nav */

.site-nav {
  margin-top: 0.75rem;
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  color: var(--nav-color);
  text-decoration: none;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--nav-hover);
}

.nav-link.active {
  color: var(--nav-active);
}

/* === Headings === */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  font-family: inherit;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: 1.75rem;
  color: var(--heading-color);
}

h2 {
  font-size: 1.375rem;
  margin-top: 2rem;
  color: var(--heading-color);
  background: var(--heading-h2-bg);
  padding: 0.15em 0.4em;
  margin-left: -0.4em;
  margin-right: -0.4em;
  border-radius: 3px;
  width: fit-content;
}

.content > h2:first-child { margin-top: 0; }

h3 {
  font-size: 1.125rem;
  margin-top: 1.5rem;
  color: var(--heading-h3-color);
  background: var(--heading-h3-bg);
  padding: 0.1em 0.3em;
  margin-left: -0.3em;
  border-radius: 3px;
  width: fit-content;
}

/* === Typography === */

strong {
  color: var(--strong-color);
  font-weight: 600;
}

em {
  color: var(--em-color);
}

/* Dates rendered as <em> after h3 headings (e.g. "2024 — present") */
h3 + p > em:only-child {
  color: var(--fg-dim);
  font-style: normal;
  font-size: 0.875rem;
}

/* === Content === */

.content {
  margin-bottom: 2rem;
}

p {
  margin-bottom: 0.75rem;
}

/* === Lists === */

ul {
  list-style: none;
  padding-left: 2em;
}

ul li {
  line-height: 1.5;
  margin-bottom: 0.2rem;
}

ul li::before {
  content: "--";
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--marker-color);
  margin-left: -2em;
  margin-right: 0.75rem;
  display: inline-block;
  width: 1.25em;
}

ol {
  padding-left: 2em;
}

ol li {
  line-height: 1.5;
  margin-bottom: 0.2rem;
}

ol li::marker {
  color: var(--marker-color);
  font-size: 0.875rem;
}

/* === Links === */

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  transition: color 0.2s;
}

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

/* UI links — no underline */
.site-header a,
.vim-statusbar a {
  text-decoration: none;
}

/* === Post list === */

.post-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.post-list time,
.recent-posts time {
  color: var(--time-color);
  font-size: 0.875rem;
  white-space: nowrap;
}

/* === Post === */

.post-header {
  margin-bottom: 1.5rem;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: 0.875rem;
  color: var(--fg-dim);
}

.post-meta time {
  color: var(--time-color);
}

.post-updated {
  color: var(--fg-dim);
}

.post-reading-time {
  color: var(--fg-faint);
}

.post-content {
  line-height: 1.45;
}

.post-content p {
  margin-bottom: 0.75rem;
}

/* === Code === */

.highlight {
  position: relative;
}

.code-copy {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--fg-faint);
  font-family: inherit;
  font-size: 0.75rem;
  padding: 0.1em 0.4em;
  border-radius: 3px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.highlight:hover .code-copy {
  opacity: 1;
}

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

.code-copy.copied {
  color: var(--accent);
}

pre {
  background: var(--pre-bg);
  border: 1px solid var(--pre-border);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--fg);
  border-radius: 3px;
  overflow-x: auto;
  margin-bottom: 0.75rem;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
  white-space: pre;
}

code {
  font-family: inherit;
  font-size: 0.9em;
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--code-border);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  overflow-wrap: break-word;
}

/* === Tech badges === */

.tech-badges {
  margin-top: 0.5rem;
}

.tech-badge {
  display: inline-block;
  font-family: inherit;
  font-size: 0.8125rem;
  background: var(--badge-bg);
  color: var(--badge-fg);
  border: 1px solid var(--badge-border);
  padding: 0.15em 0.5em;
  border-radius: 3px;
  margin: 0.15em 0.15em;
  white-space: nowrap;
  transition: background 0.2s;
}

.tech-badge:hover {
  background: var(--badge-hover-bg);
}

.tech-badge i {
  font-size: 0.875rem;
  vertical-align: middle;
  margin-right: 0.15em;
}

/* === Blockquote === */

blockquote {
  color: var(--blockquote-color);
  background: var(--blockquote-bg);
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--blockquote-border);
  border-radius: 0 3px 3px 0;
  margin-bottom: 0.75rem;
}

/* === Table === */

.post-content table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 0.875rem;
}

table {
  width: 100%;
  margin-bottom: 1rem;
}

th {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 0.3rem 0.6rem;
  color: var(--th-color);
}

td {
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--td-border);
}

/* === HR === */

hr {
  height: 0;
  border: 0;
  border-bottom: 1px solid var(--hr-color);
  margin: 1.25rem 0;
}

/* === Vim Statusbar (footer) === */

.vim-statusbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--statusbar-bg);
  color: var(--statusbar-fg);
  font-family: inherit;
  font-size: 0.8125rem;
  display: flex;
  align-items: stretch;
  z-index: 100;
  height: 1.75rem;
  border-top: 1px solid var(--border);
}

.vim-statusbar > span {
  display: flex;
  align-items: center;
  padding: 0 0.6em;
  white-space: nowrap;
}

.vim-statusbar .mode {
  background: var(--statusbar-mode-bg);
  color: var(--statusbar-mode-fg);
  font-weight: bold;
  padding: 0 0.75em;
  letter-spacing: 0.5px;
}

.vim-statusbar .sep {
  color: var(--fg-faint);
  padding: 0 0.2em;
}

.vim-statusbar .spacer {
  flex: 1;
}

.vim-statusbar .pos {
  color: var(--fg-dim);
}

/* === TOC inline (narrow screens) === */

.toc-inline {
  margin-bottom: 2rem;
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
}

.toc-inline summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--heading-color);
  font-size: 0.9375rem;
  margin-bottom: 0.5rem;
}

.toc-inline nav > ul,
.toc-inline > details > nav > ul {
  padding-left: 0;
}

.toc-inline ul {
  padding-left: 1.5em;
}

.toc-inline li {
  margin-bottom: 0.15rem;
  line-height: 1.4;
}

.toc-inline li::before {
  content: none;
}

.toc-inline a {
  color: var(--fg);
  text-decoration: none;
  font-size: 0.875rem;
}

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

/* === TOC sidebar (wide screens) === */

.toc-sidebar {
  display: none;
}

.toc-tree ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-tree li {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 0.85;
}

.toc-tree li::before {
  content: none;
}

.toc-tree .tree-marker {
  color: var(--fg-faint);
  margin-right: 0.5ch;
  font-size: 0.75rem;
}

.toc-tree a {
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 0.75rem;
}

.toc-tree a.toc-active {
  color: var(--fg);
}

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

/* Collapse h3 items by default, expand for active section */
.toc-tree ul ul {
  padding-left: 2ch;
  display: none;
}

.toc-tree li.toc-expand > ul {
  display: block;
}

.toc-toggle {
  display: none;
}

@media (min-width: 1200px) {
  .toc-inline {
    display: none;
  }

  .toc-sidebar {
    display: block;
    position: fixed;
    top: 2rem;
    right: 1.5rem;
    max-width: calc((100vw - 78ch) / 2 - 3rem);
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    overflow-x: hidden;
  }

  .toc-toggle {
    display: block;
    background: none;
    border: none;
    color: var(--fg-faint);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0;
    margin-bottom: 0.5rem;
    margin-left: auto;
    transition: color 0.15s;
  }

  .toc-toggle:hover {
    color: var(--fg-dim);
  }

  .toc-sidebar.collapsed .toc-tree {
    display: none;
  }

  .toc-sidebar.collapsed {
    overflow: hidden;
  }
}

/* === Heading anchors === */

.post-content h2,
.post-content h3 {
  position: relative;
}

.heading-anchor {
  color: var(--fg-faint);
  text-decoration: none;
  margin-left: 0.3em;
  opacity: 0;
  transition: opacity 0.15s;
  font-weight: normal;
}

.post-content h2:hover .heading-anchor,
.post-content h3:hover .heading-anchor,
.heading-anchor:focus {
  opacity: 1;
}

.heading-anchor:hover {
  color: var(--accent);
}

/* === Responsive === */

@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  .post-content table {
    font-size: 0.8125rem;
  }
}

@media (max-width: 600px) {
  .site-title {
    font-size: 1.375rem;
  }

  .site-description {
    font-size: 0.875rem;
  }

  .post-list li {
    flex-direction: column;
    gap: 0;
  }

  .vim-statusbar {
    font-size: 0.75rem;
  }

  .vim-statusbar .file-path {
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* === Print === */

@media print {
  /* Force readable colors */
  html, body {
    background: #fff !important;
    color: #222 !important;
    font-size: 12pt;
  }

  /* Hide UI chrome */
  .site-header,
  .vim-statusbar,
  .toc-sidebar,
  .toc-inline,
  .theme-toggle,
  .heading-anchor,
  .code-copy {
    display: none !important;
  }

  /* Reset layout */
  body {
    padding-bottom: 0;
  }

  .container {
    width: 100%;
    max-width: none;
  }

  /* Typography for print */
  h1, h2, h3 {
    color: #000 !important;
    background: none !important;
    break-after: avoid;
  }

  h2, h3 {
    margin-left: 0;
  }

  a {
    color: #222 !important;
    text-decoration: underline;
  }

  /* Show link URLs */
  .post-content a[href^="http"]::after {
    content: " [" attr(href) "]";
    font-size: 0.8em;
    color: #666;
    word-break: break-all;
  }

  /* Code blocks: no overflow, wrap instead */
  pre {
    background: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    color: #222 !important;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: visible;
  }

  pre code, code {
    color: #222 !important;
    background: #f0f0f0 !important;
    border-color: #ddd !important;
  }

  /* Chroma: strip all coloring */
  .chroma, .chroma span {
    color: #222 !important;
    background: none !important;
  }

  /* Tables */
  table, th, td {
    border: 1px solid #999 !important;
    color: #222 !important;
  }

  .post-content table {
    font-size: inherit;
  }

  /* Keep content together */
  pre, blockquote, table, img {
    break-inside: avoid;
  }

  /* Badges readable */
  .tech-badge {
    background: none !important;
    border: 1px solid #999 !important;
    color: #222 !important;
  }

  /* Blockquotes */
  blockquote {
    color: #444 !important;
    border-left-color: #999 !important;
    background: none !important;
  }

  strong { color: #000 !important; }
  em { color: #222 !important; }
}
