:root { color-scheme: dark; --muted-readable: #b8b8b8; }
body { margin: 0; }
.page { max-width: 76rem; padding: 1.5rem; gap: 2rem; }
.page__body { min-width: 0; }
.page__aside { position: static; max-height: none; overflow: visible; }
@media (min-width: 52rem) {
  .page { grid-template-areas: "header header" "body aside" "footer footer"; grid-template-columns: minmax(0, 1fr) 15rem; gap: 3rem; }
}
@media (max-width: 51.99rem) {
  .page { grid-template-areas: "header" "body" "aside" "footer"; grid-template-columns: minmax(0, 1fr); }
}
h1 { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.25; margin-bottom: 1rem; }
h2 { font-size: 1.25rem; line-height: 1.4; margin: 2rem 0 .8rem; }
h3 { font-size: 1.05rem; line-height: 1.5; margin: 1.5rem 0 .6rem; }
h4, h5, h6 { margin-bottom: .5rem; }
h1::before, h2::before, h3::before, h4::before, h5::before, h6::before { content: none; }
.content__body { line-height: 1.75; }
.content__body p, .content__body ul, .content__body ol { margin-bottom: 1.25rem; }
.content__body li + li { margin-top: .3rem; }
.content__body h2, .content__body h3 { scroll-margin-top: 1rem; }
a { text-underline-offset: .2em; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--hover); outline-offset: 4px; }
.heading-anchor { font-size: .85em; color: var(--muted-readable); }
.main-nav ul { gap: .75rem 1.5rem; }
.main-nav .page__logo { font-size: 1.25rem; font-weight: bold; margin-right: auto; }
.main-nav li { text-transform: none; }
.main-nav li::marker { content: none; }
.main-nav a[aria-current="page"] { color: var(--hover); text-decoration-thickness: 3px; }
.aside-title { font-weight: bold; font-size: 1.15rem; }
.post-meta, .code-controls { color: var(--muted-readable); font-size: .85rem; line-height: 1.6; }
.post-card { padding: 1.25rem 0; border-bottom: 1px solid var(--muted); }
.post-card h2 { margin: 0 0 .4rem; font-size: 1.1rem; }
.post-card p { margin: .35rem 0; }
.lede { color: var(--fg); }
.terms { display: flex; flex-wrap: wrap; gap: .5rem; }
.terms a { padding: .15rem .5rem; background: var(--inner-bg); font-size: .8rem; border-radius: .2rem; }
.notice { border-left: 3px solid var(--highlight); padding: 1rem; background: var(--inner-bg); margin: 1.5rem 0; }
.notice p:last-child { margin-bottom: 0; }
.toc { border: 1px solid var(--muted); padding: 1rem; margin: 1.5rem 0; }
summary { cursor: pointer; font-weight: bold; }
.toc nav { margin-top: 1rem; }
.toc ol { margin-bottom: 0; }
.article-footer { border-top: 1px solid var(--muted); margin-top: 2rem; padding-top: 1rem; }
.topic-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 1rem; }
.topic-grid li { padding: 1rem; border: 1px solid var(--muted); }
.topic-grid li::marker { content: none; }
.topic-grid p { margin: .5rem 0 0; font-size: .85rem; }
.topic-list { columns: 2 12rem; }
.pagination { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; margin: 2rem 0; }
.search-form { margin: 1.5rem 0; }
.search-form label { display: block; margin-bottom: .5rem; }
.search-controls { display: flex; flex-wrap: wrap; gap: .5rem; }
input, button { font: inherit; color: var(--fg); border: 1px solid var(--muted-readable); border-radius: .2rem; background: var(--inner-bg); padding: .65rem; }
input[type="search"] { flex: 1 1 12rem; min-width: 0; }
button { cursor: pointer; }
button:hover { border-color: var(--hover); }
.code-example { margin: 1.5rem 0; }
.code-controls { display: flex; align-items: center; justify-content: space-between; padding: .35rem .75rem; background: var(--bg); }
.code-controls button { padding: .2rem .6rem; font-size: .8rem; }
.code-example pre { margin: 0; }
pre { padding: 1rem; line-height: 1.6; font-size: .85rem; }
:not(pre) > code { overflow-wrap: anywhere; }
.table-scroll { overflow-x: auto; margin-bottom: 1.5rem; }
th, td { padding: .5rem .75rem; border-bottom: 1px solid var(--muted); }
.content__body img { display: block; margin: 1rem auto; }
.skip-link { position: fixed; top: -10rem; left: 1rem; padding: 1rem; background: var(--bg); z-index: 10; }
.skip-link:focus { top: 1rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media print {
  .page { display: block; padding: 0; }
  .page__header, .page__aside, .page__footer, .code-controls, .search-form, .heading-anchor, .article-footer { display: none; }
  body, .page__body { color: #000; background: #fff; box-shadow: none; }
  pre, code { white-space: pre-wrap; color: #000; background: #eee !important; }
  .toc:not([open]) { display: none; }
}

/* Keep the full desktop navigation; provide a compact native disclosure on phones. */
.mobile-nav, .mobile-intro, .mobile-article-tags { display: none; }
.article-tags { display: contents; }
.home-content { display: flex; flex-direction: column; }
.code-controls { gap: .5rem; flex-wrap: wrap; }
.code-scroll-hint { font-size: .75rem; margin-left: auto; }
.code-controls button { min-height: 44px; min-width: 60px; }

@media screen and (max-width: 51.99rem) {
  .page { padding: 0 1rem 1.5rem; margin-top: 0; gap: 1.25rem; }
  .page__header { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: .35rem 0; }
  .desktop-nav { display: none; }
  .mobile-nav { display: flex; align-items: center; gap: .5rem; width: 100%; position: relative; }
  .mobile-nav > a, .mobile-menu summary { display: flex; align-items: center; justify-content: center; min-height: 44px; box-sizing: border-box; padding: .4rem .5rem; }
  .mobile-nav .mobile-brand { font-size: 1.1rem; font-weight: bold; margin-right: auto; padding-left: 0; }
  .mobile-menu summary { cursor: pointer; border: 1px solid var(--muted-readable); border-radius: .2rem; font-weight: normal; list-style: none; }
  .mobile-menu summary::-webkit-details-marker { display: none; }
  .mobile-menu summary::after { content: ' ▾'; margin-left: .3rem; }
  .mobile-menu[open] summary::after { content: ' ▴'; }
  .mobile-menu ul { position: absolute; right: 0; top: 100%; width: min(20rem, 100%); box-sizing: border-box; list-style: none; padding: .5rem; margin: .25rem 0 0; background: var(--bg); border: 1px solid var(--muted-readable); box-shadow: 0 .5rem 1rem #0008; max-height: 65vh; overflow-y: auto; }
  .mobile-menu li::marker { content: none; }
  .mobile-menu a { display: flex; align-items: center; min-height: 44px; padding: .25rem .75rem; }
  .mobile-menu a[aria-current="page"] { color: var(--hover); font-weight: bold; }
  .page__body { box-shadow: 0 0 0 .5rem var(--off-bg); }
  .desktop-intro { display: none; }
  .mobile-intro { display: block; }
  .home-content > .search-form { margin: .5rem 0 1rem; }
  .home-recent > h2 { margin-top: .5rem; }
  .home-topics .topic-grid { gap: .6rem; }
  .home-topics .topic-grid li { padding: .5rem .75rem; }
  .topic-grid a { display: flex; align-items: center; min-height: 44px; }
  .topic-grid p { margin-top: 0; }
  .article-header h1 { margin-bottom: .75rem; }
  .article-header .lede { margin-bottom: .75rem; }
  .article-header .post-meta { margin-bottom: .5rem; }
  .article-header .article-tags { display: none; }
  .mobile-article-tags { display: block; }
  .terms a { display: inline-flex; align-items: center; min-height: 44px; box-sizing: border-box; padding: .35rem .65rem; }
  .notice { padding: .65rem .75rem; margin: 1rem 0; font-size: .9rem; line-height: 1.5; }
  .toc { padding: .25rem .75rem; margin: 1rem 0; }
  .toc summary { display: list-item; min-height: 44px; align-content: center; }
  .toc nav { margin-top: .5rem; }
  .toc li a { display: inline-block; padding: .5rem 0; }
  .content__body h2, .content__body h3, #main { scroll-margin-top: 5rem; }
  pre { font-size: .875rem; padding: .75rem; }
  .code-controls { padding: .25rem .5rem; }
  .pagination a { display: inline-flex; align-items: center; min-height: 44px; }
  .skip-link:focus { z-index: 30; }
}

@media screen {
  :root {
    --bg: #141a22;
    --off-bg: #1c242e;
    --inner-bg: #10151b;
    --fg: #e2e8f0;
    --off-fg: #9caab9;
    --muted-readable: #9caab9;
    --muted: #303c49;
    --link: #8eadc8;
    --hover: #b7cee2;
    --highlight: var(--link);
    --logo: var(--fg);
  }
}
body { font-family: system-ui, sans-serif; }
pre, code { font-family: ui-monospace, monospace; }
.home-intro h1 { font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -.04em; }
.home-intro p:first-of-type { font-size: 1.2rem; }
.home-intro p:last-child, .content__body { max-width: 70ch; }
.home-references ul { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; padding: 0; list-style: none; }
.home-references li::marker { content: none; }
.topic-grid a { font-weight: 600; }

.notebook-cover {
  display: grid;
  gap: 1rem;
  padding-block: clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--muted);
}
.notebook-cover .home-intro h1 {
  font-family: Georgia, serif;
  font-weight: 500;
  line-height: 1.1;
  margin-bottom: .4rem;
}
.notebook-cover .home-intro p {
  font-family: Georgia, serif;
  font-style: italic;
  margin: 0;
}
.notebook-cover .search-form { margin: 0; }
.lab-plate { margin: 0; }
.lab-plate img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 16rem;
  object-fit: contain;
  background: var(--inner-bg);
}
.lab-plate figcaption { margin-top: .45rem; font: italic .95rem/1.4 Georgia, serif; }
.home-content > section > h2 { font: 500 1.5rem/1.3 Georgia, serif; }
.home-topics .topic-grid { gap: .5rem 1.75rem; }
.home-topics .topic-grid li { border: 0; border-top: 1px solid var(--muted); padding: .8rem 0; }
.lab-plate figcaption p { margin: .5rem 0 0; font: 1rem/1.5 system-ui, sans-serif; }
@media (min-width: 65rem) {
  .lab-plate { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 1.5rem; align-items: center; }
}
