/* Kuan theme — plain CSS. Tokens → foundations → layout → components → media. */
:root {
  color-scheme: light;
  --paper: #faf9f6; --surface: #fff; --ink: #172c42; --muted: #65717b;
  --rule: #d8dcd9; --accent: #85693c; --soft: #f0f1ed; --link: #244f72;
  --serif-default: 'Iowan Old Style', 'Palatino Linotype', 'Songti SC', 'STSong', 'Noto Serif CJK SC', Georgia, serif;
  --sans-default: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --serif: var(--serif-default); --sans: var(--sans-default);
  --reading-font: var(--sans-default); --measure: 49rem; --wrap: 72rem;
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #101c28; --surface: #152434; --ink: #ecebe5; --muted: #a6b4bf;
  --rule: #344352; --accent: #c7ae80; --soft: #1c2c3c; --link: #b5d4ee;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { color-scheme: dark; --paper: #101c28; --surface: #152434; --ink: #ecebe5; --muted: #a6b4bf; --rule: #344352; --accent: #c7ae80; --soft: #1c2c3c; --link: #b5d4ee; }
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 6rem; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.7; -webkit-font-smoothing: antialiased; }
body:has(dialog[open]) { overflow: hidden; }
[hidden] { display: none !important; }
::selection { background: var(--ink); color: var(--paper); }
a { color: inherit; text-decoration: none !important; transition: color .2s ease; }
a, button { -webkit-tap-highlight-color: transparent; }
a:hover { color: var(--accent-secondary, var(--accent)); }
button, input, select { font: inherit; }
button, select { color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
#main:focus { outline: none; }
h1, h2, h3, p, figure { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
h1, h2 { font-family: var(--serif); font-weight: 500; }
h1 { font-size: clamp(2.4rem, 5.6vw, 4.6rem); line-height: 1.3; letter-spacing: -.025em; }
h2 { font-size: clamp(1.75rem, 3vw, 2.35rem); line-height: 1.4; }
img { max-width: 100%; height: auto; vertical-align: middle; }
.wrap { max-width: var(--wrap); width: calc(100% - 6rem); margin-inline: auto; }
.breadcrumb, .not-found-code { font-size: .68rem; font-weight: 600; letter-spacing: .18em; line-height: 1.6; text-transform: uppercase; color: var(--muted); }
.lede { color: var(--muted); font-size: 1.05rem; max-width: 42rem; line-height: 1.9; }
.skip-link { position: fixed; z-index: 20; top: .75rem; left: .75rem; padding: .7rem 1rem; background: var(--ink); color: var(--paper); transform: translateY(-180%); }
.skip-link:focus { transform: translateY(0); }
.text-button { border: 0; background: none; padding: .6rem 0; font-size: .75rem; letter-spacing: .03em; }
.outline-button { padding: .7rem 1.4rem; border: 1px solid var(--rule); background: transparent; transition: background .2s, border-color .2s; }
.outline-button:hover { background: var(--soft); border-color: var(--ink); }
.underlined-link { display: inline-flex; align-items: center; gap: 1.8rem; font-size: .8rem; text-decoration: none; border-bottom: 1px solid var(--accent); padding-block: .4rem; }
.site-header { border-top: 4px solid var(--ink); border-bottom: 0; }
.masthead { min-height: 105px; display: flex; justify-content: space-between; align-items: center; gap: 2rem; }
.brand { display: flex; align-items: center; gap: 1rem; text-decoration: none; font-family: Georgia, serif; font-size: 1.55rem; letter-spacing: -.03em; }
.brand small { display: block; margin-top: .3rem; font-family: var(--sans); font-size: .51rem; letter-spacing: .18em; color: var(--muted); }
.brand-monogram { width: 3.25rem; height: 3.25rem; border: 1px solid var(--accent); border-radius: 50%; display: grid; place-content: center; position: relative; font-size: 1.8rem; line-height: 1; }
.header-tools { display: flex; gap: 1.5rem; align-items: center; }
.primary-nav { position: relative; display: flex; gap: 3rem; }
.primary-nav a { position: relative; text-decoration: none; font-size: .82rem; padding: 1rem 0; }
.primary-nav a span { color: var(--muted); font-size: .66rem; margin-left: .6rem; }
.home-intro { display: grid; grid-template-columns: 1.35fr 1fr; gap: 6rem; padding-block: 6rem 5.5rem; }
.hero-copy h1 { margin-block: 1.6rem 1.5rem; line-height: 1.4; font-size: clamp(2.8rem, 4.7vw, 4rem); letter-spacing: .025em; }
.hero-copy h1 em { font-style: normal; color: var(--accent); }
.hero-description { max-width: 26rem; font-size: .95rem; color: var(--muted); line-height: 1.95; margin-bottom: 1.5rem; }
.hero-index { align-self: center; background: var(--surface); padding: 1.25rem; }
.index-link { display: flex; align-items: start; gap: 1rem; padding: 1.35rem 0; text-decoration: none; border-bottom: 0; }
.index-number { font-family: Georgia, serif; font-size: .8rem; color: var(--accent); padding-top: .3rem; }
.index-link strong { font-family: var(--serif); font-size: 1.5rem; font-weight: 500; }
.index-link strong small { font-family: Georgia, serif; font-size: 1rem; color: var(--muted); margin-left: .5rem; }
.index-description { display: block; font-size: .75rem; color: var(--muted); margin-top: .35rem; }
.index-arrow { margin-left: auto; transition: transform .25s; }
.index-link:hover .index-arrow { transform: translate(3px, -3px); }
.home-recent { padding-bottom: 6rem; border-top: 0; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; padding-block: 2rem; }
.section-heading h2 { margin-top: .4rem; }
.empty-state { border-top: 0; display: flex; align-items: baseline; gap: 1.5rem; padding: 2rem 0; }
.empty-state > span { color: var(--accent); }
.empty-state p { font-size: .9rem; }
.empty-state p span { color: var(--muted); font-size: .8rem; }
.collection { padding-block: 4.5rem 6rem; min-height: 60vh; }
.page-heading { padding-bottom: 3rem; }
.page-heading h1 { margin: 1rem 0; }
.collection-intro { margin-bottom: 2rem; }
.entry { border-top: 0; display: flex; align-items: start; gap: 2rem; padding-block: 1.8rem; }
.entry-date { display: flex; flex: 0 0 7.5rem; flex-direction: column; align-items: flex-start; gap: .25rem; padding-top: .35rem; color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.entry-category { color: var(--accent-secondary, var(--accent)); font-size: .68rem; text-decoration: none; }
.entry-category:hover { color: var(--ink); }
.entry-body { flex: 1; min-width: 0; }
.entry h3 { font-family: var(--serif); font-weight: 500; font-size: 1.45rem; line-height: 1.55; }
.entry h3 a { text-decoration: none; }
.entry-arrow { display: inline-block; color: var(--accent-secondary, var(--accent)); font-family: var(--sans); font-size: .85rem; margin-left: 1rem; transition: transform .25s; }
.entry a:hover .entry-arrow { transform: translate(3px, -3px); }
.entry p { font-size: .87rem; color: color-mix(in srgb, var(--muted) 82%, var(--paper)); max-width: 42rem; margin-top: .6rem; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.entry-cover { width: 7rem; height: 5.25rem; object-fit: cover; margin-top: .3rem; }
.status { display: block; margin-top: .5rem; color: var(--accent-secondary, var(--accent)); }
.topics { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: .75rem; font-size: .68rem; color: var(--muted); }
.pagination { border-top: 0; display: flex; justify-content: center; gap: 2rem; padding-top: 2rem; font-size: .8rem; }
.article-shell { padding-top: 3.5rem; }
.article-header { margin-inline: auto; max-width: var(--measure); padding-bottom: 2.7rem; }
.breadcrumb { text-decoration: none; display: inline-block; margin-bottom: 2rem; }
.article-header h1 { font-size: clamp(2.2rem, 4.5vw, 3.4rem); line-height: 1.4; margin-bottom: 1.2rem; overflow-wrap: anywhere; }
.article-header .lede { margin-bottom: 1.3rem; }
.article-meta { display: flex; gap: .75rem; flex-wrap: wrap; color: var(--muted); font-size: .74rem; }
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, var(--measure)) minmax(0, 1fr); gap: 2rem; border-top: 0; padding-block: 2.5rem 5rem; }
.article-main { grid-column: 2; min-width: 0; }
.article-shell:has(.without-toc) .article-header { margin-inline: auto; max-width: var(--measure); }
.toc { grid-column: 1; grid-row: 1; align-self: start; position: sticky; top: 6rem; font-size: .73rem; max-height: calc(100dvh - 8rem); overflow-y: auto; }
.toc summary { font-size: .75rem; font-weight: 600; padding-bottom: 1rem; cursor: pointer; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary span { display: none; }
.toc ul { list-style: none; padding-left: 0; margin: 0; }
.toc ul ul { padding-left: .8rem; }
.toc li { margin: .5rem 0; }
.toc a { color: var(--muted); text-decoration: none; border-left: 0; padding: .45rem .65rem; display: block; }
.toc a:hover, .toc a[aria-current] { color: var(--ink); background: var(--soft); }
.article-cover { max-width: 24rem; margin-bottom: 2rem; }
.article-cover img { max-height: 13rem; object-fit: contain; object-position: left; }
.article-cover figcaption { font-size: .75rem; color: var(--muted); margin-top: .6rem; }
.prose { font-family: var(--reading-font); line-height: 1.95; font-size: 1.0625rem; overflow-wrap: anywhere; }
.prose > * + * { margin-top: 1.45em; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 { position: relative; scroll-margin-top: 6rem; margin-top: 2.5em; margin-bottom: .8em; line-height: 1.55; font-weight: 600; }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: 2rem; }
.prose h2 { font-size: 1.65rem; }
.prose h3 { font-size: 1.3rem; }
.prose h4, .prose h5, .prose h6 { font-size: 1.05rem; }
.prose a { color: var(--link); }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li + li { margin-top: .5em; }
.prose li > p { margin-top: .7em; }
.prose blockquote { margin-inline: 0; border-left: 0; padding: .25rem 0 .25rem 1.5rem; color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin-block: 3rem; }
.prose pre { font-size: .82rem; line-height: 1.75; padding: 1.3rem; background: var(--soft); overflow-x: auto; border: 0; }
.prose code { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: .88em; }
.prose :not(pre) > code { background: var(--soft); padding: .1rem .3rem; }
.prose img { max-height: 36rem; object-fit: contain; }
.prose img[data-zoom] { cursor: zoom-in; }
.heading-anchor { font-family: var(--sans); font-weight: 400; font-size: .7em; opacity: 0; padding: .2em .5em; text-decoration: none; }
.prose :is(h1,h2,h3,h4,h5,h6):hover .heading-anchor, .heading-anchor:focus-visible { opacity: .65; }
.table-scroll { overflow-x: auto; }
.prose table { border-collapse: collapse; width: 100%; font-size: .9em; text-align: left; }
.prose th, .prose td { padding: .7rem 1rem; border-bottom: 1px solid var(--rule); min-width: 6rem; }
.prose th { background: var(--soft); }
.prose table.no-header tbody tr:first-child > * { border-top: 1px solid var(--rule); }
.katex-display { overflow-x: auto; overflow-y: hidden; padding-block: .5rem; }
.prose .katex { font-size: 1.05em; }
.article-end { margin-top: 3.5rem; padding-top: 1.5rem; border-top: 0; display: flex; justify-content: space-between; gap: 1rem; font-size: .8rem; }
.discussion { margin-top: 4rem; padding-top: 2rem; border-top: 0; }
.discussion h2 { margin: .5rem 0 1.5rem; font-size: 1.75rem; }
.comment-status { margin-top: .7rem; font-size: .75rem; color: var(--muted); }
.discussion:not(.comments-loaded) .giscus { display: none; }
.giscus { margin-top: 1.5rem; }
.site-footer { border-top: 0; background: var(--soft); }
.footer-main { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1.5rem; padding-block: 2.7rem; }
.footer-main > .font-control { grid-column: 2; grid-row: 1; justify-self: center; color: var(--muted); font-size: .7rem; }
.footer-brand { font-family: Georgia, serif; font-size: 1.5rem; text-decoration: none; }
.footer-main p { max-width: 25rem; margin-top: .65rem; color: var(--muted); font-size: .75rem; }
.footer-links { grid-column: 3; grid-row: 1; justify-self: end; display: flex; gap: 1.5rem; align-items: center; font-size: .75rem; white-space: nowrap; }
.footer-links a { text-decoration: none; }
.footer-bottom { border-top: 0; padding-block: 1.2rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .7rem; }
.font-control { display: flex; align-items: center; gap: .75rem; }
.font-control select { padding: .3rem; font-size: .7rem; background: var(--paper); border: 1px solid var(--rule); max-width: 12rem; }
.not-found { min-height: 60vh; padding-block: 6rem; }
.not-found h1 { margin: 1rem 0; }
.not-found .underlined-link { margin-top: 2rem; }
.lightbox { position: fixed; inset: 0; border: 1px solid #47515c; background: #101822; color: #f4f3ee; padding: 1.2rem; width: min(96vw, 90rem); max-width: 96vw; max-height: 96dvh; }
.lightbox::backdrop { background: rgb(5 12 20 / .9); backdrop-filter: blur(5px); }
.lightbox[open] { display: flex; flex-direction: column; gap: 1rem; animation: lightbox-in .18s ease-out; }
.lightbox-toolbar, .lightbox-controls { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: .8rem; }
.lightbox button { color: inherit; background: none; border: 1px solid #64717e; padding: .45rem .7rem; min-height: 44px; }
.lightbox figure { text-align: center; min-height: 0; }
.lightbox figure img { max-height: 68dvh; object-fit: contain; }
.lightbox figcaption { margin-top: .8rem; font-size: .8rem; color: #c0c9d1; }
.lightbox-original { color: inherit; }
@keyframes lightbox-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* Chroma syntax tokens use the same readable palette in both themes. */
.chroma .c, .chroma .c1, .chroma .cm { color: var(--muted); font-style: italic; }
.chroma .k, .chroma .kd, .chroma .kn, .chroma .nt, .chroma .ow { color: var(--link); font-weight: 600; }
.chroma .s, .chroma .s1, .chroma .s2, .chroma .mi, .chroma .mf { color: var(--accent); }
@media (max-width: 1100px) {
  .home-intro { gap: 3rem; }
  .article-layout { grid-template-columns: 11rem minmax(0, 1fr); }
  .article-header { max-width: none; margin-left: 13rem; }
  .without-toc { display: block; max-width: var(--measure); margin-inline: auto; }
}
@media (max-width: 760px) {
  .wrap { width: calc(100% - 2.5rem); }
  .masthead { min-height: 87px; }
  .brand { font-size: 1.3rem; gap: .75rem; }
  .brand-monogram { width: 2.6rem; height: 2.6rem; font-size: 1.5rem; }
  .brand small { font-size: .45rem; }
  .header-tools { gap: 1rem; }
  .text-button { min-height: 44px; }
  .primary-nav { gap: 0; justify-content: space-between; }
  .primary-nav a { padding: .75rem 0; }
  .primary-nav a span { display: none; }
  .has-js .primary-nav:not(.is-open) { display: none; }
  .has-js .primary-nav.is-open { display: grid; grid-template-columns: 1fr 1fr; padding-bottom: 1rem; }
  .has-js .primary-nav.is-open a { text-align: center; }
  .has-js .primary-nav a span { display: inline; }
  .home-intro { display: block; padding-block: 3rem; }
  .hero-copy h1 { font-size: clamp(2.5rem, 9vw, 3.7rem); margin-block: 1.25rem; }
  .hero-description { font-size: .9rem; }
  .hero-index { margin-top: 3rem; }
  .index-link { padding-block: 1.15rem; }
  .index-link strong { font-size: 1.3rem; }
  .home-recent { padding-bottom: 3rem; }
  .section-heading { padding-block: 1.5rem; }
  .collection { padding-block: 3rem; }
  .page-heading { padding-bottom: 2rem; }
  .entry { flex-wrap: wrap; gap: .7rem 1rem; padding-block: 1.5rem; }
  .entry-date { flex-basis: 100%; }
  .entry h3 { font-size: 1.25rem; }
  .entry-cover { width: 4.5rem; height: 3.5rem; }
  .status { display: inline; margin-left: .75rem; }
  .article-shell { padding-top: 2rem; }
  .article-header { margin-left: 0; padding-bottom: 1.8rem; }
  .breadcrumb { margin-bottom: 1.4rem; }
  .article-layout { display: flex; flex-direction: column; gap: 2rem; padding-block: 1.5rem 3rem; }
  .toc { position: static; max-height: none; width: 100%; border-bottom: 0; padding-bottom: 1rem; }
  .toc summary { display: flex; align-items: center; justify-content: space-between; padding-bottom: 0; }
  .toc summary span { display: inline; }
  .toc details[open] summary span { transform: rotate(45deg); }
  .toc nav { padding-top: .75rem; }
  .article-main { width: 100%; }
  .prose { font-size: 1rem; line-height: 1.95; }
  .heading-anchor { opacity: .45; }
  .footer-main { grid-template-columns: auto 1fr; gap: 1.5rem .75rem; padding-block: 2rem; }
  .footer-links { grid-column: 2; gap: clamp(.5rem, 3vw, 1.5rem); }
  .footer-main > .font-control { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  .footer-bottom { flex-wrap: wrap; }
  .font-control { order: 3; width: 100%; margin-top: .5rem; }
  .lightbox { padding: .75rem; }
  .lightbox-controls { gap: .5rem; font-size: .7rem; }
}
@media (min-width: 761px) { .menu-toggle { display: none; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print {
  :root { --paper: white; --ink: black; --muted: #444; --rule: #ccc; }
  .site-header, .site-footer, .toc, .discussion, .article-end, .heading-anchor, .skip-link { display: none !important; }
  .wrap { width: 100%; } .article-header { margin: 0; } .article-layout { display: block; } .prose { font-size: 11pt; }
}



/* One fixed-width indicator travels between links; no stretching. */
.primary-nav a[aria-current] { color: var(--accent); }
.primary-nav:not(.has-indicator) a[aria-current]::after { content: ''; position: absolute; width: 2rem; height: 2px; left: 50%; bottom: 0; transform: translateX(-50%); background: var(--accent); }
.nav-indicator { position: absolute; left: 0; top: 0; width: 2rem; height: 2px; background: var(--accent); pointer-events: none; opacity: 0; transition: opacity .18s ease; }
@media (prefers-reduced-motion: no-preference) {
  .primary-nav.indicator-ready .nav-indicator { transition: transform .28s cubic-bezier(.2,.7,.3,1), opacity .18s ease; }
}
.nav-group:has(a:active) ~ .nav-indicator{
  filter: brightness(0.5);
}

/* Shared containers and restrained motion. */
.site-header { background: var(--surface); }
.masthead { min-height: 88px; }
.primary-nav { gap: 2.75rem; }
.brand-monogram { border: 0; background: var(--soft); border-radius: 0; }
.home-intro { gap: clamp(2rem, 6vw, 6rem); padding-block: 5rem; }
.hero-copy { align-self: center; }
.hero-copy h1 { margin-top: 0; }
.index-link { padding: 1.25rem; transition: background .25s ease, color .25s ease; }
.index-link:hover { background: var(--soft); }
.index-link:focus-visible { outline-offset: -2px; }
.index-link strong { font-size: 1.35rem; }
.home-recent { padding-bottom: 5rem; }
.section-heading { padding-top: 0; }
.entry { background: var(--surface); padding: 1.75rem 2rem; margin-bottom: .75rem; transition: background .25s ease; }
.entry:hover { background: var(--soft); }
.empty-state { background: var(--surface); padding: 2rem; color: var(--muted); }
.page-heading { max-width: var(--measure); }
.article-shell { padding-top: 3rem; }
.article-header { padding: clamp(1.25rem, 3vw, 2.75rem); margin-bottom: 1.5rem; background: var(--surface); }
.article-layout { padding-top: 0; gap: 1.5rem; }
.article-main { background: var(--surface); padding: clamp(1.25rem, 3vw, 2.75rem); }
.toc { background: var(--surface); padding: 1rem; scroll-margin-top: 6rem; }
.toc a { overflow-wrap: anywhere; transition: background .2s ease, color .2s ease; }
.toc summary { min-height: 32px; }
.prose blockquote {
  border: 0;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  padding: 1.25rem 1.5rem;
}
.prose blockquote blockquote { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.prose blockquote blockquote blockquote { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.prose blockquote blockquote blockquote blockquote { background: color-mix(in srgb, var(--accent) 34%, transparent); }
.prose blockquote blockquote blockquote blockquote blockquote { background: color-mix(in srgb, var(--accent) 42%, transparent); }
.prose pre, .table-scroll { max-width: 100%; }
.article-end a { min-height: 44px; display: inline-flex; align-items: center; }
.discussion { background: transparent; padding: 1.5rem 0 0; }
.footer-main { padding-bottom: 2rem; }
.footer-bottom { padding-bottom: 2rem; }
.reading-resume {
  position: fixed;
  z-index: 14;
  right: max(1.25rem, calc((100vw - var(--wrap)) / 2));
  bottom: 1.25rem;
  max-width: calc(100vw - 2.5rem);
  padding: .7rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 4px 20px rgb(0 0 0 / .18);
  font-size: .8rem;
}
.reading-resume:hover { background: var(--accent); color: var(--paper); }
.reading-resume:focus-visible { outline-offset: 3px; }

.reading-nav { position: fixed; z-index: 15; inset: 0 0 auto; background: var(--surface); box-shadow: 0 4px 24px rgb(0 0 0 / .07); }
.reading-nav-inner { display: flex; align-items: center; gap: 1.5rem; min-height: 64px; }
.reading-nav a { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; font-size: .78rem; text-decoration: none; }
.reading-title { flex: 1; min-width: 0; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-family: var(--serif); font-size: 1rem; }
.reading-progress { height: 2px; background: var(--accent-secondary, var(--accent)); transform: scaleX(var(--reading-progress, 0)); transform-origin: left; }
.reading-progress.is-switching { transition: transform .26s ease-out; }
.reduce-motion .reading-progress.is-switching { transition: none; }
@media (prefers-reduced-motion: no-preference) {
  .reading-nav:not([hidden]) { animation: reading-in .3s ease both; }
  .reveal-ready :is(.hero-copy, .hero-index, .section-heading, .entry, .page-heading, .article-header) {
    opacity: 0;
    transform: translateY(8px);
  }
  .reveal-ready :is(.hero-copy, .hero-index, .section-heading, .entry, .page-heading, .article-header).reveal-enter {
    animation: section-in .45s cubic-bezier(.2,.65,.3,1) both;
  }
  .primary-nav.is-open { animation: reading-in .25s ease both; }
}
@keyframes reading-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes section-in { from { opacity: .45; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 1100px) and (min-width: 761px) {
  .article-header { margin-left: 12.5rem; }
}
@media (max-width: 760px) {
  .home-intro { padding-block: 3rem; }
  .hero-index { margin-top: 2.5rem; padding: .5rem; }
  .primary-nav { gap: 0; }
  .article-header { margin-inline: 0; padding-top: 0; }
  .article-main { padding: 1.25rem; }
  .toc { padding: 1rem; }
  .toc summary { min-height: 24px; }
  .entry { padding: 1.5rem; }
  .reading-nav-inner { gap: .85rem; min-height: 60px; }
  .reading-title { font-size: .85rem; }
  .reading-nav a { font-size: .72rem; }
  .reading-home { display: none !important; }
}
@media print {
  .reading-nav { display: none !important; }
  .article-main { padding: 0; background: white; }
  .reveal-enter { animation: none !important; }
}











body {
  cursor: default;
}
/* Reading rhythm and Markdown conventions. */
.prose { line-height: 1.9; }
.prose > p + p { margin-top: 1.2em; }
.prose :is(h1,h2,h3,h4,h5,h6) + :is(p,ul,ol) { margin-top: .75em; }
.prose :is(ul,ol) :is(ul,ol) { margin-block: .5em; }
.prose blockquote > * + * { margin-top: .8em; }
.prose em { font-style: normal; text-decoration: underline; text-underline-offset: .22em; text-decoration-thickness: 1px; }
.prose :is(h1,h2,h3,h4,h5,h6) em { font-size: .72em; font-weight: 400; color: var(--muted); text-decoration: none; }
.prose p:has(> img ~ img) { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.prose p:has(> img ~ img) > img { flex: 1 1 12rem; min-width: 0; width: 0; max-height: 24rem; }
@media (min-width: 1101px) {
  .article-layout { grid-template-columns: 12rem minmax(0, 49rem); justify-content: center; }
  .article-shell:has(.toc) .article-header { margin-left: calc((100% - 62.5rem) / 2 + 13.5rem); margin-right: 0; }
  .article-layout.without-toc { display: block; max-width: var(--measure); margin-inline: auto; }
}
@media (min-width: 761px) { .reading-nav .reading-toc { display: none; } }
@media (max-width: 760px) {
  .article-shell.wrap { width: calc(100% - 1.5rem); }
  .article-main { padding: 1.25rem; }
  .prose p:has(> img ~ img) > img { flex-basis: 7rem; }
}


/* Navigation groups stay usable without JavaScript; the switch is an enhancement. */
.primary-nav { flex-wrap: wrap; align-items: center; }
.nav-group { display: flex; align-items: center; flex-wrap: wrap; gap: 2.75rem; }
.nav-group[hidden] { display: none; }
.nav-mode-toggle { margin-left: auto; flex-shrink: 0; padding-block: 1rem; }
.friend-links { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; padding-bottom: 2rem; font-size: .75rem; }
.friend-links > span { color: var(--muted); }
.friend-links a { text-decoration: none; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .nav-group { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
  .has-js .primary-nav.is-open { grid-template-columns: minmax(0, 1fr); }
  .nav-mode-toggle { justify-self: end; }
}




html[data-nav-mode="form"] #primary-nav [data-nav-group="content"],
html[data-nav-mode="content"] #primary-nav [data-nav-group="form"] {
    display:none;
}

@media (prefers-reduced-motion: no-preference) {
  #primary-nav.nav-switching .nav-group:not([hidden]) { animation: nav-group-in .24s ease-out both; }
}
@keyframes nav-group-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }



/* Scene palettes share a secondary accent for small interface cues. */
:root[data-palette='ocean'] { --paper:#e5f0f3; --surface:#f8fbfb; --ink:#163746; --muted:#526f79; --rule:#b8ced4; --accent:#087f88; --accent-secondary:#d15c44; --link:#1f648c; --soft:#d3e5e9; }
:root[data-palette='forest'] { --paper:#e9efe0; --surface:#f7f8f1; --ink:#342c22; --muted:#665f4d; --rule:#c9d4bb; --accent:#537b36; --accent-secondary:#a06330; --link:#315b3a; --soft:#dbe7d0; }
:root[data-palette='autumn'] { --paper:#f5d09a; --surface:#ffe7bd; --ink:#402012; --muted:#785137; --rule:#d79a5f; --accent:#c6420b; --accent-secondary:#155e9f; --link:#155e9f; --soft:#f0b86d; }
:root[data-palette='cyberpunk'] { --paper:#ede3f4; --surface:#f8effa; --ink:#24162e; --muted:#685271; --rule:#d1bad9; --accent:#d0008a; --accent-secondary:#0082a3; --link:#4a38c3; --soft:#ead8f1; }
:root[data-palette='exchange'] { --paper:#ededed; --surface:#fff; --ink:#111; --muted:#555; --rule:#bdbdbd; --accent:#c8192e; --accent-secondary:#067d35; --link:#067d35; --soft:#f7f7f7; }

:root[data-theme='dark'][data-palette='classic'] { --paper:#101c28; --surface:#152434; --ink:#ecebe5; --muted:#a6b4bf; --rule:#344352; --accent:#c7ae80; --link:#b5d4ee; --soft:#1c2c3c; }
:root[data-theme='dark'][data-palette='ocean'] { --paper:#0f1c24; --surface:#172a34; --ink:#e5f0f2; --muted:#a6bdc3; --rule:#354c55; --accent:#63c4c4; --accent-secondary:#ff977a; --link:#9ac9ed; --soft:#203b44; }
:root[data-theme='dark'][data-palette='forest'] { --paper:#151b13; --surface:#202b1c; --ink:#f0eadb; --muted:#b8b19d; --rule:#44483a; --accent:#a6c979; --accent-secondary:#d3a068; --link:#c0d99e; --soft:#2b3925; }
:root[data-theme='dark'][data-palette='autumn'] { --paper:#25140c; --surface:#3c2112; --ink:#fff0dc; --muted:#ddb994; --rule:#765033; --accent:#ff7a24; --accent-secondary:#8bc8ff; --link:#8bc8ff; --soft:#593118; }
:root[data-theme='dark'][data-palette='cyberpunk'] { --paper:#100b19; --surface:#1c112b; --ink:#fff0fc; --muted:#c6adce; --rule:#493052; --accent:#ff2daf; --accent-secondary:#69dcff; --link:#69dcff; --soft:#30203c; }
:root[data-theme='dark'][data-palette='exchange'] { --paper:#080808; --surface:#171717; --ink:#f5f5f5; --muted:#b7b7b7; --rule:#414141; --accent:#ff3548; --accent-secondary:#48ed78; --link:#48ed78; --soft:#252525; }

/* Follow the active scene palette when dark mode comes from the system. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme])[data-palette='classic'] { --paper:#101c28; --surface:#152434; --ink:#ecebe5; --muted:#a6b4bf; --rule:#344352; --accent:#c7ae80; --link:#b5d4ee; --soft:#1c2c3c; }
  :root:not([data-theme])[data-palette='ocean'] { --paper:#0f1c24; --surface:#172a34; --ink:#e5f0f2; --muted:#a6bdc3; --rule:#354c55; --accent:#63c4c4; --accent-secondary:#ff977a; --link:#9ac9ed; --soft:#203b44; }
  :root:not([data-theme])[data-palette='forest'] { --paper:#151b13; --surface:#202b1c; --ink:#f0eadb; --muted:#b8b19d; --rule:#44483a; --accent:#a6c979; --accent-secondary:#d3a068; --link:#c0d99e; --soft:#2b3925; }
  :root:not([data-theme])[data-palette='autumn'] { --paper:#25140c; --surface:#3c2112; --ink:#fff0dc; --muted:#ddb994; --rule:#765033; --accent:#ff7a24; --accent-secondary:#8bc8ff; --link:#8bc8ff; --soft:#593118; }
  :root:not([data-theme])[data-palette='cyberpunk'] { --paper:#100b19; --surface:#1c112b; --ink:#fff0fc; --muted:#c6adce; --rule:#493052; --accent:#ff2daf; --accent-secondary:#69dcff; --link:#69dcff; --soft:#30203c; }
  :root:not([data-theme])[data-palette='exchange'] { --paper:#080808; --surface:#171717; --ink:#f5f5f5; --muted:#b7b7b7; --rule:#414141; --accent:#ff3548; --accent-secondary:#48ed78; --link:#48ed78; --soft:#252525; }
}

/* Typography for front matter components in their own article card. */
.article-main > .page-controls {
  margin-top: 0;
  color: var(--ink);
  font-family: var(--reading-font);
  line-height: 1.85;
}
.article-main > .settings-page-controls {
  font-family: var(--sans);
}


.page-controls :is(button, select) {
  border: 1px solid var(--rule);
  border-radius: .25rem;
  color: var(--ink);
  font: inherit;
}
.page-controls select { background: var(--surface); }
.page-controls button { background: transparent; }

#main .settings-group {
  display: grid;
  grid-template-columns: minmax(10rem, .8fr) minmax(0, 1.2fr);
  column-gap: 2.5rem;
  align-items: start;
  padding: 1.75rem 0;
  border-top: 1px solid var(--rule);
}
#main .settings-page-controls > .settings-group:first-child {
  padding-top: 0;
  border-top: 0;
}
#main .settings-group h2 {
  grid-column: 1;
  grid-row: 1 / span 2;
  margin: 0;
  color: var(--ink);
  font: 600 1.2rem/1.55 var(--serif);
}
#main .settings-group > p {
  grid-column: 2;
  margin: 0 0 .75rem;
  color: var(--muted);
  font-size: .875rem;
}
#main .settings-control {
  grid-column: 2;
  display: grid;
  gap: .4rem;
  width: 100%;
  max-width: 32rem;
  margin: .75rem 0 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: .9375rem;
  font-weight: 600;
}
#main .settings-control select {
  width: 100%;
  min-height: 2.9rem;
  padding: .65rem .85rem;
  border: 1px solid var(--rule);
  border-radius: .25rem;
  background: var(--surface);
  color: var(--ink);
  line-height: 1.4;
}
#main .settings-control select:focus-visible { outline-offset: 2px; }
@media (max-width: 640px) {
  #main .settings-group { grid-template-columns: 1fr; row-gap: .55rem; }
  #main .settings-group h2,
  #main .settings-group > p,
  #main .settings-control { grid-column: 1; grid-row: auto; }
  #main .settings-control { margin-top: .6rem; }
}

/* User-controlled reduced motion preference. */
:root.reduce-motion { scroll-behavior: auto !important; }
:root.reduce-motion *,
:root.reduce-motion *::before,
:root.reduce-motion *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: .01ms !important;
}
.settings-switch { grid-template-columns: 1fr auto !important; align-items: center; }
.settings-switch input { width: 1.25rem; height: 1.25rem; accent-color: var(--accent); }
.settings-reset-group { grid-template-columns: minmax(10rem, .8fr) minmax(0, 1.2fr); }
#main .settings-reset {
  grid-column: 2;
  justify-self: start;
  padding: .65rem 1rem;
  border: 1px solid var(--rule);
  border-radius: .25rem;
  color: var(--ink);
  background: var(--surface);
}
#main .settings-reset:hover { border-color: var(--accent); background: var(--soft); }
#main .settings-status { grid-column: 2; min-height: 1.4em; margin-top: .4rem; }
@media (max-width: 640px) {
  #main .settings-reset-group { grid-template-columns: 1fr; }
  #main .settings-reset, #main .settings-status { grid-column: 1; }
}

/* Article covers fill the text column; portrait covers retain a readable width. */
.article-cover { width: 100%; max-width: none; margin: 0 0 2rem; }
.article-cover > a { display: block; width: 100%; }
.article-cover img { display: block; width: 100%; max-width: 100%; max-height: none; height: auto; object-fit: contain; object-position: center; }
.article-cover.is-portrait { text-align: center; }
.article-cover.is-portrait > a { width: auto; max-width: min(100%, 24rem); margin-inline: auto; }
.article-cover.is-portrait img { width: auto; max-width: 100%; max-height: 70vh; margin-inline: auto; }
.article-cover figcaption { text-align: center; }

/* Captions sit over the lower-left edge of their image. */
.article-cover { position: relative; }
.article-cover figcaption {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 0;
  left: 0;
  padding: .65rem .9rem;
  background: rgb(12 20 27 / .68);
  color: #fff;
  text-align: left;
  font-size: .78rem;
  line-height: 1.5;
  backdrop-filter: blur(3px);
}
.prose .image-caption-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: bottom;
}
.prose .image-caption-wrap > img { display: block; }
.prose .image-caption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: .5rem .7rem;
  background: rgb(12 20 27 / .68);
  color: #fff;
  text-align: left;
  font: .75rem/1.5 var(--sans);
  backdrop-filter: blur(3px);
}
.prose p:has(> .image-caption-wrap ~ .image-caption-wrap) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
}
.prose p:has(> .image-caption-wrap ~ .image-caption-wrap) > .image-caption-wrap {
  flex: 1 1 12rem;
  min-width: 0;
}
.lightbox figure { position: relative; display: table; max-width: 100%; margin-inline: auto; }
.lightbox figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  margin: 0;
  padding: .65rem .9rem;
  background: rgb(5 12 20 / .72);
  color: #fff;
  text-align: left;
  font-size: .8rem;
  line-height: 1.5;
  backdrop-filter: blur(3px);
}

/* Refined lightbox with layered entrance and exit motion. */
.lightbox {
  inset: 0;
  width: min(94vw, 86rem);
  height: min(92dvh, 62rem);
  max-width: 94vw;
  max-height: 92dvh;
  padding: clamp(.8rem, 2.2vw, 1.75rem);
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / .16);
  border-radius: 1rem;
  background: linear-gradient(145deg, rgb(28 39 52 / .98), rgb(9 15 23 / .99));
  color: #f5f6f7;
  box-shadow: 0 28px 100px rgb(0 0 0 / .55);
  opacity: 0;
  transform: translateY(14px) scale(.975);
}
.lightbox[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(.7rem, 1.8vh, 1.25rem);
  animation: lightbox-enter .38s cubic-bezier(.2,.75,.25,1) both;
}
.lightbox.is-closing { animation: lightbox-exit .34s cubic-bezier(.4,0,.8,.3) both; pointer-events: none; }
.lightbox::backdrop { background: rgb(3 8 14 / 0); backdrop-filter: blur(0); }
.lightbox[open]::backdrop { animation: lightbox-backdrop-in .38s ease-out both; }
.lightbox.is-closing::backdrop { animation: lightbox-backdrop-out .34s ease-in both; }
.lightbox-toolbar, .lightbox-controls {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  color: rgb(245 246 247 / .78);
  font-size: .78rem;
}
.lightbox-toolbar { min-height: 2.75rem; }
.lightbox-controls { min-height: 2.9rem; }
.lightbox button, .lightbox-original {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.65rem;
  padding: .55rem .9rem;
  border: 1px solid rgb(255 255 255 / .19);
  border-radius: 999px;
  background: rgb(255 255 255 / .07);
  color: #f5f6f7;
  font: inherit;
  text-decoration: none;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.lightbox button:hover, .lightbox-original:hover {
  border-color: rgb(255 255 255 / .42);
  background: rgb(255 255 255 / .14);
  color: #fff;
}
.lightbox button:active, .lightbox-original:active { transform: scale(.97); }
.lightbox figure {
  position: relative;
  display: block;
  align-self: center;
  justify-self: center;
  width: fit-content;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  overflow: hidden;
  border-radius: .5rem;
  background: rgb(0 0 0 / .18);
  box-shadow: 0 14px 40px rgb(0 0 0 / .18);
}
.lightbox figure img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 68dvh;
  border-radius: .5rem;
  object-fit: contain;
}
.lightbox figure img.lightbox-image-enter { animation: lightbox-image-enter .32s cubic-bezier(.2,.7,.3,1) both; }
.lightbox figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  margin: 0;
  padding: .75rem 1rem;
  border-radius: 0 0 .5rem .5rem;
  background: linear-gradient(0deg, rgb(4 8 14 / .82), rgb(4 8 14 / .42));
  color: #fff;
  text-align: left;
  font-size: .8rem;
  line-height: 1.55;
  backdrop-filter: blur(5px);
}
@keyframes lightbox-enter {
  from { opacity: 0; transform: translateY(14px) scale(.975); filter: blur(5px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
@keyframes lightbox-exit {
  from { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
  to { opacity: 0; transform: translateY(8px) scale(.985); filter: blur(4px); }
}
@keyframes lightbox-backdrop-in { from { background: rgb(3 8 14 / 0); backdrop-filter: blur(0); } to { background: rgb(3 8 14 / .78); backdrop-filter: blur(8px); } }
@keyframes lightbox-backdrop-out { from { background: rgb(3 8 14 / .78); backdrop-filter: blur(8px); } to { background: rgb(3 8 14 / 0); backdrop-filter: blur(0); } }
@keyframes lightbox-image-enter { from { opacity: 0; transform: scale(.985); filter: blur(3px); } to { opacity: 1; transform: scale(1); filter: blur(0); } }
:root.reduce-motion .lightbox[open],
:root.reduce-motion .lightbox.is-closing,
:root.reduce-motion .lightbox[open]::backdrop,
:root.reduce-motion .lightbox.is-closing::backdrop,
:root.reduce-motion .lightbox-image-enter { animation: none !important; }
:root.reduce-motion .lightbox[open] {
  opacity: 1;
  transform: none;
  filter: none;
}
@media (prefers-reduced-motion: reduce) {
  .lightbox[open] { opacity: 1; transform: none; filter: none; }
}
@media (max-width: 600px) {
  .lightbox { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; border-radius: 0; padding: .7rem; }
  .lightbox-controls { gap: .35rem; font-size: .68rem; }
  .lightbox button, .lightbox-original { min-height: 2.45rem; padding: .45rem .65rem; }
  .lightbox figure img { max-height: 72dvh; }
}

/* The user preference is restored before the stylesheet is applied. */
html[data-show-nav-toggle='true'] #primary-nav .nav-mode-toggle[hidden] {
  display: inline-flex !important;
}

/* Friend links are hidden before first paint when the saved preference is off. */
html[data-hide-friend-links='true'] .friend-links { display: none !important; }


/* Optional article fullscreen control, enabled from Settings. */
.article-backline { display: flex; align-items: baseline; gap: .4rem; margin-bottom: 2rem; }
.article-backline .breadcrumb { margin: 0; }
.article-fullscreen-separator { color: var(--muted); font-size: .82rem; }
/* A fullscreen element is detached visually from body/#main. Re-establish the
   page-level reading defaults on the article and preserve each nested layout. */
.article-shell:fullscreen,
.article-shell:-webkit-full-screen {
  display: block;
  width: 100%;
  max-width: none;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: clamp(1rem, 4vw, 3rem);
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
.article-shell:fullscreen::backdrop,
.article-shell:-webkit-full-screen::backdrop { background: var(--paper); }
.article-shell:fullscreen .article-header,
.article-shell:-webkit-full-screen .article-header {
  width: min(100%, var(--measure));
  max-width: var(--measure);
  margin-inline: auto;
}
.article-shell:fullscreen .article-layout,
.article-shell:-webkit-full-screen .article-layout {
  width: min(100%, 76rem);
  max-width: 76rem;
  margin-inline: auto;
}
/* With a TOC, align the fullscreen title with the article text column.
   Keep this override scoped to fullscreen so normal article layout is unchanged. */
@media (min-width: 761px) {
  .article-shell:fullscreen:has(.toc) .article-header,
  .article-shell:-webkit-full-screen:has(.toc) .article-header {
    box-sizing: border-box;
    width: min(100%, 76rem);
    max-width: 76rem;
    margin-inline: auto;
    padding-inline: 13.5rem;
  }
}
@media (max-width: 760px) {
  .article-shell:fullscreen:has(.toc) .article-header,
  .article-shell:-webkit-full-screen:has(.toc) .article-header {
    width: 100%;
    max-width: var(--measure);
    margin-inline: auto;
    padding-inline: 0;
  }
}
.article-shell:fullscreen .article-layout.without-toc,
.article-shell:-webkit-full-screen .article-layout.without-toc {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: var(--measure);
}
@media (min-width: 761px) {
  .article-shell:fullscreen .article-layout:not(.without-toc),
  .article-shell:-webkit-full-screen .article-layout:not(.without-toc) {
    grid-template-columns: minmax(0, 12rem) minmax(0, 49rem);
    justify-content: center;
    gap: 1.5rem;
  }
}
@media (max-width: 760px) {
  .article-shell:fullscreen,
  .article-shell:-webkit-full-screen { padding: 1.25rem; }
  .article-shell:fullscreen .article-layout,
  .article-shell:-webkit-full-screen .article-layout { display: flex; flex-direction: column; }
}
@media (max-width: 760px) { .article-backline { margin-bottom: 1.4rem; } }

.code-block { margin: 1.5rem 0; }
.code-language { display: flex; align-items: center; justify-content: space-between; padding: .35rem 1.3rem 0; border: 0; background: var(--soft); color: var(--muted); font: .7rem/1.4 var(--sans); letter-spacing: .04em; text-transform: uppercase; }
.code-copy { border: 0; background: transparent; color: inherit; padding: .25rem 0 .35rem; font: inherit; letter-spacing: 0; text-transform: none; cursor: pointer; }
.code-copy:hover, .code-copy:focus-visible { color: var(--accent); }
.code-block .highlight { margin: 0; }
.code-block .highlight pre { margin: 0; }
.code-language + .highlight pre { padding-top: 1.3rem; }

/* Loading state and entry motion for continuously loaded updates. */
.infinite-loading-dots::after { content: ""; animation: infinite-dots 1.2s steps(4, end) infinite; }
.infinite-placeholder .article-main {
  min-height: clamp(12rem, 32vh, 22rem);
  opacity: .38;
}
.continuous-sentinel { height: 1px; }
.infinite-placeholder-retry { cursor: pointer; }
.infinite-placeholder-retry .article-header h1 { color: var(--muted); }
@media (prefers-reduced-motion: no-preference) {
  .reveal-ready .infinite-article .article-main.infinite-reading-enter {
    animation: section-in .45s cubic-bezier(.2,.65,.3,1) both;
  }
  .infinite-placeholder .article-main { animation: infinite-placeholder-pulse 1.15s ease-in-out infinite alternate; }
  .infinite-article .article-header.reveal-enter { animation: section-in .45s cubic-bezier(.2,.65,.3,1) both; }
  .reading-title { will-change: transform, opacity; }
}
@keyframes infinite-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75%, 100% { content: "..."; }
}
@keyframes infinite-placeholder-pulse {
  from { opacity: .25; }
  to { opacity: .58; }
}


/* Article titles share one card; continuous sections add sequential reading. */
.article-shell.continuous-layout .article-header {
  max-width: var(--measure);
  margin-inline: auto;
}
.article-layout.without-toc,
.article-layout.continuous-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: var(--measure);
  margin-inline: auto;
}
.article-layout.continuous-layout { padding-block: .75rem 0; }
.article-layout.continuous-layout .toc {
  position: static;
  grid-column: auto;
  grid-row: auto;
  width: auto;
  max-height: none;
  margin: 0;
  padding: clamp(1.25rem, 3vw, 2.75rem);
}
.article-layout.continuous-layout .article-main { grid-column: auto; }
.article-shell .article-header,
.infinite-article .article-header {
  max-width: var(--measure);
  margin: 0 auto 1.5rem;
  padding: clamp(1.25rem, 3vw, 2.75rem);
  background: var(--surface);
}
.article-shell .toc,
.infinite-article .toc {
  background: var(--surface);
}
.article-shell .article-layout.continuous-layout,
.infinite-article .article-layout.continuous-layout {
  padding: 0;
}
.article-shell.continuous-layout,
.infinite-article { padding-top: 1.5rem !important; }
.article-shell.continuous-layout .article-header h1,
.infinite-article.continuous-layout .article-header h1 { text-wrap: initial; }
.article-shell.continuous-layout:not([data-infinite-next]) .article-layout > .article-main:last-of-type,
.infinite-article.continuous-layout:not([data-infinite-next]) .article-layout > .article-main:last-of-type {
  margin-bottom: 5rem;
}
@media (min-width: 761px) {
  .article-shell .toc,
  .infinite-article .toc {
    padding-block: clamp(1rem, 2vw, 2rem);
  }
}
@media (max-width: 760px) {
  .article-layout.continuous-layout { padding-block: .5rem 0; }
  .article-shell.continuous-layout,
  .infinite-article { padding-top: 1rem !important; }
  .article-shell .article-header,
  .infinite-article .article-header {
    margin-bottom: 1rem;
    padding: 1.25rem;
  }
  .article-shell .toc,
  .infinite-article .toc {
    padding: 1rem;
    margin-bottom: 1rem;
  }
  .article-shell.continuous-layout:not([data-infinite-next]) .article-main,
  .infinite-article.continuous-layout:not([data-infinite-next]) .article-main {
    margin-bottom: 3rem;
  }
}


.entry-date-line { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; }
@media (max-width: 760px) {
  .entry-date-line {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: .6rem;
  }
}


/* Theme-aware image viewer with brief opacity/position transitions. */
.lightbox {
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  opacity: 1;
  transform: none;
  filter: none;
  box-shadow: 0 18px 56px rgb(0 0 0 / .18);
}
.lightbox[open] {
  animation: lightbox-enter .18s ease-out both;
}
.lightbox.is-closing {
  animation: lightbox-exit .14s ease-in both;
  pointer-events: none;
}
.lightbox::backdrop,
.lightbox[open]::backdrop,
.lightbox.is-closing::backdrop {
  background: color-mix(in srgb, var(--paper) 68%, transparent);
  backdrop-filter: blur(8px);
  animation: none;
}
.lightbox button,
.lightbox-original {
  border-color: var(--rule);
  background: var(--paper);
  color: var(--ink);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.lightbox button:hover,
.lightbox-original:hover {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--ink);
}
.lightbox figure img { border-radius: 3px; }
.lightbox figure img.lightbox-image-enter { animation: lightbox-image-enter .16s ease-out both; }
@keyframes lightbox-image-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes lightbox-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes lightbox-exit {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(4px); }
}

/* Captions use a subtle black tint, blur, and clear white type. */
.article-cover figcaption,
.prose .image-caption,
.lightbox figcaption {
  border-radius: 0;
  background: rgb(0 0 0 / .24);
  color: #fff;
  backdrop-filter: blur(8px);
}


/* Long article headlines ease down when they exceed ten Han characters. */
.article-header h1.long-title {
  font-size: clamp(1.9rem, 3.6vw, 2.8rem);
}
@media (max-width: 760px) {
  .article-header h1.long-title {
    font-size: clamp(1.7rem, 6.3vw, 2.35rem);
  }
}


/* Mark only fetched update articles with the reading progress accent. */
.infinite-article:not(.infinite-placeholder) .article-header {
  border-top: 3px solid var(--accent);
}


/* Floating lightbox controls: clean white in light mode, bordered in dark mode. */
.lightbox button,
.lightbox-original {
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #17212b;
  box-shadow: 0 3px 10px rgb(0 0 0 / .10), 0 1px 2px rgb(0 0 0 / .06);
  transition: transform .15s ease, box-shadow .15s ease;
}
.lightbox button:hover,
.lightbox-original:hover {
  border: 0;
  background: #fff;
  color: #17212b;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgb(0 0 0 / .14), 0 2px 4px rgb(0 0 0 / .08);
}
:root[data-theme='dark'] .lightbox button,
:root[data-theme='dark'] .lightbox-original {
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 3px 10px rgb(0 0 0 / .16);
}
:root[data-theme='dark'] .lightbox button:hover,
:root[data-theme='dark'] .lightbox-original:hover {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .lightbox button,
  :root:not([data-theme]) .lightbox-original {
    border: 1px solid var(--rule);
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 3px 10px rgb(0 0 0 / .16);
  }
  :root:not([data-theme]) .lightbox button:hover,
  :root:not([data-theme]) .lightbox-original:hover {
    border-color: var(--accent);
    background: var(--soft);
    color: var(--ink);
  }
}


/* Keep the lightbox geometric and ensure the counter stays readable in both themes. */
.lightbox,
.lightbox * {
  border-radius: 0 !important;
}
.lightbox .lightbox-counter {
  color: var(--ink) !important;
  font-weight: 600;
}


.stream-entry { text-decoration: none; }


/* Theme the prose list markers and task checkboxes. */
.prose ul > li::marker,
.prose ol > li::marker {
  color: var(--accent-secondary, var(--accent));
}
.prose li:has(> input[type="checkbox"]) {
  list-style: none;
}
.prose li > input[type="checkbox"] {
  accent-color: var(--accent-secondary, var(--accent));
  width: 1em;
  height: 1em;
  margin: 0 .5em 0 0;
  vertical-align: -.12em;
  opacity: 1;
  cursor: default;
}


/* Lightbox caption and gallery navigation share one floating surface. */
.lightbox-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
}
.lightbox-controls > [data-lightbox="previous"] { margin-right: auto; }
.lightbox-controls > [data-lightbox="next"] { margin-left: auto; }
.lightbox-zoom { display: flex; align-items: center; justify-content: center; gap: .4rem; }
.lightbox-zoom button[data-lightbox="zoom-out"],
.lightbox-zoom button[data-lightbox="zoom-in"] { width: 2.7rem; padding-inline: .35rem; }
.lightbox-zoom button[data-lightbox="zoom-reset"] { min-width: 3.6rem; padding-inline: .4rem; }
.lightbox-zoom button:disabled { cursor: default; }
.lightbox figure {
  position: relative;
  display: block;
  align-self: center;
  justify-self: center;
  width: fit-content;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}
.lightbox-image-window {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: rgb(0 0 0 / .18);
  box-shadow: 0 14px 40px rgb(0 0 0 / .18);
}
.lightbox figure img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 68dvh;
  object-fit: contain;
  transform-origin: center center;
  transition: transform .12s ease;
  cursor: zoom-in;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox-caption-rail {
  position: absolute;
  z-index: 2;
  bottom: .55rem;
  left: 50%;
  display: flex;
  flex-direction: column;
  width: min(44rem, calc(100vw - 3rem));
  max-width: calc(100% - 1rem);
  overflow: hidden;
  transform: translateX(-50%);
  border: 0;
  border-radius: 1rem !important;
  background: rgb(10 14 20 / .76);
  color: #f5f6f7;
  box-shadow: 0 12px 36px rgb(0 0 0 / .24), 0 2px 8px rgb(0 0 0 / .12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 1;
  transition: opacity .22s ease;
}
.lightbox figure.is-zoomed .lightbox-caption-rail { opacity: 0; pointer-events: none; }
.lightbox figcaption {
  position: static;
  order: 0;
  margin: 0;
  padding: .7rem 1rem .55rem;
  border-radius: 0 !important;
  background: transparent;
  color: #f5f6f7;
  text-align: left;
  font-size: .8rem;
  line-height: 1.55;
  backdrop-filter: none;
}
.lightbox figcaption:empty { display: none; }
.lightbox-caption-rail.caption-empty .lightbox-thumbnails { border-top: 0; }
.lightbox-thumbnails {
  position: static;
  order: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: .45rem;
  width: auto;
  max-width: 100%;
  max-height: 3.1rem;
  min-width: 0;
  margin: 0;
  padding: .45rem .55rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
  border: 0;
  background: transparent;
  backdrop-filter: none;
  cursor: grab;
}
.lightbox-thumbnails::-webkit-scrollbar { display: none; }
.lightbox-thumbnails.is-dragging { cursor: grabbing; user-select: none; }
.lightbox-thumbnails.is-dragging button { cursor: grabbing; }
.lightbox-thumbnail {
  flex: 0 0 auto;
  width: 4rem;
  height: 2.55rem;
  min-height: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  border: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  opacity: .72;
  transition: opacity .15s ease;
}
.lightbox-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px !important;
  box-shadow: none;
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox-thumbnail:hover,
.lightbox-thumbnail[aria-current="true"] { opacity: 1; }
.lightbox figure.is-panorama {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  overflow: visible;
}
.lightbox figure.is-panorama .lightbox-image-window { max-height: min(58dvh, 44rem); }
.lightbox figure.is-panorama .lightbox-image-window img { max-height: min(58dvh, 44rem); }
.lightbox figure.is-panorama .lightbox-caption-rail {
  position: relative;
  inset: auto;
  left: auto;
  width: 100%;
  max-width: 44rem;
  margin-top: -.65rem;
  transform: none;
}
.lightbox figure.is-zoomed img { cursor: grab; touch-action: none; }
.lightbox figure.is-dragging img { cursor: grabbing; transition: none; }
@media (max-width: 600px) {
  .lightbox[open] { grid-template-columns: minmax(0, 1fr); }
  .lightbox figure.is-panorama {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .lightbox figure.is-panorama .lightbox-image-window {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .lightbox figure.is-panorama .lightbox-image-window img {
    max-width: 100%;
    margin-inline: auto;
  }
  .lightbox figure.is-panorama .lightbox-caption-rail {
    width: 100%;
    max-width: 100%;
  }
  .lightbox-controls { gap: .35rem; }
  .lightbox-zoom { gap: .25rem; }
  .lightbox-zoom button[data-lightbox="zoom-out"],
  .lightbox-zoom button[data-lightbox="zoom-in"] { width: 2.35rem; }
  .lightbox-zoom button[data-lightbox="zoom-reset"] { min-width: 3.15rem; }
  .lightbox-thumbnail { width: 3.35rem; height: 2.25rem; }
  .lightbox-thumbnails { max-height: 2.7rem; }
}


/* Friends directory */
.friends-toolbar { position: sticky; z-index: 5; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.friends-toolbar p { color: var(--muted); font-size: .78rem; }
.friends-toolbar button { border: 1px solid var(--rule); background: var(--surface); padding: .55rem .9rem; font-size: .78rem; }
.friend-card-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem; margin-top: 1.5rem; }
.friend-card { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--rule); }
.friend-card-list.avatars-enabled .friend-card { grid-template-columns: 3.75rem minmax(0, 1fr); }
.friend-avatar, .friend-avatar-placeholder { width: 3.75rem; height: 3.75rem; border-radius: 50%; object-fit: cover; background: var(--soft); }
.friend-avatar-placeholder { display: none; place-items: center; color: var(--muted); font-family: var(--serif); font-size: 1.4rem; }
.friend-card-list.avatars-enabled .friend-avatar-placeholder { display: grid; }
.friend-card h2 { font-family: var(--reading-font); font-size: 1.1rem; line-height: 1.55; overflow-wrap: anywhere; }
.friend-card h2 a { text-decoration: none; }
.friend-card p { margin-top: .4rem; color: var(--muted); font-size: .9rem; line-height: 1.85; }
.friend-card .friend-url { display: inline-block; margin-top: .45rem; font-size: .7rem; color: var(--muted); overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .friends-toolbar p { font-size: .68rem; }
  .friend-card-list { grid-template-columns: 1fr; }
}


/* Keep the homepage column navigator off small screens and tighten footer links. */
@media (max-width: 760px) {
  .hero-index { display: none; }
  .friend-links { gap: .4rem .8rem; }
}
