:root {
  color-scheme: light dark;
  --surface: #f4f5f7;
  --surface-raised: #e9ebef;
  --text: #181a1f;
  --text-muted: #626773;
  --line: #cfd3da;
  --accent: #3159c7;
  --code-surface: #e5e8ee;
  --content-width: 46rem;
  --page-width: 74rem;
  --radius: 0.35rem;
  font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #131416;
    --surface-raised: #1b1d21;
    --text: #f0f0ed;
    --text-muted: #a2a5ad;
    --line: #303238;
    --accent: #8ba9ff;
    --code-surface: #202329;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--surface);
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
}

img,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 0.18rem solid var(--accent);
  outline-offset: 0.22rem;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--surface);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header,
.site-footer,
main {
  width: min(calc(100% - 3rem), var(--page-width));
  margin-inline: auto;
}

.site-header {
  display: flex;
  min-height: 4.5rem;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.site-name {
  font-size: 1.08rem;
  font-weight: 720;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.site-nav,
.site-footer nav {
  display: flex;
  align-items: center;
  gap: 1.35rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.site-nav a,
.site-footer a {
  text-decoration: none;
}

.site-nav [aria-current="page"] {
  color: var(--text);
}

main {
  min-height: calc(100dvh - 13rem);
}

.home-intro {
  max-width: 55rem;
  padding: clamp(4rem, 10vw, 8rem) 0 clamp(3rem, 7vw, 5.5rem);
}

.home-label,
.post-kicker {
  margin: 0 0 0.85rem;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.home-intro h1,
.archive-header h1,
.not-found h1,
.page-header h1,
.post-header h1,
.post-preview h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.home-intro h1 {
  max-width: 15ch;
  margin: 0;
  font-size: clamp(2.65rem, 7.2vw, 5.6rem);
  line-height: 0.98;
}

.home-intro > p:last-child {
  max-width: 40rem;
  margin: 1.75rem 0 0;
  color: var(--text-muted);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
}

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

.post-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  padding: clamp(2.25rem, 5vw, 4.5rem) 0;
  border-bottom: 1px solid var(--line);
}

.post-preview.has-image {
  grid-template-columns: minmax(0, 1.55fr) minmax(14rem, 0.8fr);
  align-items: center;
}

.post-preview h2 {
  max-width: 30ch;
  margin: 0;
  font-size: clamp(1.65rem, 3.5vw, 2.8rem);
  line-height: 1.08;
}

.post-preview h2 a {
  text-decoration: none;
}

.post-preview-copy > p {
  max-width: 55rem;
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: clamp(1rem, 1.4vw, 1.08rem);
  line-height: 1.6;
}

.post-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.post-kicker a {
  text-decoration: none;
}

.post-kicker span {
  color: var(--text);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-top: 1.25rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.post-preview-image {
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  background: var(--surface-raised);
}

.post-preview-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 220ms ease;
}

.post-preview:hover .post-preview-image img {
  transform: scale(1.018);
}

.post,
.page {
  padding: clamp(3rem, 8vw, 7rem) 0 clamp(5rem, 10vw, 9rem);
}

.post-header,
.page-header {
  max-width: 61rem;
  margin-bottom: clamp(3rem, 7vw, 6rem);
}

.post-header h1,
.page-header h1 {
  max-width: 20ch;
  margin: 0;
  font-size: clamp(2.65rem, 7vw, 5.8rem);
  line-height: 0.98;
}

.post-deck,
.page-header p {
  max-width: 48rem;
  margin: 1.6rem 0 0;
  color: var(--text-muted);
  font-size: clamp(1.1rem, 2.2vw, 1.4rem);
  line-height: 1.55;
}

.feature-image {
  width: min(100%, var(--page-width));
  margin: clamp(2.5rem, 6vw, 5rem) 0 0;
}

.feature-image img {
  width: 100%;
  max-height: 46rem;
  border-radius: var(--radius);
  object-fit: cover;
}

figcaption {
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.post-content {
  max-width: var(--content-width);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.08rem, 1.65vw, 1.22rem);
  line-height: 1.82;
}

.post-content > *:first-child {
  margin-top: 0;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  margin: 2.5em 0 0.65em;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.post-content h2 {
  font-size: 1.75em;
}

.post-content h3 {
  font-size: 1.35em;
}

.post-content p,
.post-content ul,
.post-content ol,
.post-content blockquote,
.post-content pre,
.post-content figure,
.post-content table,
.post-content .kg-card {
  margin-block: 1.55em;
}

.post-content a {
  color: var(--accent);
}

.post-content blockquote {
  margin-inline: 0;
  padding-left: 1.25rem;
  border-left: 0.22rem solid var(--accent);
  color: var(--text-muted);
  font-style: italic;
}

.post-content code {
  padding: 0.1em 0.28em;
  border-radius: var(--radius);
  background: var(--code-surface);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.84em;
}

.post-content pre {
  overflow-x: auto;
  padding: 1.2rem;
  border-radius: var(--radius);
  background: var(--code-surface);
  line-height: 1.55;
}

.post-content pre code {
  padding: 0;
  background: none;
}

.post-content :not(pre) > code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.88em;
}

.post-content th,
.post-content td {
  padding: 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.post-content figure,
.post-content .kg-width-wide,
.post-content .kg-gallery-card,
.post-content .kg-embed-card {
  width: min(100vw - 3rem, 64rem);
  margin-inline: 0;
}

.post-content .kg-width-full {
  width: min(100vw - 3rem, var(--page-width));
}

.post-content iframe {
  width: 100%;
  max-width: 100%;
  min-height: 24rem;
  border: 0;
  border-radius: var(--radius);
}

.kg-gallery-container,
.kg-gallery-row {
  display: grid;
  gap: 0.55rem;
}

.kg-gallery-row {
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.kg-callout-card {
  padding: 1rem 1.1rem;
  border-left: 0.22rem solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-raised);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9em;
}

.kg-bookmark-card a {
  display: grid;
  grid-template-columns: 1fr minmax(7rem, 12rem);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

.kg-bookmark-content {
  padding: 1rem;
}

.kg-bookmark-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-tags {
  display: flex;
  max-width: var(--content-width);
  flex-wrap: wrap;
  gap: 0.7rem 1.25rem;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  text-transform: capitalize;
}

.archive-header,
.not-found {
  max-width: 52rem;
  padding: clamp(4rem, 10vw, 8rem) 0 clamp(3rem, 7vw, 5rem);
}

.archive-header h1,
.not-found h1 {
  margin: 0;
  font-size: clamp(2.8rem, 7vw, 5.5rem);
  line-height: 1;
}

.author-header > img {
  margin-bottom: 1.5rem;
  border-radius: 50%;
}

.author-header > p:last-child,
.not-found > p {
  max-width: 40rem;
  color: var(--text-muted);
}

.compact .post-preview {
  padding-block: 2.25rem;
}

.compact .post-preview h2 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

.empty-state {
  padding-block: 3rem;
  color: var(--text-muted);
}

.text-link {
  display: inline-block;
  margin-top: 1rem;
  color: var(--accent);
  font-weight: 650;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-top: clamp(4rem, 9vw, 8rem);
  padding: 2.5rem 0;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 48rem) {
  .site-header,
  .site-footer,
  main {
    width: min(calc(100% - 2rem), var(--page-width));
  }

  .site-nav {
    gap: 0.9rem;
  }

  .post-preview.has-image {
    grid-template-columns: 1fr;
  }

  .post-preview-image {
    grid-row: 1;
    aspect-ratio: 16 / 10;
  }

  .post-content figure,
  .post-content .kg-card,
  .post-content .kg-width-wide,
  .post-content .kg-width-full {
    width: 100%;
  }

  .post-content iframe {
    min-height: 15rem;
  }

  .site-footer {
    align-items: flex-start;
  }
}

@media (max-width: 31rem) {
  .site-header {
    align-items: flex-start;
    padding-block: 1rem;
  }

  .site-nav {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .site-footer {
    flex-direction: column;
    gap: 0.8rem;
  }

  .kg-bookmark-card a {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .site-header,
  .site-footer,
  .post-tags {
    display: none;
  }

  :root {
    --surface: #fff;
    --text: #111;
    --text-muted: #444;
  }

  main,
  .post-content {
    width: 100%;
    max-width: none;
  }
}
