/* ===== 真夜中のテーブル — Hugo theme（読みやすさ改善案 B）=====
   オフホワイト地 + 濃グレー本文、差し色は深緑を一色。
   本文・見出し・リンクすべて BIZ UDPGothic に統一。 */

:root{
  --bg:#fafbf8;
  --bg-trans:rgba(250,251,248,.94);
  --ink:#1e221d;          /* 見出し・タイトル */
  --body:#3b3f38;         /* 本文テキスト */
  --ink2:#2a2e28;
  --accent:#355e43;       /* 深緑：リンク・日付 */
  --accent-hover:#284a34;
  --muted:#6a6f64;
  --muted2:#4e5349;
  --muted3:#8a9085;
  --faint:#b7bcb0;
  --rule:#ebede6;         /* 記事間の仕切り線 */
  --rule2:#f0f2ec;
  --hdr:#e6e8e1;          /* ヘッダー下線 */
  --tag:#5a6055;          /* タグ文字（背景#fafbf8に対し約6.2:1、WCAG AA適合） */
  --tag-border:#e3e6dd;
  --code-bg:#1e221d;      /* コードブロック背景 */
  --code-text:#ded8cf;    /* コードブロック文字色 */
  --inline-code-bg:#f1ede4; /* インラインコード背景 */
  --selection-bg:#cfe0d4; /* テキスト選択時の背景 */
  --search-active-bg:#f5efe9;   /* 検索結果のアクティブ項目背景 */
  --search-active-border:#d9c3b8; /* 検索結果のアクティブ項目枠線 */
  --underline-accent:#d9c3b8;   /* タクソノミー・音声リンクの下線 */
  --scrollbar-thumb:#c9b8aa;    /* テーブル横スクロールバー（つまみ） */
  --scrollbar-track:#f3efe8;    /* テーブル横スクロールバー（トラック） */
  /* Google Fonts(BIZ UDPGothic)読み込み中に sans-serif へ直落ちし日本語表示が
     不安定にならないよう、日本語システムフォントをフォールバックに挟む（Issue #10） */
  --serif:'BIZ UDPGothic', "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --sans:'BIZ UDPGothic', "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
}

/* ダークモード変数はこの1ブロックに統合（手動切替 html[data-theme="dark"] とOS設定追従の
   @media (prefers-color-scheme:dark) の2箇所で同一の値を参照する） */
html[data-theme="dark"] {
  --bg:#0f120f;
  --bg-trans:rgba(15,18,15,.94);
  --ink:#eef2eb;
  --body:#c6ccc0;
  --ink2:#dae0d4;
  --accent:#72ba8b;
  --accent-hover:#90d3a7;
  --muted:#91968c;
  --muted2:#a5aba0;
  --muted3:#7a8075;
  --faint:#636b5d;
  --rule:#363c32;
  --rule2:#151814;
  --hdr:#252a22;
  --tag:#7f8779;          /* タグ文字（背景#0f120fに対し約5.1:1、WCAG AA適合） */
  --tag-border:#2a3027;
  --code-bg:#1a1e19;
  --code-text:#c6ccc0;
  --inline-code-bg:#20251d;
  --selection-bg:#2d4a38;
  --search-active-bg:#1c2118;
  --search-active-border:#3a4536;
  --underline-accent:#3a4536;
  --scrollbar-thumb:#3a4536;
  --scrollbar-track:#1a1e19;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg:#0f120f;
    --bg-trans:rgba(15,18,15,.94);
    --ink:#eef2eb;
    --body:#c6ccc0;
    --ink2:#dae0d4;
    --accent:#72ba8b;
    --accent-hover:#90d3a7;
    --muted:#91968c;
    --muted2:#a5aba0;
    --muted3:#7a8075;
    --faint:#636b5d;
    --rule:#363c32;
    --rule2:#151814;
    --hdr:#252a22;
    --tag:#7f8779;
    --tag-border:#2a3027;
    --code-bg:#1a1e19;
    --code-text:#c6ccc0;
    --inline-code-bg:#20251d;
    --selection-bg:#2d4a38;
    --search-active-bg:#1c2118;
    --search-active-border:#3a4536;
    --underline-accent:#3a4536;
    --scrollbar-thumb:#3a4536;
    --scrollbar-track:#1a1e19;
  }
}

*{ box-sizing:border-box; }
html{ scroll-behavior: smooth; }
html,body{ margin:0; padding:0; }
body{
  background:var(--bg);
  color:var(--body);
  font-family:var(--sans);
  font-size:1rem;
  line-height:2;
  letter-spacing:.015em;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
::selection{ background:var(--selection-bg); }
a{ color:var(--accent); text-decoration:none; }
a:hover{ color:var(--accent-hover); }

/* ---- layout shells ---- */
.wrap{ max-width:880px; margin:0 auto; padding:0 56px 72px; }
.wrap--article{ max-width:880px; }

/* ---- top bar ---- */
.topbar{
  position:sticky; top:0; z-index:10;
  display:flex; justify-content:space-between; align-items:center;
  min-height:58px; padding:26px 0; border-bottom:1px solid var(--hdr); margin-bottom:48px;
  background:var(--bg-trans); backdrop-filter:blur(10px);
  transition:transform .25s ease;
}
.topbar .brand{ text-decoration:none; display:block; }
.brand-eyebrow{ font-size:10px; letter-spacing:.2em; color:var(--accent); font-weight:700; margin-bottom:8px; }
.brand-name{ font-family:var(--serif); font-size:24px; font-weight:600; letter-spacing:.08em; color:var(--ink); }
.nav{ display:flex; gap:16px; align-items:center; font-size:13px; }
.nav a{
  color:var(--muted); text-decoration:none;
  display:flex; align-items:center; justify-content:center;
  width:26px; height:26px; border-radius:50%;
  transition:all 0.2s ease;
}
.nav a:hover, .nav a.active{
  background:var(--rule2);
}
.nav a .nav-icon{
  stroke:var(--muted);
  flex-shrink:0;
  transition:stroke 0.2s ease;
}
.nav a:hover .nav-icon,
.nav a.active .nav-icon{
  stroke:var(--ink);
}
.nav .nav-text{
  display:none;
}
.nav .search{
  appearance:none; border:0; background:transparent; padding:0; cursor:pointer;
  display:flex; align-items:center; gap:6px; color:var(--muted); font:inherit;
}
.nav .search:hover{ color:var(--ink); }
.nav .search .icon{
  width:26px; height:26px; border-radius:50%; border:1px solid var(--tag-border);
  display:flex; align-items:center; justify-content:center; font-size:13px;
}
.theme-toggle {
  appearance: none; border: 0; background: transparent; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--tag-border);
  transition: all 0.2s ease;
}
.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--ink);
}
.theme-toggle svg {
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}
.theme-toggle:active svg {
  transform: scale(0.85);
}

/* テーマ別アイコン切り替え */
html[data-theme="light"] .theme-toggle .sun-icon { display: none; }
html[data-theme="light"] .theme-toggle .moon-icon { display: block; }
html[data-theme="dark"] .theme-toggle .sun-icon { display: block; }
html[data-theme="dark"] .theme-toggle .moon-icon { display: none; }

/* OSダークモード時のデフォルト挙動用（localStorage未設定時） */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .theme-toggle .sun-icon { display: block; }
  html:not([data-theme="light"]) .theme-toggle .moon-icon { display: none; }
}
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) .theme-toggle .sun-icon { display: none; }
  html:not([data-theme="dark"]) .theme-toggle .moon-icon { display: block; }
}

.menu-toggle{
  display:none; appearance:none; width:38px; height:38px; border:0; background:transparent;
  padding:8px; cursor:pointer;
}
.menu-toggle span{
  display:block; width:20px; height:2px; margin:4px auto; background:var(--ink);
  transition:transform .18s ease, opacity .18s ease;
}
.topbar.nav-open .menu-toggle span:nth-child(1){ transform:translateY(6px) rotate(45deg); }
.topbar.nav-open .menu-toggle span:nth-child(2){ opacity:0; }
.topbar.nav-open .menu-toggle span:nth-child(3){ transform:translateY(-6px) rotate(-45deg); }

/* ---- search ---- */
.search-open{ overflow:hidden; }
.search-overlay{
  position:fixed; inset:0; z-index:20; display:flex; align-items:flex-start; justify-content:center;
  padding:88px 22px 22px;
}
.search-overlay[hidden]{ display:none; }
.search-backdrop{ position:absolute; inset:0; background:rgba(43,39,35,.32); }
.search-panel{
  position:relative; z-index:1; width:min(680px,100%); max-height:min(72vh,720px);
  overflow:hidden; border:1px solid var(--ink); background:var(--bg);
  box-shadow:0 24px 60px rgba(43,39,35,.22);
}
.search-box{
  display:grid; grid-template-columns:42px 1fr 42px; align-items:center;
  border-bottom:1px solid var(--rule); min-height:58px;
}
.search-box-icon{ display:flex; align-items:center; justify-content:center; color:var(--accent); font-size:18px; }
.search-input{
  width:100%; min-width:0; border:0; outline:0; background:transparent; color:var(--ink);
  font-family:var(--serif); font-size:20px; line-height:1.4;
}
.search-input::placeholder{ color:var(--muted3); }
.search-close{
  appearance:none; width:42px; height:42px; border:0; background:transparent; color:var(--muted);
  cursor:pointer; font-size:22px; line-height:1;
}
.search-close:hover{ color:var(--accent); }
.search-status{
  min-height:36px; padding:10px 18px 0; color:var(--muted3);
  font-size:12px; letter-spacing:.08em;
}
.search-results{ max-height:calc(min(72vh,720px) - 94px); overflow:auto; padding:4px 18px 18px; }
.search-result{
  display:block; padding:15px 12px 16px; border-top:1px solid var(--rule);
  color:var(--ink); text-decoration:none;
}
.search-result:first-child{ border-top:0; }
.search-result:hover .search-result-title,.search-result.is-active .search-result-title{ color:var(--accent); }
.search-result.is-active{ background:var(--search-active-bg); outline:1px solid var(--search-active-border); outline-offset:-1px; }
.search-result-title{
  display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  font-family:var(--serif); font-size:18px; font-weight:600; line-height:1.5;
}
.search-result-meta{
  display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  margin-top:4px; color:var(--muted3); font-size:11px; letter-spacing:.04em;
}
.search-result-summary{
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
  margin-top:8px; color:var(--muted); font-size:13px; line-height:1.75;
}

/* ---- section label ---- */
.section-label{
  display:flex; align-items:baseline; justify-content:space-between;
  font-size:12px; letter-spacing:.2em; color:var(--muted2);
  padding-top:26px; border-top:1px solid var(--rule); margin:0 0 28px;
}
.visually-hidden{ position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; }

/* ---- featured posts (home) ---- */
.featured-posts{ margin-bottom:44px; padding:22px 26px 24px; background:var(--rule2); border:1px solid var(--rule); border-radius:6px; }
.featured-posts .section-label{ border-top:0; padding-top:0; margin-bottom:18px; }
.featured-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:13px; }
.featured-list a{ font-family:var(--serif); font-size:16px; font-weight:600; color:var(--ink); }
.featured-list a:hover{ color:var(--accent); }
.featured-date{ margin-left:10px; font-size:12px; color:var(--muted3); letter-spacing:.04em; white-space:nowrap; }

/* ---- archive CTA (home) ---- */
.archive-cta{ margin-top:32px; text-align:center; }
.archive-cta a{ display:inline-block; padding:12px 28px; border:1px solid var(--accent); border-radius:6px; color:var(--accent); font-size:14px; letter-spacing:.08em; }
.archive-cta a:hover{ background:var(--accent); color:var(--bg); }

/* ---- list month heading ---- */
.list-month-head{
  font-family:var(--serif); font-size:15px; font-weight:700; letter-spacing:.08em;
  color:var(--muted2); margin:0 0 24px; padding-top:6px;
}
.list-month-head:not(:first-of-type){ margin-top:8px; }

/* ---- post list rows (top / section / taxonomy) ---- */
.post-row{ padding:0 0 38px; margin-bottom:38px; border-bottom:1px solid var(--rule); }
.post-meta{ display:flex; align-items:center; flex-wrap:wrap; gap:0 4px; font-size:13px; color:var(--muted3); letter-spacing:.04em; margin-bottom:8px; }
.post-meta .meta-separator{ color:var(--faint); margin:0 2px; }
.post-reading-time,
.article-reading-time{ display:inline-flex; align-items:center; gap:3px; }
.post-reading-time svg,
.article-reading-time svg{ stroke:var(--faint); }
.post-tags{ display:flex; flex-wrap:wrap; gap:6px 8px; }
.post-tags .tag{ color:var(--tag); font-size:12px; font-weight:400; letter-spacing:.04em; text-decoration:none; border:1px solid var(--tag-border); border-radius:4px; padding:1px 8px; }
.post-tags .tag:hover{ color:var(--accent); border-color:var(--accent); }
.post-title{ font-family:var(--serif); font-size:24px; font-weight:700; line-height:1.55; margin:0; }
.post-title a{ color:var(--ink); text-decoration:none; }
.post-title a:hover{ color:var(--accent); }
.post-excerpt{ font-size:15px; line-height:1.95; color:var(--muted); margin:10px 0 0; }

/* ---- pagination ---- */
.pager{
  border-top:1px solid var(--rule); padding-top:36px; margin-top:8px;
  display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:6px;
  font-family:var(--serif); font-variant-numeric:tabular-nums; font-size:14px;
}
.pager a,.pager span{
  width:38px; height:38px; display:flex; align-items:center; justify-content:center;
  border-radius:50%; color:var(--ink2); text-decoration:none;
}
.pager .active{ background:var(--accent); color:var(--bg); }
.pager .prev,.pager .next{ width:auto; font-family:var(--sans); font-size:12px; letter-spacing:.1em; padding:0 8px; }
.pager a.prev,.pager a.next{ color:var(--accent); }
.pager .disabled{ color:var(--faint); }
.pager .dots{ width:20px; color:var(--faint); }

/* ---- article (single) ---- */
.article-eyebrow{ text-align:center; font-size:11px; letter-spacing:.2em; color:var(--accent); font-weight:700; margin-bottom:20px; }
.article-title{ font-family:var(--serif); font-size:30px; font-weight:700; line-height:1.6; color:var(--ink); text-align:center; letter-spacing:.015em; margin:0; }
.article-meta{ display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:0 4px; text-align:center; font-size:12px; color:var(--muted2); margin-top:22px; letter-spacing:.08em; }
.article-meta .meta-separator{ color:var(--faint); margin:0 2px; }
.article-taxonomy{ display:flex; flex-direction:column; align-items:center; gap:8px; margin:18px 0 36px; font-family:var(--sans); font-size:12px; line-height:1.8; }
.article-taxonomy-row{ display:flex; flex-wrap:wrap; align-items:baseline; justify-content:center; gap:6px 10px; }
.article-taxonomy-label{ color:var(--muted3); font-weight:700; letter-spacing:.12em; }
.article-taxonomy-list{ display:flex; flex-wrap:wrap; justify-content:center; gap:6px 10px; }
.article-taxonomy a{ color:var(--accent); text-decoration:none; border-bottom:1px solid var(--underline-accent); }
.article-audio{ text-align:center; margin:18px 0 40px; }
.about-prose{ margin-top:40px; }
.article-audio a{ font-size:12px; color:var(--accent); border-bottom:1px solid var(--underline-accent); padding-bottom:3px; text-decoration:none; }

.summary{ border-top:1px solid var(--ink); border-bottom:1px solid var(--rule); padding:24px 0 26px; margin-bottom:40px; }
.summary .label{ font-size:12px; letter-spacing:.2em; color:var(--muted2); margin-bottom:14px; }
.summary ul{ list-style:none; margin:0; padding:0; font-family:var(--serif); font-size:15px; line-height:2.0; }
.summary li::before{ content:"・ "; color:var(--accent); }

/* ---- markdown body (.prose) — mirrors article 案A ---- */
.prose{
  font-family:var(--serif); font-size:1.0625rem; line-height:1.95; letter-spacing:.015em; color:var(--body);
  max-width:40em; margin-inline:auto; /* 1行約35〜40字に最適化（Issue #1） */
  line-break:strict; overflow-wrap:break-word; /* 日本語の禁則・折り返し（Issue #4） */
}
.prose > *:first-child{ margin-top:0; }
.prose p{ margin:0 0 22px; text-wrap:pretty; }
.prose h2{
  font-family:var(--serif); font-size:1.4375rem; font-weight:700; line-height:1.6; letter-spacing:.015em; color:var(--ink);
  margin:48px 0 22px; padding-bottom:12px; border-bottom:1px solid var(--hdr);
  text-wrap:balance;
}
.prose h3{ font-family:var(--serif); font-size:1.125rem; font-weight:700; line-height:1.6; color:var(--ink); margin:40px 0 14px; text-wrap:balance; }
.prose h3::before{ content:"—"; color:var(--accent); margin-right:12px; }
.prose h4{ font-family:var(--serif); font-size:1rem; font-weight:700; line-height:1.6; color:var(--ink); margin:32px 0 12px; }
.prose h5{ font-family:var(--sans); font-size:.875rem; font-weight:700; letter-spacing:.04em; line-height:1.6; color:var(--ink2); margin:28px 0 10px; }
.prose h6{ font-family:var(--sans); font-size:.8125rem; font-weight:700; letter-spacing:.08em; line-height:1.6; color:var(--muted2); text-transform:uppercase; margin:24px 0 10px; }
/* 固定ヘッダー(sticky .topbar)の下に見出しが隠れないようオフセットを確保（Issue #2） */
.prose h2,.prose h3,.prose h4,.prose h5,.prose h6{ scroll-margin-top:96px; }
.prose blockquote{
  margin:32px 0; padding:8px 0 8px 24px; border-left:3px solid var(--accent);
  color:var(--muted); font-size:1rem; line-height:2.0;
}
.prose blockquote p{ margin:0; }
.prose img{ display:block; max-width:100%; height:auto; margin:28px auto; }
.prose figure{ margin:28px auto; text-align:center; }
.prose figure img{ margin:0 auto; }
.prose figcaption{ margin-top:10px; font-size:.8125rem; line-height:1.6; color:var(--muted3); }
.prose pre{
  font-family:'SFMono-Regular',Menlo,Consolas,monospace; font-size:.8125rem; line-height:1.85;
  background:var(--code-bg) !important; color:var(--code-text); padding:22px 24px; border-radius:8px; margin:28px 0;
  overflow-x:auto; white-space:pre; letter-spacing:0;
}
.prose :not(pre) > code{
  font-family:'SFMono-Regular',Menlo,Consolas,monospace; font-size:.85em;
  background:var(--inline-code-bg); padding:2px 6px; border-radius:4px;
  color:var(--ink);
}
.prose table{
  display:block; width:100%; max-width:100%; overflow-x:auto; border-collapse:collapse;
  font-family:var(--serif); margin:28px 0; -webkit-overflow-scrolling:touch;
  scrollbar-color:var(--scrollbar-thumb) var(--scrollbar-track);
}
.prose table > :where(thead,tbody,tfoot){
  display:table; width:100%; min-width:680px; table-layout:fixed; border-collapse:collapse;
}
.prose table:has(th:nth-child(3)) > :where(thead,tbody,tfoot),
.prose table:has(td:nth-child(3)) > :where(thead,tbody,tfoot){ min-width:760px; }
.prose table:has(th:nth-child(4)) > :where(thead,tbody,tfoot),
.prose table:has(td:nth-child(4)) > :where(thead,tbody,tfoot){ min-width:960px; }
.prose th{
  text-align:left; vertical-align:bottom; font-family:var(--sans); font-size:.6875rem; font-weight:700; letter-spacing:.12em;
  line-height:1.7; color:var(--muted2); padding:0 18px 12px 0; border-bottom:2px solid var(--ink);
  overflow-wrap:anywhere;
}
.prose td{
  vertical-align:top; font-size:.90625rem; line-height:1.85; padding:14px 18px 14px 0;
  border-bottom:1px solid var(--rule); overflow-wrap:anywhere;
}
.prose th:last-child,.prose td:last-child{ padding-right:0; }
.prose tr td:last-child{ font-variant-numeric:tabular-nums; white-space:normal; }
.prose ul,.prose ol{ padding-left:1.4em; margin:0 0 22px; }
.prose li{ margin-bottom:8px; }
.prose a{ color:var(--accent); text-decoration:none; }
.prose a:hover{ color:var(--accent-hover); text-decoration:underline; text-underline-offset:3px; }
.prose hr{ border:none; border-top:1px solid var(--rule); margin:40px 0; }

.article-nav{
  display:grid; grid-template-columns:1fr 1fr; gap:22px; margin:56px 0 0; padding-top:24px;
  border-top:1px solid var(--ink);
}
.article-nav-link{ min-width:0; color:var(--ink); text-decoration:none; }
.article-nav-next{ text-align:right; }
.article-nav-label{
  display:block; margin-bottom:8px; color:var(--muted3); font-family:var(--sans);
  font-size:11px; font-weight:700; letter-spacing:.14em;
}
.article-nav-title{
  display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  font-family:var(--serif); font-size:16px; font-weight:600; line-height:1.6;
}
.article-nav-link:hover .article-nav-title{ color:var(--accent); }

/* ---- related posts ---- */
.related-posts{ margin-top:56px; padding-top:24px; border-top:1px solid var(--rule); }
.related-title{ font-size:12px; letter-spacing:.2em; color:var(--muted2); margin-bottom:18px; }
.related-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:12px; }
.related-list a{ font-family:var(--serif); font-size:16px; font-weight:600; color:var(--ink); }
.related-list a:hover{ color:var(--accent); }
.related-date{ margin-left:10px; font-size:12px; color:var(--muted3); letter-spacing:.04em; white-space:nowrap; }

/* ---- tag cloud (タグ一覧) ---- */
.tagcloud{ display:flex; flex-wrap:wrap; align-items:baseline; gap:16px 26px; font-family:var(--serif); }
.tagcloud a{ color:var(--muted); text-decoration:none; }
.tagcloud a:hover{ color:var(--accent); }
.tagcloud .n{ font-family:var(--sans); font-size:11px; color:var(--faint); margin-left:4px; }
.tagcloud-note{ margin-top:28px; font-size:12px; color:var(--muted3); letter-spacing:.06em; }

/* ---- archive (アーカイブ) ---- */
.year-head{ display:flex; align-items:baseline; gap:16px; margin:0 0 8px; }
.year-head .y{ font-family:var(--serif); font-size:30px; font-weight:600; }
.year-head .c{ font-size:11px; color:var(--muted3); letter-spacing:.08em; }
.year-head + .month-row{ border-top:1px solid var(--ink); }
.month-row{ display:grid; grid-template-columns:84px 1fr; gap:24px; padding:22px 0; border-top:1px solid var(--rule); }
.month-row .m{ font-family:var(--serif); font-size:18px; color:var(--ink2); }
.month-row .mc{ font-size:11px; color:var(--muted3); letter-spacing:.08em; margin-top:5px; }
.month-list{ display:flex; flex-direction:column; gap:13px; min-width:0; }
.month-list .t{
  display:flex; align-items:baseline; min-width:0; white-space:nowrap;
  font-family:var(--serif); font-size:18px; font-weight:500; line-height:1.6;
}
.month-list .t a{
  min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  color:var(--ink); text-decoration:none;
}
.month-list .t a:hover{ color:var(--accent); }
.month-list .d{
  flex:0 0 auto; white-space:nowrap;
  font-family:var(--sans); font-size:12px; color:var(--muted3); font-weight:400; margin-left:8px; letter-spacing:.04em;
}

/* ---- footer ---- */
.site-footer{ margin-top:72px; padding-top:24px; border-top:1px solid var(--rule); text-align:center; font-size:12px; color:var(--muted2); letter-spacing:.1em; }
.site-footer a{ color:var(--accent); text-decoration:none; }

/* ---- responsive ---- */
@media (max-width:640px){
  .wrap{ padding:0 22px 56px; }
  .topbar{ min-height:56px; margin-bottom:38px; padding:10px 0; }
  /* auto-hide on scroll down, reveal on scroll up (see js/header-autohide.js) */
  .topbar.is-hidden{ transform:translateY(-100%); }
  .brand-name{ font-size:22px; }
  .menu-toggle{ display:block; margin-left:auto; }
  .nav{
    position:absolute; top:100%; left:0; right:0; display:none; flex-direction:column; align-items:stretch;
    gap:0; padding:6px 0 12px; border-bottom:1px solid var(--hdr);
    background:var(--bg); box-shadow:0 18px 36px rgba(15,18,15,.25);
  }
  .topbar.nav-open .nav{ display:flex; }
  .nav a,.nav .theme-toggle,.nav .search{
    width:100%; min-height:44px; justify-content:flex-start; padding:0 2px;
    border-top:1px solid var(--rule); color:var(--ink2);
  }
  .nav a{
    border-radius:0;
    justify-content:flex-start;
    padding-left:8px;
    gap:10px;
    background:transparent !important;
  }
  .nav a.active{
    color:var(--accent);
  }
  .nav a.active .nav-icon{
    stroke:var(--accent);
  }
  .nav .nav-text{
    display:inline;
    font-size:13px;
    font-weight:500;
  }
  .nav .theme-toggle {
    border: 0;
    border-radius: 0;
    justify-content: flex-start;
    padding-left: 8px;
  }
  .nav .search .icon{ margin-left:0; }
  .article-title{ font-size:26px; }
  /* archives: stack the month label above the titles; titles stay one line */
  .month-row{ display:block; padding:18px 0; }
  .month-row .m{ display:inline; }
  .month-row .mc{ display:inline; margin:0 0 0 8px; }
  .month-row > div:first-child{ margin-bottom:12px; }
  /* モバイルはヘッダーが低い(56px)ため、隠れない範囲でオフセットを縮小（Issue #2） */
  .prose h2,.prose h3,.prose h4,.prose h5,.prose h6{ scroll-margin-top:72px; }
}

/* ===== 記事の目次 (TOC) ===== */

/* スマホ用アコーディオン目次 */
.toc-inline {
  margin-bottom: 38px;
  background-color: var(--rule2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 18px 22px;
}

.toc-inline-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* detailsのデフォルトの黒い三角形（矢印）を消す */
.toc-inline-title::-webkit-details-marker {
  display: none;
}
.toc-inline-title::marker {
  display: none;
}

/* 独自の矢印アイコンを表示 */
.toc-inline-title::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  margin-right: 4px;
}

.toc-inline[open] .toc-inline-title::after {
  transform: rotate(-135deg);
}

.toc-inline-content {
  margin-top: 14px;
  border-top: 1px solid var(--rule);
  padding-top: 14px;
}

.toc-inline-content nav ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc-inline-content nav ul ul {
  padding-left: 18px;
  margin-top: 6px;
}

.toc-inline-content nav li {
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.toc-inline-content nav a {
  color: var(--body);
  transition: color 0.15s ease;
}

.toc-inline-content nav a:hover {
  color: var(--accent);
}

/* PC用サイドバー目次（初期状態はスマホなので非表示） */
.toc-sidebar {
  display: none;
}

/* PC表示でのグリッドレイアウト & スクロール追従 */
@media (min-width: 1024px) {
  /* スマホ用目次を非表示に */
  .toc-inline {
    display: none;
  }

  /* 目次がある場合、wrap自体の最大幅を少し広げて窮屈さを防ぐ */
  .wrap--article:has(.has-toc) {
    max-width: 1140px;
  }

  .article-body-container.has-toc {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 64px;
    align-items: start;
  }

  /* TOCサイドバー併用時は本文列の幅に合わせて左寄せ（中央寄せだとサイドバーと間延びする） */
  .article-body-container.has-toc .prose {
    max-width: none;
    margin-inline: 0;
  }

  /* サイドバー目次を表示 */
  .toc-sidebar {
    display: block;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding-bottom: 24px;
  }

  .toc-sidebar-container {
    border-left: 1px solid var(--rule);
    padding-left: 24px;
  }

  .toc-sidebar-title {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.1em;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 16px;
  }

  .toc-sidebar-content nav ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
  }

  .toc-sidebar-content nav ul ul {
    padding-left: 12px;
    margin-top: 8px;
  }

  .toc-sidebar-content nav li {
    margin-bottom: 10px;
    font-size: 13px;
    line-height: 1.5;
  }

  .toc-sidebar-content nav a {
    color: var(--muted);
    transition: all 0.2s ease;
    display: block;
  }

  .toc-sidebar-content nav a:hover,
  .toc-sidebar-content nav a.active {
    color: var(--accent);
  }
  
  .toc-sidebar-content nav a.active {
    font-weight: 700;
  }
}

/* ===== Overrides for Sticky Archives and Dark Mode Contrast ===== */

/* Sticky year headers in archives */
.year-head {
  position: -webkit-sticky;
  position: sticky;
  top: 86px;
  z-index: 9;
  background-color: var(--bg);
  margin: 0;
  padding: 16px 0 8px;
}
@media (max-width: 640px) {
  .year-head {
    top: 56px;
    padding: 12px 0 6px;
  }
  .topbar.is-hidden ~ .year-head {
    top: 0;
  }
}

/* Tag cloud colors for light and dark modes */
.tagcloud a.tag-medium {
  color: #2b2723;
}
.tagcloud a.tag-heavy {
  color: #b5462f;
}
html[data-theme="dark"] .tagcloud a.tag-medium {
  color: #dae0d4;
}
html[data-theme="dark"] .tagcloud a.tag-heavy {
  color: #e67a63;
}

/* ===== モーション抑制設定への対応（Issue #8） ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
