@font-face {
  font-family: "Fusion Pixel 12px";
  src: url("../fonts/fusion-pixel-12px-zh-hans.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400 500;
}

:root {
  --black: #111214;
  --gray: #687078;
  --white: #f1f3f4;
  --math-blue: #2457d6;
  --math-red: #c32f27;
  --math-green: #27813c;
  --math-purple: #7846a8;
  --math-orange: #c65d16;
  --font: "Pixelify Sans", "Fusion Pixel 12px", monospace;
  --page: min(1120px, calc(100% - 40px));
}

:root[data-theme="night"] {
  --black: #e8e8e8;
  --gray: #999;
  --white: #121212;
  --math-blue: #7aa2ff;
  --math-red: #ff7b72;
  --math-green: #7ee787;
  --math-purple: #d2a8ff;
  --math-orange: #ffa657;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--black); background: var(--white); font-family: var(--font); font-size: 14px; font-synthesis: none; cursor: url("../cursors/cat.png") 3 2, url("../cursors/cat.svg") 3 2, auto; transition: color 160ms steps(2, end), background-color 160ms steps(2, end); }
a { color: inherit; text-underline-offset: 4px; }
button { color: inherit; background: none; font: inherit; }
a, button, video, [role="button"] { cursor: url("../cursors/cat.png") 3 2, url("../cursors/cat.svg") 3 2, pointer; }
:focus-visible { outline: 1px solid var(--black); outline-offset: 4px; }
.skip { position: fixed; left: 12px; top: -50px; padding: 8px; background: var(--white); z-index: 5; }
.skip:focus { top: 12px; }

.identity { width: var(--page); min-height: 180px; margin: 0 auto; padding: 42px 0 32px; display: flex; flex-direction: column; justify-content: space-between; }
.identity h1 { margin: 0; font-size: 16px; line-height: 1.5; letter-spacing: 0; font-weight: 400; }
.identity h1 span { display: inline-block; animation: cursor 1s steps(1) infinite; }
.identity p { margin: 48px 0 0; color: var(--gray); }
@keyframes cursor { 50% { opacity: 0; } }

.identity-controls { align-self: flex-end; display: flex; align-items: flex-end; gap: 22px; }
#catgirl {
  margin: 0;
  padding: 4px;
  border: 0;
  white-space: pre;
  color: var(--black);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1;
  letter-spacing: -0.04em;
  user-select: none;
  transition: transform 160ms steps(2, end), opacity 160ms steps(2, end);
}
#catgirl:hover, #catgirl:focus-visible, #catgirl[data-state="happy"] { transform: translateY(-2px); }
#catgirl[data-state="annoyed"] { transform: translateY(1px); }
#catgirl[data-state="sleeping"] { opacity: 0.64; }

.theme-toggle {
  margin: 0;
  padding: 4px;
  border: 0;
  white-space: pre;
  color: var(--black);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0;
  text-align: left;
  user-select: none;
  transition: transform 160ms steps(2, end);
}
.theme-toggle:hover, .theme-toggle:focus-visible { transform: translateX(2px); }
.article-nav .theme-toggle { align-self: center; margin-left: auto; font-size: 8px; }

.relations { min-height: 72px; padding: 20px max(20px, calc((100% - 1120px) / 2)); display: flex; align-items: center; gap: 14px; border-top: 1px solid var(--black); border-bottom: 1px solid var(--black); white-space: nowrap; overflow-x: auto; }
.relations a:hover, .relations a:focus-visible { text-decoration-style: dashed; }

.index { width: var(--page); margin: 0 auto; padding: 90px 0 140px; }
.index-header { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 52px; }
h2 { margin: 0; font-size: 16px; font-weight: 500; }
.filters { display: flex; gap: 18px; }
.filters button { padding: 0 0 3px; border: 0; color: var(--gray); }
.filters button::before { content: "["; }
.filters button::after { content: "]"; }
.filters button.active { color: var(--black); text-decoration: underline; text-decoration-style: dashed; text-underline-offset: 5px; }

.column-labels, .entry a { display: grid; grid-template-columns: 64px 100px minmax(220px, 1fr) 80px 36px; gap: 16px; }
.column-labels { padding: 9px 12px; color: var(--gray); border-bottom: 1px solid var(--black); font-size: 10px; }
.entries { margin: 0; padding: 0; list-style: none; }
.entry { border-bottom: 1px dashed var(--gray); }
.entry a { position: relative; min-height: 78px; align-items: center; padding: 12px; text-decoration: none; }
.entry a::before { content: ">"; position: absolute; opacity: 0; transform: translateX(-10px); }
.entry a:hover::before, .entry a:focus-visible::before { opacity: 1; }
.entry a:hover .title, .entry a:focus-visible .title { text-decoration: underline; text-decoration-style: dashed; text-underline-offset: 5px; }
.entry .number, .entry .type, .entry time, .entry .link { font-size: 11px; }
.entry .number, .entry time { color: var(--gray); }
.entry .title { font-size: clamp(15px, 2vw, 21px); }
.entry .link { justify-self: end; }
.empty { padding: 30px 12px; border-bottom: 1px dashed var(--gray); color: var(--gray); }
.prettiest { margin: 110px 0 0; }
.prettiest a { display: block; }
.prettiest img { display: block; width: 100%; height: auto; border: 1px solid var(--black); filter: grayscale(1); image-rendering: pixelated; }
.prettiest figcaption { margin-top: 12px; color: var(--gray); font-size: 11px; text-align: center; }
.prettiest a:hover + figcaption, .prettiest a:focus-visible + figcaption { color: var(--black); text-decoration: underline dashed; text-underline-offset: 4px; }

.contact { min-height: 170px; padding: 36px max(20px, calc((100% - 1120px) / 2)); display: grid; grid-template-columns: 1fr repeat(3, auto) 1fr; align-items: start; gap: 32px; border-top: 1px solid var(--black); }
.contact > span { color: var(--gray); }
.contact .top { justify-self: end; }

/* Plain-text content pages */
.article-shell { width: min(760px, calc(100% - 40px)); margin: 0 auto; }
.article-nav { min-height: 72px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--black); }
.article-nav .current { color: var(--gray); }
.article { padding: 76px 0 120px; }
.article-header { margin-bottom: 72px; }
.article-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 28px; color: var(--gray); font-size: 11px; }
.article h1 { max-width: 18ch; margin: 0; font-size: clamp(27px, 6vw, 48px); font-weight: 400; line-height: 1.08; }
.article .lead { max-width: 58ch; margin: 28px 0 0; color: var(--gray); font-size: 16px; line-height: 1.7; }
.article-section { margin-top: 68px; }
.article h2 { padding-bottom: 10px; border-bottom: 1px solid var(--black); font-size: 17px; }
.article h2::before { content: ":: "; color: var(--gray); }
.article h3 { margin: 42px 0 16px; font-size: 14px; font-weight: 500; }
.article h3::before { content: "[+] "; color: var(--gray); }
.article p { margin: 20px 0; line-height: 1.8; }
.article-media { margin: 34px 0 0; }
.article-media img, .article-media video { display: block; width: 100%; height: auto; border: 1px solid var(--black); background: var(--white); }
.article-media img { filter: grayscale(1); image-rendering: pixelated; }
.article-media figcaption { margin-top: 10px; color: var(--gray); font-size: 11px; }
.article-media figcaption::before { content: "|_ "; }
.math-block {
  --math-color: var(--math-blue);
  margin: 28px 0;
  padding: 22px 12px;
  overflow-x: auto;
  border-top: 1px dashed var(--gray);
  border-bottom: 1px dashed var(--gray);
  color: var(--math-color);
  text-align: center;
}
.math-block .katex { color: var(--math-color); }
.math-block[data-math-color="blue"] { --math-color: var(--math-blue); }
.math-block[data-math-color="red"] { --math-color: var(--math-red); }
.math-block[data-math-color="green"] { --math-color: var(--math-green); }
.math-block[data-math-color="purple"] { --math-color: var(--math-purple); }
.math-block[data-math-color="orange"] { --math-color: var(--math-orange); }
.article-footer { min-height: 130px; padding: 30px 0; border-top: 1px solid var(--black); display: flex; justify-content: space-between; gap: 20px; }
.character-art { margin: 56px 0; padding: 28px 0; overflow-x: auto; border-top: 1px dashed var(--gray); border-bottom: 1px dashed var(--gray); font: inherit; line-height: 1.2; }
.references p { margin-block: 12px; font-size: 12px; }
.map-table, .mapping-table { margin: 28px 0; border-top: 1px solid var(--black); }
.map-table [role="row"], .mapping-table [role="row"] { display: grid; border-bottom: 1px dashed var(--gray); }
.map-table [role="row"] { grid-template-columns: 90px 1fr 1.25fr; }
.mapping-table [role="row"] { grid-template-columns: 1fr 1fr; }
.map-table span, .mapping-table span { padding: 10px 8px; }
.map-table [role="columnheader"], .mapping-table [role="columnheader"] { color: var(--gray); font-size: 11px; }

@media (max-width: 680px) {
  :root { --page: calc(100% - 24px); }
  body { font-size: 12px; }
  .identity { min-height: 160px; padding-top: 32px; }
  .identity-controls { gap: 14px; }
  #catgirl { font-size: 10px; }
  .theme-toggle { font-size: 10px; }
  .identity p { margin-top: 36px; }
  .relations { padding-inline: 12px; }
  .index { padding: 65px 0 90px; }
  .prettiest { margin-top: 72px; }
  .index-header { display: block; }
  .filters { margin-top: 28px; gap: 12px; }
  .column-labels { display: none; }
  .entry a { min-height: 76px; grid-template-columns: 30px 1fr 30px; gap: 10px; padding: 10px 4px; }
  .entry .type, .entry time { display: none; }
  .entry .title { grid-column: 2; }
  .entry .link { grid-column: 3; }
  .contact { min-height: 220px; padding-inline: 12px; grid-template-columns: 1fr 1fr; gap: 24px; }
  .contact > span, .contact .top { grid-column: 1 / -1; }
  .contact .top { justify-self: start; }
  .article-shell { width: calc(100% - 24px); }
  .article { padding: 52px 0 80px; }
  .article-header { margin-bottom: 54px; }
  .article .lead { font-size: 14px; }
  .article-section { margin-top: 52px; }
  .math-block { padding-inline: 4px; }
  .map-table [role="row"] { grid-template-columns: 64px 1fr 1.2fr; }
  .map-table span, .mapping-table span { padding-inline: 4px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .identity h1 span { animation: none; }
  body, #catgirl, .theme-toggle { transition: none; }
}
