:root {
  color-scheme: dark;
  --bg: #171a1d;
  --surface: #1d2125;
  --surface-raised: #22272c;
  --text: #d9dbd7;
  --text-strong: #f0f1ed;
  --muted: #9ca39f;
  --accent: #79a37b;
  --accent-strong: #91b993;
  --rule: #343a3f;
  --max: 1344px;
  --reading: 65ch;
  --sans: "Noto Sans JP", "Yu Gothic", "YuGothic", "Hiragino Kaku Gothic ProN", sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body { margin: 0; color: var(--text); background: var(--bg); font-family: var(--sans); font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased; }
body::selection { color: var(--bg); background: var(--accent-strong); }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .25em; }
button, input, select { font: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; left: 16px; top: 12px; padding: 9px 14px; color: var(--bg); background: var(--accent-strong); transform: translateY(-180%); }
.skip-link:focus { transform: none; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 4px; }

.site-header { width: min(calc(100% - 64px), var(--max)); min-height: 82px; margin: auto; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--rule); }
.brand { display: flex; flex-direction: column; color: var(--text-strong); font-size: 23px; font-weight: 700; line-height: 1; letter-spacing: .11em; text-decoration: none; }
.brand span { margin-top: 8px; color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .04em; }
.site-header nav, .site-footer nav { display: flex; align-items: center; gap: 38px; font-size: 14px; font-weight: 600; }
.site-header nav a, .site-footer nav a, .nav-search { color: var(--text); text-decoration: none; }
.site-header nav a:hover, .site-footer nav a:hover, .nav-search:hover { color: var(--accent-strong); }
.nav-search { padding: 8px 0; border: 0; border-bottom: 1px solid var(--muted); background: transparent; }
.menu-button { display: none; color: var(--text); border: 1px solid var(--rule); background: var(--surface); padding: 8px 12px; }

main { width: min(calc(100% - 64px), var(--max)); margin: 28px auto 0; }
.hero { height: 336px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(480px, 1fr); overflow: hidden; background: var(--bg); }
.hero > img { width: 100%; height: 336px; grid-column: 2; grid-row: 1; object-fit: cover; object-position: center; }
.hero-copy { max-width: 650px; padding: 28px 34px 32px 0; grid-column: 1; grid-row: 1; }
.category { margin: 0; color: var(--accent-strong); font: 500 13px/1.4 var(--mono); }
.hero h1 { max-width: 650px; margin: 18px 0 20px; color: var(--text-strong); font-size: clamp(38px, 3.2vw, 46px); line-height: 1.16; letter-spacing: -.045em; white-space: nowrap; }
.hero-copy > p:not(.category) { max-width: var(--reading); margin: 0 0 26px; color: #c5c9c5; font-size: clamp(16px, 1.3vw, 18px); line-height: 1.75; }
.text-link { display: inline-flex; align-items: center; gap: 20px; color: var(--accent-strong); font-weight: 700; text-decoration: none; border-bottom: 1px solid currentColor; padding: 5px 0 7px; }
.text-link:hover { color: var(--text-strong); }

.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 304px; gap: 18px; margin-top: 14px; }
.home-primary { min-width: 0; }
.search-panel { position: relative; min-height: 188px; padding: 16px 30px 18px; border: 1px solid var(--rule); background: var(--surface); }
.search-panel > label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 13px; }
.search-panel > input { width: 100%; height: 50px; padding: 0 18px; border: 2px solid var(--accent); border-radius: 9px; color: var(--text-strong); background: #14171a; font-size: 17px; }
.search-panel > input:focus { border-color: var(--accent-strong); outline: 0; box-shadow: 0 0 0 3px rgba(121, 163, 123, .17); }
.search-suggestions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 26px; margin-top: 13px; }
.search-suggestions span { width: 100%; color: var(--muted); font-size: 12px; }
.search-suggestions button { padding: 0 0 4px; color: var(--text); border: 0; border-bottom: 1px solid transparent; background: transparent; font-weight: 600; }
.search-suggestions button:hover { color: var(--accent-strong); border-bottom-color: currentColor; }
.search-status, .form-status { min-height: 1.4em; margin: 8px 0 0; color: var(--accent-strong); font-size: 12px; }

.latest { padding: 16px 0 42px; }
.latest > h2, .side-panel h2 { margin: 0; color: var(--text-strong); font-size: 19px; line-height: 1.4; }
.latest > h2 { padding: 0 0 12px; border-bottom: 1px solid var(--rule); }
.post-list.is-filtered .post-row[hidden] { display: none; }
.post-row { display: grid; grid-template-columns: 100px 66px minmax(0, 1fr) 28px; gap: 18px; align-items: start; min-height: 86px; padding: 17px 0; border-bottom: 1px solid var(--rule); }
.post-row time { padding-top: 3px; color: var(--muted); font: 12px/1.5 var(--mono); }
.post-row .category { padding-top: 3px; font-size: 12px; }
.post-row h3 { margin: 0; color: var(--text-strong); font-size: 18px; line-height: 1.45; }
.post-row h3 a { text-decoration: none; }
.post-row h3 a:hover { color: var(--accent-strong); }
.post-row div > p { max-width: var(--reading); margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.row-link { padding-top: 4px; color: var(--text); text-decoration: none; }
.row-link:hover { color: var(--accent-strong); }

.home-sidebar { display: flex; flex-direction: column; gap: 16px; }
.side-panel { padding: 24px 26px; border: 1px solid var(--rule); background: var(--surface); }
.side-panel h2 { padding-bottom: 14px; border-bottom: 1px solid var(--rule); }
.side-panel select { width: 100%; min-height: 46px; margin-top: 16px; padding: 10px 13px; color: var(--text); border: 1px solid #4a5258; border-radius: 2px; background: #171a1d; }
.topic-list { display: grid; }
.topic-list a { display: grid; gap: 3px; padding: 15px 0; color: var(--text-strong); border-bottom: 1px solid var(--rule); text-decoration: none; }
.topic-list a:last-child { border-bottom: 0; }
.topic-list a:hover span { color: var(--accent-strong); }
.topic-list small { color: var(--muted); font-size: 12px; }

.site-footer { width: min(calc(100% - 64px), var(--max)); min-height: 128px; margin: 30px auto 0; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 48px; border-top: 1px solid var(--rule); }
.site-footer p { color: var(--muted); font: 11px var(--mono); }

/* Article */
.reading-progress { position: fixed; z-index: 60; left: 0; top: 0; width: 0; height: 3px; background: var(--accent-strong); }
.breadcrumb { width: min(100%, 1180px); margin: 26px auto; display: flex; flex-wrap: wrap; gap: 9px; color: var(--muted); font-size: 12px; }
.breadcrumb a { color: var(--accent-strong); }
.article-shell { width: min(100%, 1180px); margin: 0 auto; display: grid; grid-template-columns: 210px minmax(0, 690px) 1fr; gap: 46px; }
.article-header { grid-column: 2 / 4; max-width: 900px; padding: 10px 0 34px; border-bottom: 1px solid var(--rule); }
.article-header h1 { max-width: 850px; margin: 8px 0 20px; color: var(--text-strong); font-size: clamp(40px, 5vw, 68px); line-height: 1.15; letter-spacing: -.045em; text-wrap: balance; }
.article-lead { max-width: var(--reading); margin: 24px 0; color: #c7cbc7; font-size: 18px; line-height: 1.75; }
.byline { display: flex; align-items: center; gap: 12px; }
.byline p { margin: 0; font-size: 12px; line-height: 1.7; }
.byline time, .byline span { color: var(--muted); font-family: var(--mono); }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 auto; border: 1px solid var(--accent); border-radius: 50%; color: var(--accent-strong); background: var(--surface); font-weight: 700; }
.article-toc { grid-column: 1; align-self: start; position: sticky; top: 24px; padding-top: 34px; }
.article-toc h2 { margin: 0 0 12px; padding-bottom: 9px; border-bottom: 2px solid var(--accent); font-size: 16px; }
.article-toc ol { margin: 0; padding-left: 22px; }
.article-toc li { margin: 8px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.article-toc a { text-decoration: none; }
.article-toc a:hover, .article-toc a.is-active { color: var(--accent-strong); }
.article-body { grid-column: 2; padding-top: 34px; font-size: 18px; line-height: 1.75; }
.article-body > p:first-child { margin-top: 0; color: #c8ccc8; }
.article-body section { position: relative; margin: 58px 0; scroll-margin-top: 28px; }
.article-body section h2 { margin: 0 0 20px; color: var(--text-strong); font-size: 27px; line-height: 1.45; }
.article-body section h2 span { display: inline-block; min-width: 30px; margin-right: 10px; color: var(--accent-strong); font: 500 15px var(--mono); }
.article-body p { margin: 17px 0; }
.article-body pre { margin: 24px 0; overflow: auto; padding: 18px 20px; border: 1px solid var(--rule); background: #121518; color: #d0d4d0; font: 13px/1.8 var(--mono); }
.article-body blockquote { margin: 28px 0; padding: 16px 21px; border-left: 3px solid var(--accent); background: var(--surface); color: var(--text-strong); font-size: 18px; font-weight: 600; }
.margin-note { position: absolute; left: calc(100% + 42px); top: 8px; width: 210px; padding-left: 15px; border-left: 2px solid var(--accent); color: var(--muted); font-size: 13px; line-height: 1.75; }
.affiliate-note { margin: 42px 0; padding: 18px 22px; border: 1px solid var(--accent); background: var(--surface); }
.affiliate-note h2 { margin: 0 0 6px; font-size: 16px; }
.affiliate-note p { margin: 0; font-size: 13px; line-height: 1.75; }
.sources { padding-top: 28px; border-top: 1px solid var(--rule); }
.sources ul { columns: 2; padding-left: 20px; }
.sources a { color: var(--accent-strong); }
.author-box { display: flex; gap: 18px; padding: 24px; background: var(--surface); }
.author-box h2 { margin: 0 0 5px !important; font-size: 17px !important; }
.author-box p { margin: 0; color: var(--muted); font-size: 14px; }
.related { width: min(100%, 1080px); margin: 76px auto 46px; padding-top: 28px; border-top: 1px solid var(--rule); }
.related > h2 { margin: 0 0 22px; font-size: 23px; }
.related > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 34px; }
.related article + article { border-left: 1px solid var(--rule); padding-left: 34px; }
.related h3 { margin: 7px 0; font-size: 17px; line-height: 1.55; }
.related h3 a { text-decoration: none; }
.related article > p:last-child { color: var(--muted); font-size: 13px; }

@media (max-width: 1050px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-sidebar { display: grid; grid-template-columns: repeat(3, 1fr); }
  .article-shell { grid-template-columns: 180px minmax(0, 1fr); }
  .article-header, .article-body { grid-column: 2; }
  .margin-note { position: static; width: auto; margin: 20px 0; }
}

@media (max-width: 760px) {
  html { scroll-padding-top: 72px; }
  body { font-size: 17px; }
  .site-header, main, .site-footer { width: min(calc(100% - 32px), var(--max)); }
  .site-header { min-height: 70px; }
  .brand { font-size: 18px; }
  .brand span { font-size: 9px; }
  .menu-button { display: block; }
  .site-header nav { position: absolute; z-index: 50; left: 16px; right: 16px; top: 69px; display: none; flex-direction: column; align-items: stretch; gap: 0; padding: 10px 18px; border: 1px solid var(--rule); background: var(--surface-raised); }
  .site-header nav.is-open { display: flex; }
  .site-header nav a, .nav-search { padding: 12px 0; border-bottom: 1px solid var(--rule); text-align: left; }
  main { margin-top: 16px; }
  .hero { height: auto; min-height: 0; display: flex; flex-direction: column; }
  .hero > img { width: 100%; height: 230px; min-height: 0; order: 1; object-position: center; }
  .hero-copy { max-width: none; padding: 26px 0 30px; order: 2; }
  .hero h1 { margin-top: 11px; font-size: clamp(34px, 10.5vw, 48px); }
  .hero h1 { white-space: normal; text-wrap: balance; }
  .hero-copy > p:not(.category) { font-size: 17px; line-height: 1.7; }
  .home-grid { margin-top: 0; }
  .search-panel { padding: 18px; }
  .search-suggestions { align-items: flex-start; flex-direction: column; gap: 10px; }
  .search-suggestions span { width: auto; }
  .post-row { grid-template-columns: 92px 1fr 25px; gap: 8px 12px; padding: 20px 0; }
  .post-row time { grid-column: 1; }
  .post-row .category { grid-column: 2; }
  .post-row > div { grid-column: 1 / 3; }
  .post-row .row-link { grid-column: 3; grid-row: 1 / 3; align-self: center; }
  .post-row div > p { font-size: 14px; }
  .home-sidebar { display: flex; }
  .site-footer { padding: 32px 0; grid-template-columns: 1fr; gap: 22px; }
  .site-footer nav { flex-wrap: wrap; gap: 14px 22px; }
  .article-shell { display: block; }
  .breadcrumb { margin-top: 22px; }
  .article-header h1 { font-size: 42px; }
  .article-lead { font-size: 17px; }
  .article-toc { position: static; margin: 24px 0; padding: 18px; border: 1px solid var(--rule); }
  .article-body { padding-top: 16px; font-size: 17px; }
  .article-body section { margin: 46px 0; }
  .article-body section h2 { font-size: 23px; }
  .sources ul { columns: 1; }
  .related > div { grid-template-columns: 1fr; }
  .related article + article { border-left: 0; border-top: 1px solid var(--rule); padding: 20px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
