:root {
  color-scheme: light dark;
  --background: #faf9f6;
  --text: #242424;
  --muted: #6a6a66;
  --link: #0057a8;
  --line: #deddd8;
  --code: #efeee9;
  --selection: #d9e9f7;
  --width: 720px;
  --wide: 960px;
  --sans: Verdana, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html {
  background: var(--background);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  text-size-adjust: 100%;
}

body {
  min-width: 300px;
  margin: 0;
  background: var(--background);
}

::selection { background: var(--selection); }

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

a:hover { text-decoration-thickness: 2px; }

a:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--link);
  outline-offset: 3px;
}

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

.site-shell {
  width: min(calc(100% - 40px), var(--width));
  margin-right: auto;
  margin-left: auto;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: -80px;
  left: 16px;
  background: var(--text);
  color: var(--background);
  padding: 8px 12px;
}

.skip-link:focus { top: 16px; }

.site-header { padding-top: 34px; }

.site-header__inner {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.site-brand {
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.site-nav { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 0.88rem; }
.site-nav a { text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--text); font-weight: 700; }

.page-shell { min-height: 68vh; }

.home-intro { padding-top: clamp(64px, 12vw, 108px); padding-bottom: 56px; }

h1, h2, h3 {
  color: var(--text);
  line-height: 1.2;
  text-wrap: balance;
}

.home-intro h1 {
  margin: 0 0 20px;
  font-size: clamp(2rem, 7vw, 3.25rem);
  letter-spacing: -0.045em;
}

.home-intro > p {
  max-width: 660px;
  margin: 0 0 16px;
  font-size: 1.08rem;
}

.home-links { color: var(--muted); font-size: 0.92rem !important; }
.home-links span { padding: 0 0.25em; }

.post-index { padding-bottom: 78px; }

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.section-heading h2 { margin: 0; font-size: 1.2rem; }
.section-heading > a { font-size: 0.86rem; }

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

.post-row {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}

.post-row time, .archive-list time, .stack-list time {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: nowrap;
}

.post-row time { padding-top: 0.2em; }
.post-row h3 { margin: 0 0 3px; font-size: 1rem; }
.post-row h3 a { color: var(--text); text-decoration: none; }
.post-row h3 a:hover { color: var(--link); text-decoration: underline; }
.post-row p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.empty-state { color: var(--muted); padding: 18px 0; }

.article-page { padding-bottom: 70px; }

.article-hero { padding-top: clamp(56px, 10vw, 88px); padding-bottom: 36px; }
.article-hero.compact { padding-bottom: 22px; }

.article-hero h1 {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: clamp(2rem, 7vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.article-description {
  max-width: 660px;
  margin: 0 0 18px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 1.16rem;
  line-height: 1.5;
}

.byline { color: var(--muted); font-size: 0.82rem; }
.byline span::before { content: " · "; }

.article-body {
  border-top: 1px solid var(--line);
  padding-top: 32px;
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.62;
  overflow-wrap: break-word;
}

.article-body > *:first-child { margin-top: 0; }
.article-body p, .article-body ul, .article-body ol, .article-body blockquote { margin: 0 0 1.25em; }
.article-body ul, .article-body ol { padding-left: 1.35em; }
.article-body li { margin-bottom: 0.35em; }

.article-body h2 { margin: 2.2em 0 0.65em; font-family: var(--serif); font-size: 1.65rem; font-weight: 600; letter-spacing: -0.025em; }
.article-body h3 { margin: 1.8em 0 0.55em; font-family: var(--serif); font-size: 1.25rem; font-weight: 600; }

.article-body blockquote {
  border-left: 3px solid var(--line);
  padding-left: 1.15em;
  color: var(--muted);
}

.article-body code {
  border-radius: 3px;
  background: var(--code);
  padding: 0.12em 0.28em;
  font-family: var(--mono);
  font-size: 0.84em;
}

.article-body pre {
  max-width: 100%;
  overflow: auto;
  margin: 1.4em 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--code);
  padding: 16px;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.55;
}

.article-body pre code { background: transparent; padding: 0; }
.article-body hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }

.article-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin-bottom: 1.4em;
  font-family: var(--sans);
  font-size: 0.88rem;
}

.article-body th, .article-body td { border-bottom: 1px solid var(--line); padding: 7px 14px 7px 0; text-align: left; }

.article-body figure { margin: 1.6em 0; }
.article-body figcaption { margin-top: 0.55em; color: var(--muted); font-size: 0.8rem; }

.article-body aside, .article-body .aside, .article-body .side {
  margin: 1.5em 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 13px 15px;
  color: var(--muted);
  font-size: 0.86rem;
}

.article-body > .l-page,
.article-body > .l-page-outset,
.article-body > .l-screen,
.article-body > .l-screen-inset {
  position: relative;
  left: 50%;
  width: min(calc(100vw - 40px), var(--wide));
  max-width: none;
  margin-right: 0;
  margin-left: 0;
  transform: translateX(-50%);
}

.sample-diagram {
  display: grid;
  min-height: 150px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--code);
  color: var(--muted);
  font-size: 0.82rem;
}

.article-footer {
  margin-top: 48px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  color: var(--muted);
  font-size: 0.86rem;
}

.article-footer p { margin: 0 0 8px; }

.listing-page { padding-top: clamp(54px, 10vw, 86px); padding-bottom: 72px; }
.listing-hero { border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.listing-hero h1 { margin: 0 0 8px; font-size: clamp(2rem, 7vw, 3rem); letter-spacing: -0.04em; }
.listing-hero p { margin: 0; color: var(--muted); }

.archive-list li {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 17px 0;
}

.archive-list li > div { display: flex; justify-content: space-between; gap: 18px; }
.archive-list li > div > a:first-child { color: var(--text); font-weight: 700; text-decoration: none; }
.archive-category { color: var(--muted); font-size: 0.78rem; }

.term-cloud { padding-top: 12px; }
.term-cloud > a { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 11px 0; text-decoration: none; }
.term-cloud small { color: var(--muted); }

.stack-list article {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 4px 18px;
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}

.stack-list time { grid-row: 1 / span 2; }
.stack-list h2 { margin: 0; font-size: 1.05rem; }
.stack-list h2 a { color: var(--text); text-decoration: none; }
.stack-list p { margin: 2px 0 0; color: var(--muted); font-size: 0.86rem; }

.pagination { display: flex; justify-content: center; gap: 18px; padding-top: 28px; font-size: 0.84rem; }

.about-page { padding-top: clamp(54px, 10vw, 86px); padding-bottom: 70px; }

.about-hero {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 28px;
}

.about-portrait { width: 112px; aspect-ratio: 1; border-radius: 50%; object-fit: cover; object-position: center 28%; }
.about-hero h1 { margin: 0 0 8px; font-size: clamp(1.85rem, 6vw, 2.6rem); letter-spacing: -0.04em; }
.about-hero p { margin: 3px 0; }
.about-role { color: var(--muted); }

.about-story { padding-top: 28px; font-size: 1.02rem; }
.about-story p { margin: 0 0 1.25em; }
.selected-work, .about-footer { margin-top: 44px; border-top: 1px solid var(--line); padding-top: 22px; }
.about-footer h2 { margin: 0 0 14px; font-size: 1.25rem; }

.selected-work__header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 14px;
}

.section-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.selected-work__header h2 {
  max-width: 470px;
  margin: 0;
  font-size: clamp(1.55rem, 5vw, 2.15rem);
  letter-spacing: -0.035em;
}

.selected-work__header > a { flex: 0 0 auto; font-size: 0.82rem; }

.work-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) max-content;
  gap: 16px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}

.work-index {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding-top: 2px;
}

.work-item h3 { margin: 2px 0 5px; font-size: 1rem; font-weight: 600; }
.work-item div > p:last-child { margin: 0; color: var(--muted); font-size: 0.82rem; }
.work-venue { margin: 0; color: var(--muted); font-size: 0.72rem; }
.work-link { padding-top: 19px; font-size: 0.76rem; white-space: nowrap; }
.about-footer p { margin: 0; }

.not-found { padding-top: 100px; padding-bottom: 80px; }
.not-found h1 { margin: 0 0 16px; font-size: 2rem; }
.not-found p { margin: 0 0 14px; }

.site-footer { border-top: 1px solid var(--line); padding: 20px 0 34px; color: var(--muted); font-size: 0.78rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 18px; }
.footer-inner p { margin: 0; }
.footer-inner nav { display: flex; gap: 14px; }

@media (max-width: 560px) {
  .site-header { padding-top: 22px; }
  .site-header__inner { display: block; }
  .site-nav { margin-top: 8px; }
  .home-intro { padding-top: 52px; }
  .post-row, .archive-list li, .stack-list article { grid-template-columns: 1fr; gap: 4px; }
  .stack-list time { grid-row: auto; }
  .archive-list li > div { display: block; }
  .archive-category { display: block; margin-top: 3px; }
  .about-hero { grid-template-columns: 82px minmax(0, 1fr); gap: 16px; }
  .about-portrait { width: 82px; }
  .selected-work__header { display: block; }
  .selected-work__header > a { display: inline-block; margin-top: 10px; }
  .work-item { grid-template-columns: 26px minmax(0, 1fr); gap: 12px; }
  .work-link { grid-column: 2; padding-top: 0; }
  .article-body > .l-page,
  .article-body > .l-page-outset,
  .article-body > .l-screen,
  .article-body > .l-screen-inset {
    position: static;
    left: auto;
    width: 100%;
    transform: none;
  }
  .footer-inner { display: block; }
  .footer-inner nav { margin-top: 8px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #1c1c1a;
    --text: #eeeeea;
    --muted: #aaa9a2;
    --link: #78b8f3;
    --line: #3d3d39;
    --code: #292927;
    --selection: #254867;
  }
}

@media print {
  :root { --background: #fff; --text: #000; --muted: #444; --link: #000; --line: #bbb; }
  .site-nav, .site-footer, .skip-link, .article-footer { display: none; }
  .site-header { padding-top: 0; }
  .site-header__inner { border: 0; }
  .article-page { width: 100%; }
}
