/* Onc ink-and-paper theme */
:root {
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
  --bg: #f7f7f5;
  --fg: #171717;
  --text: #3d3d3a;
  --muted: #73736e;
  --line: #e4e4e0;
  --line-strong: #c8c8c2;
  --code-bg: #f1f1ee;
  --code-fg: #242422;
  --focus: #171717;
  --s-1: 8px;
  --s-2: 16px;
  --s-3: 24px;
  --s-4: 32px;
  --header: 56px;
  --gutter: var(--s-3);
  --site: 760px;
  --prose: 680px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}
html[data-theme="dark"] {
  --bg: #111111;
  --fg: #f3f3f0;
  --text: #c8c8c2;
  --muted: #8f8f88;
  --line: #2a2a2a;
  --line-strong: #454540;
  --code-bg: #191919;
  --code-fg: #e7e7e2;
  --focus: #f3f3f0;
}
*, *::before, *::after { box-sizing: border-box }
html {
  color-scheme: light dark;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header) + var(--s-2));
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}
html[data-theme="dark"] { color-scheme: dark }
body {
  margin: 0;
  min-height: 100dvh;
  padding-top: var(--header);
  overflow-x: clip;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, a { -webkit-tap-highlight-color: transparent }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px }
a { color: inherit }
h1, h2, h3 { margin: 0; font-weight: 520; letter-spacing: -.02em; line-height: 1.3; overflow-wrap: anywhere }
time, code, pre, .meta, .code-lang, .code-copy { font-family: var(--font-mono) }

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1000;
  height: var(--header);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.header-inner, .site-main, .footer-inner { max-width: var(--site); margin-inline: auto }
.header-inner {
  height: 100%;
  padding-inline: var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}
.brand { display: flex; align-items: center; gap: var(--s-1); min-height: 44px; color: var(--fg); text-decoration: none }
.brand-mark { width: 18px; height: 18px; display: block; flex: 0 0 auto }
.brand-name { font-size: 14px; font-weight: 560; letter-spacing: .04em }
.header-actions, .nav { display: flex; align-items: center }
.nav { gap: 0 }
.nav a {
  min-height: 44px;
  padding: var(--s-1) 12px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  touch-action: manipulation;
}
.rss-link, .icon-btn, .floating-btn, .toc-close {
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
}
.rss-link { text-decoration: none }
.rss-link svg, .icon-btn svg, .floating-btn svg, .toc-close svg { width: 18px; height: 18px; pointer-events: none }
.theme-icon-sun, .menu-icon-close { display: none }
.theme-icon-moon { display: block }
html[data-theme="dark"] .theme-icon-sun { display: block }
html[data-theme="dark"] .theme-icon-moon { display: none }
.menu-toggle { display: none }
.menu-toggle[aria-expanded="true"] .menu-icon-open { display: none }
.menu-toggle[aria-expanded="true"] .menu-icon-close { display: block }

.site-main { padding: var(--s-3) var(--gutter) }
.hero { padding-bottom: var(--s-1) }
.hero h1 { font-size: clamp(34px, 5vw, 48px); letter-spacing: -.035em }
.hero-kicker { max-width: 34em; margin: var(--s-1) 0 0; color: var(--muted); font-size: 14px }
.dot-sep { margin-inline: var(--s-1); color: var(--line-strong) }

.post-list, .archive-list { list-style: none; margin: 0; padding: 0 }
.post-list { margin-top: var(--s-3) }
.post-list li, .empty-state { border-top: 1px solid var(--line) }
.post-list li:last-child { border-bottom: 1px solid var(--line) }
.post-list li { padding-block: var(--s-2) }
.entry-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2) }
.post-list h2 { min-width: 0; font-size: 18px }
.post-list a, .archive-list a { color: var(--fg); text-decoration: none }
.post-list a:hover, .archive-list a:hover { text-decoration: underline; text-underline-offset: 4px }
.post-list .meta, .article-date, .archive-list time { flex: 0 0 auto; color: var(--muted); font-size: 12px; letter-spacing: .04em }
.post-list p { max-width: var(--prose); margin: var(--s-1) 0 0; color: var(--text); font-size: 14px }
.empty-state { margin-top: var(--s-3); padding-block: var(--s-2); color: var(--text) }

.archives { padding-top: 0 }
.archive-year { margin: var(--s-3) 0 var(--s-1); padding-top: var(--s-2); border-top: 1px solid var(--line); font-size: 12px; font-weight: 500; letter-spacing: .04em }
.archive-year:first-child { margin-top: 0; padding-top: 0; border-top: 0 }
.archive-list { margin-top: 0 }
.archive-list li { display: flex; align-items: baseline; gap: 12px; min-width: 0; padding-block: var(--s-1) }
.archive-list time { flex-basis: 88px; font-size: 11px }
.archive-list a { min-width: 0; overflow: hidden; font-size: 15px; font-weight: 450; text-overflow: ellipsis; white-space: nowrap }

.page { min-width: 0 }
.page-head, .page > h1 { max-width: var(--prose); margin-bottom: var(--s-3) }
.page > h1, .page-head h1 { font-size: clamp(28px, 3.5vw, 34px) }
.article-date { display: block; margin-top: var(--s-1) }
.body { max-width: var(--prose); min-width: 0; color: var(--text); font-size: 16px; line-height: 1.7 }
.body > :first-child { margin-top: 0 }
.body p, .body ul, .body ol { margin: 0 0 var(--s-1) }
.body h2, .body h3 { display: flex; align-items: baseline; gap: var(--s-1); min-width: 0; margin: var(--s-3) 0 var(--s-1); color: var(--fg) }
.body h2 { padding-top: var(--s-2); border-top: 1px solid var(--line); font-size: 20px }
.body h3 { font-size: 17px }
.heading-anchor {
  flex: 0 0 1.3em;
  width: 1.3em;
  margin-left: -1.3em;
  color: var(--muted);
  font-family: var(--font-mono);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
}
.body h2:hover .heading-anchor, .body h3:hover .heading-anchor, .heading-anchor:focus-visible { opacity: 1 }
.heading-text { min-width: 0 }
.body ul, .body ol { padding-left: var(--s-3) }
.body li { margin-block: var(--s-1) }
.body li::marker { color: var(--muted) }
.body blockquote { margin: var(--s-2) 0; padding-left: var(--s-2); border-left: 1px solid var(--line-strong) }
.body blockquote p { margin: 0 }
.body hr { margin-block: var(--s-3); border: 0; border-top: 1px solid var(--line) }
.body a { color: var(--fg); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px }
.body img { display: block; max-width: 100%; height: auto; margin-block: var(--s-2); border: 1px solid var(--line) }
.body code { margin-inline: .15em; padding: .08em .32em; border: 1px solid var(--line); background: var(--code-bg); color: var(--fg); font-size: .86em }
.body table { display: table; width: 100%; margin-block: var(--s-2); border-collapse: collapse; border-top: 1px solid var(--line); font-size: .92em }
.body th, .body td { padding: var(--s-1) 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: normal; overflow-wrap: anywhere }
.body th { color: var(--fg); font-weight: 560 }

.code-window { margin-block: var(--s-1); border: 1px solid var(--line); background: var(--code-bg); color: var(--code-fg); overflow: hidden }
.code-window-bar { min-height: 40px; padding: var(--s-1) var(--s-1) var(--s-1) var(--s-2); display: flex; align-items: center; border-bottom: 1px solid var(--line) }
.code-lang { color: var(--muted); font-size: 11px; letter-spacing: .03em }
.code-copy { min-width: 64px; min-height: 32px; margin-left: auto; padding-inline: var(--s-1); border: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer }
.code-copy:hover { color: var(--fg) }
.code-copy[disabled] { cursor: default; opacity: .7 }
.code-window pre { margin: 0; padding: var(--s-2); overflow: auto; font-size: 12.5px; line-height: 1.5; tab-size: 2; scrollbar-color: var(--line-strong) transparent }
.code-window pre code { margin: 0; padding: 0; border: 0; background: none; color: inherit; font-size: inherit }
.code-window pre ::selection { background: color-mix(in srgb, var(--fg) 16%, transparent) }

.floating-btn { position: fixed; right: var(--s-2); z-index: 920; border: 1px solid var(--line-strong); background: var(--bg); color: var(--fg) }
.toc-open { bottom: var(--s-2) }
.back-top { bottom: calc(var(--s-2) + 52px); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 160ms var(--ease) }
.back-top.is-visible { opacity: 1; visibility: visible; pointer-events: auto }
.toc-overlay { position: fixed; inset: 0; z-index: 900; display: none; background: color-mix(in srgb, var(--bg) 72%, transparent) }
.toc-overlay.is-open { display: block }
.toc-panel {
  position: fixed;
  right: var(--s-2);
  bottom: var(--s-2);
  z-index: 910;
  display: none;
  width: min(360px, calc(100vw - var(--s-4)));
  max-height: min(560px, calc(100dvh - 96px));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--bg);
}
.toc-panel.is-open { display: block }
.toc-header { min-height: 48px; padding-left: var(--s-2); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line) }
.toc-header h2 { font-size: 13px; font-weight: 560; letter-spacing: .04em }
.toc-nav { max-height: calc(min(560px, 100dvh - 96px) - 49px); overflow: auto; padding: var(--s-1) }
.toc-nav a { display: block; padding: var(--s-1); color: var(--text); font-size: 13px; line-height: 1.45; text-decoration: none }
.toc-nav a[data-level="3"] { padding-left: var(--s-3); font-size: 12px }
.toc-nav a.is-active { color: var(--fg); box-shadow: inset 2px 0 0 var(--fg) }
.toc-empty { margin: 0; padding: var(--s-1); color: var(--muted); font-size: 13px }

.site-footer { border-top: 1px solid var(--line); padding: var(--s-2) var(--gutter); color: var(--muted); font-size: 11px }
.footer-inner { display: flex; justify-content: space-between; gap: var(--s-2); flex-wrap: wrap }

@media (max-width: 720px) {
  :root { --gutter: var(--s-2) }
  .menu-toggle { display: inline-flex }
  .nav {
    position: fixed;
    top: var(--header);
    right: 0;
    left: 0;
    z-index: 999;
    display: none;
    padding: var(--s-1) var(--gutter);
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .nav.is-open { display: flex }
  .site-main { padding-block: var(--s-3) }
  .hero h1 { font-size: 32px }
  .post-list { margin-top: var(--s-2) }
  .entry-head { flex-direction: column; align-items: flex-start; gap: var(--s-1) }
  .post-list h2 { font-size: 17px }
  .page > h1, .page-head h1 { font-size: 28px }
  .body { font-size: 15px; line-height: 1.65 }
  .body h2, .body h3 { display: block }
  .body img, .body table, .code-window { width: calc(100% + var(--gutter) * 2); max-width: none; margin-inline: calc(var(--gutter) * -1) }
  .heading-anchor { display: inline-block; width: auto; margin: 0 var(--s-1) 0 0; opacity: .55; vertical-align: baseline }
  .heading-text { overflow-wrap: anywhere }
  .code-window pre { padding: var(--gutter); font-size: 12px }
  .footer-inner { justify-content: flex-start }
}
@media (max-width: 390px) {
  .page > h1, .page-head h1 { font-size: 26px }
  .archive-list li { gap: 12px }
  .archive-list time { flex-basis: 72px }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important }
}
