:root {
  --bg: #ffffff;
  --fg: #161616;
  --muted: #666666;
  --line: #e8e8e8;
  --max: 42rem;
  --wide: 68rem;
  --font-size: 17px;
  --font-body: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-heading: "Noto Serif SC", "Songti SC", "SimSun", serif;
}

* {
  box-sizing: border-box;
}

html[data-ink='light'] {
  --fg: #161616;
  --muted: #3f3f3f;
  --line: rgba(22, 22, 22, 0.2);
}

html[data-ink='dark'] {
  --fg: #f3f3f0;
  --muted: #d0d0cc;
  --line: rgba(255, 255, 255, 0.22);
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: transparent;
  color: var(--fg);
}

html {
  font-size: var(--font-size);
}

body {
  font-family: var(--font-body);
  line-height: 1.8;
}

h1,
h2,
h3,
.brand,
.page-title,
.hero h1 {
  font-family: var(--font-heading);
  font-weight: 650;
  letter-spacing: 0.03em;
  line-height: 1.35;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--fg);
}

.shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: var(--bg-color, var(--bg));
}

.bg-layer[data-mode='solid'] {
  background: var(--bg-color, var(--bg));
}

.bg-layer[data-mode='image'] {
  --bg-veil: 0.12;
  background-color: var(--bg);
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
}

.bg-layer[data-mode='image']::after,
.bg-layer[data-mode='dynamic']::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(255, 255, 255, var(--bg-veil, 0.08));
}

.bg-layer[data-mode='dynamic'] {
  background: #111;
}

.bg-layer[data-mode='dynamic'] .bg-canvas,
.bg-layer[data-mode='dynamic'] .bg-video {
  z-index: 0;
}

.bg-layer[data-mode='dynamic'][data-kind='nature'] {
  --bg-veil: 0.06;
}

.bg-layer[data-mode='dynamic'][data-kind='space'] {
  --bg-veil: 0.03;
}

.bg-canvas,
.bg-video {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.bg-video {
  object-fit: cover;
}

.bg-layer[data-mode='blackhole'] {
  background: #000;
}

.site-header,
.site-footer,
.body {
  position: relative;
  z-index: 1;
  width: 100%;
}

html[data-ink='dark'] .site-header,
html[data-ink='dark'] .body,
html[data-ink='dark'] .site-footer > span {
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
}

html[data-ink='light'] .site-header,
html[data-ink='light'] .body,
html[data-ink='light'] .site-footer > span {
  text-shadow: 0 1px 8px rgba(255, 255, 255, 0.5);
}

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.6rem 1.5rem 1.2rem;
}

.brand {
  font-size: 1.15rem;
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.15rem;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
}

.nav a[aria-current='page'],
.nav a:hover {
  color: var(--fg);
}

.body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: var(--wide);
  width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.body[data-has-sidebar='true'] {
  grid-template-columns: minmax(0, 1fr) 18rem;
  gap: 2.5rem;
  align-items: start;
}

main {
  max-width: var(--max);
  width: 100%;
}

.body:not([data-has-sidebar='true']) main {
  margin: 0 auto;
}

.sidebar-slot {
  position: sticky;
  top: 1.5rem;
  min-height: 12rem;
  border: 1px dashed var(--line);
  padding: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.sidebar-slot[hidden] {
  display: none;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
  color: var(--muted);
  font-size: 0.88rem;
  position: relative;
}

.bg-picker {
  position: relative;
}

.bg-toggle {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.bg-toggle:hover,
.bg-toggle[aria-expanded='true'] {
  color: var(--fg);
}

.bg-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.7rem);
  width: min(24rem, calc(100vw - 3rem));
  max-height: min(70vh, 32rem);
  overflow: auto;
  background: #fff;
  color: #222;
  --fg: #161616;
  --muted: #666666;
  --line: #e8e8e8;
  border: 1px solid var(--line);
  padding: 0.75rem;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.08);
  z-index: 6;
}

.bg-panel-label {
  margin: 0.7rem 0 0.45rem;
  font-size: 0.82rem;
}

.bg-panel-label:first-child {
  margin-top: 0;
}

.bg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 0.45rem;
}

.bg-grid button {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: #f6f6f4;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.bg-grid button span {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding-bottom: 0.35rem;
}

.bg-swatch span {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.bg-grid button.bg-swatch-mountains {
  background: linear-gradient(#c5d6e6, #6f8ea3 52%, #3a4a54);
}

.bg-grid button.bg-swatch-forest {
  background: linear-gradient(#d5e4d4, #5d805c 48%, #243b28);
}

.bg-grid button.bg-swatch-river {
  background: linear-gradient(#d7e6f0, #5b92b3 55%, #2d5c75);
}

.bg-grid button.bg-swatch-stars {
  background: radial-gradient(circle at 50% 40%, #4a5578, #0c0e14);
}

.bg-grid button.bg-swatch-galaxy {
  background: radial-gradient(circle at 50% 45%, #d4b8f0, #3a2a6a 40%, #07060d);
}

.bg-grid button.bg-swatch-blackhole {
  background: radial-gradient(circle at 50% 50%, #ffd18a, #a33a12 28%, #050505 48%);
}

.bg-grid button.bg-swatch-photo {
  background-color: #111;
  background-size: cover;
  background-position: center;
}

.bg-grid button[aria-pressed='true'] {
  outline: 2px solid var(--fg);
  outline-offset: 1px;
}

.bg-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.prose img,
.prose-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.15rem 0;
}

.prose-figure {
  margin: 1.4rem 0;
}

.prose-figure figcaption {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 0.35rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin: 1.5rem 0 0.4rem;
}

.lede {
  color: var(--muted);
  margin: 0 0 2.5rem;
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  border-top: 1px solid var(--line);
}

.post-list a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 0;
  text-decoration: none;
}

.post-list time {
  color: var(--muted);
  flex: none;
  font-variant-numeric: tabular-nums;
}

.page-title {
  font-size: 1.85rem;
  margin: 1.2rem 0 1.5rem;
}

.prose :first-child {
  margin-top: 0;
}

.prose {
  font-size: 1.02em;
}

.prose p {
  margin: 0 0 1.15rem;
}

.prose h2,
.prose h3 {
  margin: 2rem 0 0.8rem;
}

.post-meta {
  color: var(--muted);
  margin: -0.8rem 0 2rem;
}

.comment-slot[hidden],
.comment-slot:empty {
  display: none;
}

.muted {
  color: var(--muted);
}

@media (max-width: 860px) {
  .body[data-has-sidebar='true'] {
    grid-template-columns: 1fr;
  }

  .post-list a {
    flex-direction: column;
    gap: 0.2rem;
  }
}
