:root { --bg: #fff; --fg: #222; --muted: #777; --link: #0a58ca; color-scheme: light; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151515; --fg: #e6e6e6; --muted: #999; --link: #7db3ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151515; --fg: #e6e6e6; --muted: #999; --link: #7db3ff; color-scheme: dark;
}

#theme-toggle { background: none; border: 1px solid var(--muted); color: var(--fg);
  border-radius: 4px; cursor: pointer; padding: .1rem .5rem; font-size: 1rem; }

:root { --bg: #fff; --fg: #222; --muted: #777; --link: #0a58ca; }

body { background: var(--bg); color: var(--fg); font: 16px/1.6 system-ui, sans-serif; margin: 0; }
a { color: var(--link); }
	
.home-sidebar h2 { font-size: 1rem; margin-top: 0; }
.home-sidebar section + section { margin-top: 1rem; }

.home-sidebar .post-list li { margin-bottom: .6rem; 
			      font-size: .85em;
			      line-height: 1.0;}
			      
.home-sidebar .date { display: block; margin-left: 0; }

.home-sidebar .post-list a { font-size: 1; }
.home-sidebar .post-list .date { font-size: .75em; margin-top: 0.5em; }

main { margin: 0 0 0 10px; padding: 1rem;}

@media (min-width: 1200px) {
main { max-width: 75%; /*margin: 0 16%;*/ padding: 1rem; }
}

.home main, .home .top-nav { margin: 0 0; max-width: 100%; }

.top-nav { max-width: 100%; padding: 1rem; display: flex; gap: 1.25rem; align-items: baseline; }

.top-nav .site-title { font-weight: bold; margin-right: auto; text-decoration: none; }
.meta, .date { color: var(--muted); font-size: .9em; }
.date { margin-left: .5rem; }
.post-list { list-style: none; padding: 0; }
.columns-wrapper { display: flex; gap: 2rem; flex-wrap: wrap; }
.columns-wrapper .column { flex: 1 1 280px; }
img { max-width: 100%; height: auto; }

.img-figure { margin: 1.5rem 0; width: fit-content; }
.img-figure img { display: block; max-width: 100%; height: auto; }
.img-figure figcaption {
  text-align: center; margin-top: .4rem; font-size: .85rem; line-height: 1.4; color: var(--muted);
}

.img-figure.align-left   { float: left;  margin: .25rem 1.5rem 1rem 1rem; }
.img-figure.align-right  { float: right; margin: .25rem 1rem 1rem 1.5rem; }
.img-figure.align-center { margin: 1.5rem auto; }

.video-figure { display: block; width: fit-content; max-width: 100%; margin: 1.5rem auto; }
.video-figure video { display: block; max-width: 100%; height: auto; }
.video-caption { display: block; margin-top: .4rem; font-size: .85rem; line-height: 1.4; color: var(--muted); }
.video-caption { text-align: center; }

article h2, article h3, article pre, .post-nav { clear: both; }
article, .intro-text { display: flow-root; }

.intro-text { max-width: 46rem; }   /* keep the blurb at a readable line length */

.home-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem 2.5rem;
  margin-top: 2.5rem; padding-top: 1.5rem;
  border-top: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
}
.home-columns h2 { font-size: 1.05rem; margin-top: 0; }

.home-layout { display: grid; grid-template-columns: 1fr; gap: 2rem; }

@media (min-width: 800px) {
  .home-layout { grid-template-columns: 260px minmax(0, 1fr); gap: 2.5rem; }
  .home-sidebar { order: -1; }   /* sidebar on the left */
}

.home-sidebar h2 { font-size: 1.05rem; margin-top: 0; }

.home-sidebar .post-list li,
.home-columns .post-list li { margin-bottom: .6rem; font-size: .85em; line-height: 1.3; }
.home-sidebar .date,
.home-columns .date { display: block; margin-left: 0; }

@media (max-width: 600px) {
  .img-figure.align-left, .img-figure.align-right { float: none; margin: 1rem auto; }
}

pre { overflow-x: auto; padding: 1rem; background: color-mix(in srgb, var(--fg) 8%, transparent); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: baseline; margin: 1.5rem 0; }
.tag-cloud a { text-decoration: none; }
.tag-cloud a:hover { text-decoration: underline; }
.tag-cloud.compact { font-size: .85rem; gap: .25rem .75rem; }
.tag-cloud.compact a { opacity: .8; }
.tag-cloud .more { opacity: .6; }

.toc { display: none; }

@media (min-width: 1200px) {
  .toc {
    display: block;
    position: fixed;
    top: 5rem;
    left: calc(50% + 380px);
    width: 220px;
    font-size: .85rem;
    color: var(--muted);
    border-left: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
    padding-left: 0.5rem;
    height: 100%;
  }
  .toc ul { list-style: none; padding-left: .75rem; }
  .toc > nav > ul { padding-left: 0; }
  .toc a { text-decoration: none; }
}

.post-meta { display: none; }

@media (min-width: 800px) {
  .post-layout { grid-template-columns: 180px minmax(0, 1fr); gap: 2.5rem; }
  .post-meta {
    display: block;
    position: sticky; top: 5rem; align-self: start;
    max-height: calc(100vh - 6.5rem); overflow-y: auto;
  }
}

.post-layout {display: grid; gap: 1.5rem; }

.post-meta {
  font-size: .85rem;
  color: var(--muted);
  top: 5rem;
  left: 1rem;
}

.meta-item { margin-bottom: 1.25rem; }
.meta-item .label {
  display: block; margin-bottom: .25rem;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
}

.meta-item ul { list-style: none; padding: 0; margin: 0; }
.meta-item li { margin-bottom: .2rem; }
.meta-item.toc { display: none; }

.post-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 3rem; padding-top: 1rem; font-size: .9rem;
  border-top: 1px solid color-mix(in srgb, var(--fg) 15%, transparent);
}
.post-nav a { text-decoration: none; }
.post-nav .newer { margin-left: auto; text-align: right; }

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

.nav-title {
  flex: 1 1 0; min-width: 0;
  text-align: center;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  opacity: 0; transform: translateY(.4rem);
  transition: opacity .2s, transform .2s;
}
.show-title .nav-title { opacity: 1; transform: none; }
@media (max-width: 700px) { .nav-title { display: none; } }

html { scroll-padding-top: 5rem; }

.post-list-detailed li {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: .15rem 1rem; margin-bottom: .85rem;
}
.post-list-detailed .snippet { flex: 1 1 14rem; color: var(--muted); font-size: .9em; }
.post-list-detailed .date { margin-left: auto; white-space: nowrap; }

.post-list-detailed .snippet { overflow-wrap: anywhere; }

@media (max-width: 600px) {
  .post-list-detailed .date { order: 2; }
  .post-list-detailed .snippet { order: 3; flex-basis: 100%; }
}
pre.mono {
  overflow-x: auto; padding: 1rem; line-height: 1.4; font-size: .9em;
  font-family: Consolas, monospace;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
}

.c-red   { color: #c62828; color: light-dark(#c62828, #ff7b7b); }
.c-blue  { color: #1565c0; color: light-dark(#1565c0, #7db3ff); }
.c-green { color: #15c028; color: light-dark(#15c028, #7dff7b); }

a.lightbox { cursor: zoom-in; }

#lightbox {
  border: none; padding: 0; background: transparent;
  max-width: 96vw; max-height: 96vh; overflow: visible;
}
#lightbox::backdrop { background: rgba(0, 0, 0, .85); }
#lightbox img {
  display: block; max-width: 96vw; max-height: 96vh;
  object-fit: contain; cursor: zoom-out;
}

html:has(dialog[open]) { overflow: hidden; }
