/* Editorial — bold sans headlines over a serif body, drop cap, red pull quotes, sidenotes.
   System fonts only: readers download no font files. */
:root {
  color-scheme: light dark;
  --paper: #fffefb; --ink: #1f1f1f; --muted: #6b6760; --rule: #e8e3da; --accent: #b3261e; --code-bg: #f4f2ee;
  --serif: "Iowan Old Style", Charter, Georgia, "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif;
  --serif-hant: "Iowan Old Style", Charter, Georgia, "Songti TC", "Noto Serif CJK TC", "Source Han Serif TC", PMingLiU, serif;
  --serif-ja: "Iowan Old Style", Charter, Georgia, "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --measure: 38rem;
  --margin-note: 14rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper: #16161a; --ink: #e7e4de; --muted: #9a968f; --rule: #2c2c31; --accent: #ff6b5e; --code-bg: #1f1f25; }
}
:root[data-theme="dark"] { --paper: #16161a; --ink: #e7e4de; --muted: #9a968f; --rule: #2c2c31; --accent: #ff6b5e; --code-bg: #1f1f25; }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); text-autospace: normal; line-break: strict; hanging-punctuation: allow-end; -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 17px/1.8 var(--serif); }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* chrome */
.site-header, .site-footer, .banner { font-family: var(--sans); }
.site-header { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; max-width: calc(var(--measure) + 4rem); margin: 0 auto; padding: 1.5rem 1.25rem; }
.site-title { font-weight: 800; letter-spacing: -.01em; text-decoration: none; font-size: 1.05rem; }
.site-header nav { display: flex; gap: 1.2rem; font-size: .9rem; color: var(--muted); }
.site-header nav a { text-decoration: none; }
.site-footer { max-width: calc(var(--measure) + 4rem); margin: 4rem auto 2rem; padding: 1.5rem 1.25rem; border-top: 1px solid var(--rule); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; font-size: .85rem; color: var(--muted); }
.lang-switch ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .9rem; }
.lang-switch a { text-decoration: none; }
.lang-switch [aria-current] { color: var(--ink); font-weight: 600; }
.theme-toggle { font: inherit; color: inherit; background: none; border: 1px solid var(--rule); border-radius: 999px; padding: .15rem .8rem; cursor: pointer; }
.banner { background: var(--accent); color: #fff; text-align: center; padding: .4rem; font-size: .85rem; }

/* post */
main { max-width: var(--measure); margin: 0 auto; padding: 0 1.25rem; }
.post-header { margin: 2.5rem 0 2rem; }
.post-title { font: 700 clamp(2rem, 5.5vw, 2.9rem)/1.15 var(--sans); letter-spacing: -.02em; margin: 0 0 .5rem; }
.post-subtitle { font: 400 1.2rem/1.45 var(--sans); color: var(--muted); margin: 0 0 1rem; }
.post-meta { font: .85rem/1.5 var(--sans); color: var(--muted); margin: 0; }
.cover { margin: 0 0 2rem; }
.cover img { width: 100%; height: auto; }
.post-tags { font: .85rem var(--sans); color: var(--muted); margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.post-tags a { margin-right: .6rem; text-decoration: none; }

.prose { overflow-wrap: break-word; }
.prose :lang(ja) { font-family: var(--serif-ja); }
.prose :lang(zh-Hant) { font-family: var(--serif-hant); }
.prose p { margin: 0 0 1.25em; }
.prose h2, .prose h3, .prose h4 { font-family: var(--sans); line-height: 1.3; margin: 2.2em 0 .7em; }
.prose h2 { font-size: 1.45rem; } .prose h3 { font-size: 1.2rem; } .prose h4 { font-size: 1.05rem; }
.prose[data-dropcap="true"] > p:first-of-type::first-letter { float: left; font: 600 3.6em/.82 var(--serif); padding: .06em .1em 0 0; }
.prose blockquote { margin: 1.6em 0; padding-left: 1.1em; border-left: 2px solid var(--rule); color: var(--muted); }
.prose blockquote.pull { border: 0; padding: 0; margin: 2.2em 0; color: var(--accent); font: 600 1.4rem/1.45 var(--sans); }
.prose blockquote.pull p { margin: 0; }
.prose figure { margin: 2em 0; }
.prose figure img { display: block; width: 100%; height: auto; border-radius: 2px; }
.prose figcaption { font: .85rem/1.5 var(--sans); color: var(--muted); text-align: center; margin-top: .6em; }
.prose img { max-width: 100%; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em auto; width: 30%; }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; font: .92rem/1.5 var(--sans); margin: 1.6em 0; }
.prose th, .prose td { border-bottom: 1px solid var(--rule); padding: .45em .8em; text-align: left; }
.prose th { font-weight: 600; }
.prose code { font: .88em var(--mono); background: var(--code-bg); padding: .12em .32em; border-radius: 3px; }
.prose pre.shiki { background: var(--code-bg) !important; padding: 1em 1.2em; border-radius: 4px; overflow-x: auto; font: .85rem/1.6 var(--mono); margin: 1.6em 0; }
.prose pre.shiki code { background: none; padding: 0; font: inherit; }
.shiki span { color: var(--shiki-light); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .shiki span { color: var(--shiki-dark); } }
:root[data-theme="dark"] .shiki span { color: var(--shiki-dark); }
.prose .katex-display { overflow-x: auto; overflow-y: hidden; padding: .3em 0; }
.prose .embed { position: relative; aspect-ratio: 16 / 9; margin: 2em 0; }
.prose .embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.prose audio, .prose video { width: 100%; margin: 1.2em 0; }
.prose .unknown-directive { color: var(--muted); }

/* sidenotes: tap-to-open under 1100px, in the right margin above it */
.sidenote-number { font: 600 .7em var(--sans); color: var(--accent); vertical-align: super; line-height: 0; padding: 0 .12em; cursor: pointer; }
/* The checkbox stays focusable (keyboard: Tab to it, Space opens the note); it is only invisible. */
.margin-toggle { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.sidenote-number:has(+ .margin-toggle:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.sidenote { display: none; }
.margin-toggle:checked + .sidenote { display: block; margin: .6em 0; padding: .6em .9em; background: var(--code-bg); border-radius: 4px; font: .85rem/1.6 var(--sans); color: var(--muted); }
.sidenote-mark { color: var(--accent); font-weight: 600; margin-right: .4em; }
/* lists, code and quotes in a note arrive as span.sn-block (a note sits inside a paragraph) */
.sidenote .sn-block { display: block; }
.sidenote .sn-ul, .sidenote .sn-ol { padding-left: 1.1em; counter-reset: sn-item; }
/* never display:list-item — such an item counts in the nearest <ol> around the note: the post's own list */
.sidenote .sn-ul > .sn-li::before { content: "• "; }
.sidenote .sn-ol > .sn-li::before { counter-increment: sn-item; content: counter(sn-item) ". "; }
.sidenote .sn-pre { white-space: pre-wrap; font: .8rem/1.5 var(--mono); margin: .3em 0; }
.sidenote .sn-blockquote { border-left: 2px solid var(--rule); padding-left: .6em; margin: .3em 0; font-style: italic; }
@media (min-width: 1100px) {
  main.post { margin-left: calc(50% - (var(--measure) + var(--margin-note) + 2.5rem) / 2); }
  .sidenote, .margin-toggle:checked + .sidenote { display: block; float: right; clear: right; width: var(--margin-note); margin: .25em calc(-1 * (var(--margin-note) + 2.5rem)) 0 0; padding: 0; background: none; font: .8rem/1.55 var(--sans); color: var(--muted); }
  .sidenote-number { cursor: default; }
}

/* home, lists, tags, messages */
.home .latest { margin: 3rem 0; }
.kicker { font: 600 .75rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0; }
.home .latest h2 { font: 700 clamp(1.8rem, 5vw, 2.5rem)/1.2 var(--sans); letter-spacing: -.02em; margin: .4rem 0; }
.home .latest h2 a { text-decoration: none; }
.home .subtitle { font: 1.1rem var(--sans); color: var(--muted); margin: 0 0 .8rem; }
.home .meta { font: .85rem var(--sans); color: var(--muted); }
.home .archive h2, .tag h1, .tags h1, .message h1 { font: 700 1.5rem var(--sans); margin: 3rem 0 1rem; }
.post-list { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.post-list li { display: flex; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--rule); }
.post-list time { flex: none; width: 9rem; font: .85rem/1.9 var(--sans); color: var(--muted); }
.post-list a { text-decoration: none; }
h3 { font: 600 1rem var(--sans); color: var(--muted); margin: 2rem 0 .4rem; }
.tag-cloud { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; font-family: var(--sans); }
.tag-cloud a { text-decoration: none; }
.tag-cloud .count { color: var(--muted); font-size: .8em; }
.empty { font-family: var(--sans); color: var(--muted); margin: 4rem 0; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .post-list li { flex-direction: column; gap: 0; }
  .post-list time { width: auto; }
}
