:root {
  color-scheme: light dark;
  --paper: #f7f3ed;
  --paper-deep: #eee7dc;
  --ink: #202522;
  --muted: #687069;
  --line: #d6cec1;
  --accent: #ae4d36;
  --accent-dark: #813522;
  --card: #fffdf9;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", Georgia, serif;
  --sans: "Avenir Next", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.75; }
a { color: inherit; text-underline-offset: 0.18em; }
a:hover { color: var(--accent); }
.shell { width: min(1120px, calc(100% - 48px)); margin-inline: auto; }
.skip-link { position: fixed; z-index: 10; top: -4rem; left: 1rem; padding: .55rem 1rem; background: var(--ink); color: var(--paper); }
.skip-link:focus { top: 1rem; }
.site-header { border-bottom: 1px solid var(--line); }
.nav-shell { min-height: 78px; display: flex; justify-content: space-between; align-items: center; }
.brand { font-family: var(--serif); font-size: 1.65rem; font-weight: 700; letter-spacing: -.06em; text-decoration: none; }
nav { display: flex; gap: 1.4rem; font-size: .86rem; }
nav a { text-decoration: none; color: var(--muted); }
.hero { padding: clamp(4.8rem, 12vw, 9.5rem) 0 4rem; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 .8rem; color: var(--accent); font-family: var(--sans); font-size: .7rem; font-weight: 700; letter-spacing: .13em; line-height: 1.4; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.25; letter-spacing: -.045em; }
.hero h1 { max-width: 800px; margin: 0; font-size: clamp(3.1rem, 8vw, 6.6rem); font-weight: 500; }
.hero-copy { max-width: 540px; margin: 2rem 0 1.6rem; color: var(--muted); font-size: 1.08rem; }
.author-line, .article-byline { display: flex; align-items: center; gap: .75rem; font-size: .8rem; color: var(--muted); }
.monogram { display: inline-grid; place-items: center; width: 2.45rem; height: 2.45rem; border-radius: 50%; background: var(--ink); color: var(--paper); font-family: var(--serif); font-size: .78rem; }
.search-section { padding: 2.2rem 0; border-bottom: 1px solid var(--line); }
.search-section label { display: block; margin-bottom: .45rem; font-size: .8rem; font-weight: 700; }
.search-control { display: flex; max-width: 620px; }
input[type="search"] { width: 100%; min-height: 48px; padding: 0 .9rem; border: 1px solid var(--line); border-radius: 0; background: var(--card); color: var(--ink); font: inherit; }
button, .button-link { min-height: 48px; border: 0; padding: 0 1.1rem; background: var(--ink); color: var(--paper); font: inherit; font-size: .85rem; font-weight: 700; text-decoration: none; cursor: pointer; }
button:hover, .button-link:hover { background: var(--accent); color: white; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 255px; gap: clamp(2.5rem, 7vw, 7rem); padding: 4.5rem 0 6rem; }
.featured-post { padding: 0 0 3.3rem; border-bottom: 1px solid var(--line); }
.featured-post h2 { max-width: 760px; margin: .3rem 0 1rem; font-size: clamp(2rem, 4vw, 3.45rem); font-weight: 500; }
.featured-post h2 a, .post-card h3 a { text-decoration: none; }
.featured-post > p:not(.post-meta) { max-width: 680px; margin-bottom: 1.2rem; color: var(--muted); }
.post-meta { margin: 0 0 .55rem; color: var(--muted); font-size: .72rem; letter-spacing: .04em; }
.text-link { font-size: .85rem; font-weight: 700; }
.section-heading { margin: 3.3rem 0 1.1rem; }
.section-heading h2, .topic-panel h2, .related h2 { margin: 0; font-size: 1.3rem; font-weight: 600; }
.post-list { display: grid; gap: 0; }
.post-card { padding: 1.9rem 0 1.65rem; border-bottom: 1px solid var(--line); }
.post-card h3 { max-width: 660px; margin: 0 0 .55rem; font-size: 1.55rem; font-weight: 600; }
.post-card > p:not(.post-meta) { max-width: 650px; margin: 0; color: var(--muted); font-size: .94rem; }
.post-card-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
.post-card-bottom > a { font-size: 1.35rem; text-decoration: none; }
.inline-tags { display: flex; flex-wrap: wrap; gap: .45rem; }
.inline-tags span { padding: .18rem .5rem; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: .68rem; }
.topic-panel { align-self: start; position: sticky; top: 1.5rem; padding: 1.45rem; background: var(--paper-deep); }
.tag-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.tag-list a { padding: .35rem .6rem; border: 1px solid var(--line); background: var(--paper); font-size: .75rem; text-decoration: none; }
.tag-list span { margin-left: .25rem; color: var(--muted); }
.empty-state { padding: 2rem 0; color: var(--muted); }
.article-shell { max-width: 820px; padding-top: 3rem; padding-bottom: 6rem; }
.back-link { font-size: .84rem; color: var(--muted); }
.article { margin-top: 3.5rem; }
.article-header { padding-bottom: 3.3rem; border-bottom: 1px solid var(--line); }
.article-header h1 { margin: .5rem 0 1.1rem; font-size: clamp(2.6rem, 6vw, 4.7rem); font-weight: 500; }
.article-summary { max-width: 650px; color: var(--muted); font-size: 1.12rem; }
.article-byline { margin-top: 2rem; }
.prose { max-width: 690px; padding-top: 3rem; font-family: var(--serif); font-size: 1.08rem; line-height: 2; }
.prose h2, .prose h3 { margin-top: 3rem; font-weight: 600; }
.prose h2 { font-size: 1.75rem; }
.prose h3 { font-size: 1.35rem; }
.prose a { color: var(--accent-dark); }
.prose blockquote { margin: 2rem 0; padding: .15rem 1.35rem; border-left: 3px solid var(--accent); color: var(--muted); }
.prose pre { overflow-x: auto; padding: 1.25rem; background: #262b28; color: #f5f0e8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; line-height: 1.65; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; }
.prose :not(pre) > code { padding: .12em .3em; background: var(--paper-deep); }
.prose .mermaid { overflow-x: auto; margin: 2rem 0; padding: 1rem; border: 1px solid var(--line); background: var(--card); }
.prose .mermaid svg { display: block; max-width: 100%; height: auto; margin: auto; }
.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-family: var(--sans); font-size: .88rem; }
.prose th, .prose td { padding: .5rem .75rem; border: 1px solid var(--line); text-align: left; }
.related { margin-top: 5rem; padding-top: 2rem; border-top: 1px solid var(--line); }
.archive, .about, .not-found { padding-top: 5rem; padding-bottom: 7rem; }
.archive h1, .about h1, .not-found h1 { margin: 0; font-size: clamp(2.8rem, 6vw, 5.3rem); font-weight: 500; }
.archive-intro { margin: .5rem 0 2.5rem; color: var(--muted); }
.archive-tags { margin-top: 3.5rem; }
.about-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 5rem; margin-top: 3.5rem; }
.about-lead { margin-top: 0; font-family: var(--serif); font-size: 1.55rem; line-height: 1.65; }
.about aside { align-self: start; padding: 1.5rem; background: var(--paper-deep); }
.about aside h2 { margin-top: 0; }
.repo-note { margin: 1.6rem 0 0; font-size: .82rem; color: var(--muted); }
.not-found p:not(.eyebrow) { color: var(--muted); }
.not-found .button-link { display: inline-flex; align-items: center; margin-top: 1rem; }
.site-footer { border-top: 1px solid var(--line); }
.footer-inner { display: flex; justify-content: space-between; gap: 1rem; padding: 2rem 0; color: var(--muted); font-size: .78rem; }
.footer-inner p { margin: 0; }
.footer-inner strong { color: var(--ink); }

@media (max-width: 720px) {
  .shell { width: min(100% - 32px, 1120px); }
  .nav-shell { min-height: 66px; }
  nav { gap: .85rem; }
  .content-grid, .about-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .topic-panel { position: static; order: -1; }
  .hero { padding-top: 4.5rem; }
  .article { margin-top: 2.4rem; }
  .footer-inner { display: block; }
  .footer-inner div { margin-top: .4rem; }
}

@media (prefers-color-scheme: dark) {
  :root { --paper: #1d211f; --paper-deep: #292e2b; --ink: #f5f0e8; --muted: #b8bdb4; --line: #454c46; --accent: #e98262; --accent-dark: #ff9e7e; --card: #252a27; }
  .prose pre { background: #111412; }
}
