/* 公開ページ（読者向け）のスタイル
   雰囲気：余白を広く取った、白とごく薄いグレーのシンプルなデザイン。差し色は「オーロラ」のグラデーション
   構成：PC は本文＋サイドバーの2カラム、スマホは1カラム
   文字と背景のコントラストは WCAG AA（4.5:1）を目安にしている */
:root {
  --bg: #ffffff;
  --bg-soft: #f5f5f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: #e8e8ed;
  --link: #2563d9;
  --link-hover: #1b4fb8;
  --code-bg: #1d1d1f;

  /* 差し色：飾り用（線・番号・サムネイルの仮表示など） */
  --grad: linear-gradient(120deg, #2ec5c0 0%, #4f8cff 50%, #9a6dff 100%);
  /* 差し色：白い文字を載せる部分用（ボタンなど。少し濃くしてコントラストを確保） */
  --grad-strong: linear-gradient(120deg, #0d8481 0%, #2f6fe0 50%, #7a4fe6 100%);
  --accent: #4f8cff;

  --radius-lg: 22px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 28px rgba(0, 0, 0, 0.06);
  --container: 1160px;
  --sidebar-w: 300px;
  --header-h: 64px; /* 固定ヘッダーの高さ（public/js/site.js が実際の高さで上書きする） */
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--link); }
a:hover { color: var(--link-hover); }
img { max-width: 100%; height: auto; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  padding: 8px 12px;
  background: var(--text);
  color: #fff;
  z-index: 100;
}
.skip-link:focus { left: 8px; }

/* ---------- 広告表記の帯 ---------- */
.pr-bar {
  margin: 0;
  padding: 6px 16px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

/* ---------- ヘッダー（上部に固定・半透明） ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 62px;
}
.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}
.site-logo:hover { color: var(--text); opacity: 0.75; }
.logo-mark { width: 30px; height: 30px; flex-shrink: 0; color: #1a1a1a; }

.global-nav { margin-left: auto; min-width: 0; }
.global-nav ul {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.global-nav ul::-webkit-scrollbar { display: none; }
.global-nav a {
  display: block;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.global-nav a:hover { background: var(--bg-soft); color: var(--text); }
.global-nav a[aria-current] { font-weight: 700; }
.header-search {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  margin-left: auto; /* カテゴリーのナビがないときも右端に寄せる */
  border-radius: 999px;
  color: var(--text);
}
.global-nav + .header-search { margin-left: -16px; }
.header-search:hover { background: var(--bg-soft); color: var(--text); }

/* ---------- パンくず ---------- */
.breadcrumb { padding-top: 20px; }
.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--muted);
}
.breadcrumb li + li::before { content: '›'; margin-right: 4px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }
.breadcrumb [aria-current] {
  max-width: 28em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 2カラムレイアウト ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
  gap: 56px;
  padding-top: 28px;
  padding-bottom: 80px;
}
.main { min-width: 0; }

/* ---------- 共通部品 ---------- */
.category-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.7;
  text-decoration: none;
}
a.category-badge:hover { box-shadow: inset 0 0 0 1px var(--accent); color: var(--text); }

.button {
  display: inline-block;
  padding: 11px 26px;
  border-radius: 999px;
  background: var(--grad-strong);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(47, 111, 224, 0.22);
  transition: transform 0.2s, box-shadow 0.2s;
}
.button:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 10px 24px rgba(47, 111, 224, 0.28); }

.section-title {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.empty { color: var(--muted); }

/* サムネイル：画像ができるまでの仮表示。カテゴリーごとに --hue で色合いを少し変える */
.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(var(--angle, 120deg), #2ec5c0 0%, #4f8cff 50%, #9a6dff 100%);
  filter: hue-rotate(var(--hue, 0deg));
}
.thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.55), transparent 55%);
}
/* アイキャッチ画像があるときは、グラデーションではなく画像を表示する */
.thumb.has-image { background: var(--bg-soft); filter: none; }
.thumb.has-image::after { display: none; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-link { display: block; }
a:hover > .thumb.has-image img,
a:hover .thumb.has-image img { transform: scale(1.03); }
.thumb img { transition: transform 0.4s ease; }
@media (prefers-reduced-motion: reduce) { .thumb img { transition: none; } }

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- 一覧ページの見出し ---------- */
.list-title { margin: 0; font-size: 30px; line-height: 1.35; letter-spacing: -0.01em; }
.list-lead { margin: 10px 0 0; color: var(--muted); font-size: 15px; }
.list-count { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.category-hero {
  margin-bottom: 32px;
  padding: 28px 30px;
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  position: relative;
  overflow: hidden;
}
.category-hero::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--grad);
}
/* カテゴリーのタイル画像（src/lib/category-art.js）。カテゴリーページの上部では右側に置く */
.category-hero.has-art { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.category-hero-text { min-width: 0; }
.category-hero-art { flex: 0 0 200px; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; }
.thumb.has-art { background: none; filter: none; }
.thumb.has-art svg,
.category-hero-art svg { display: block; width: 100%; height: 100%; }

/* ---------- トップページ：大きく見せる最新記事 ---------- */
.hero {
  display: block;
  margin-bottom: 20px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.25s, box-shadow 0.25s;
}
.hero:hover { color: var(--text); transform: translateY(-2px); box-shadow: var(--shadow); }
.hero .thumb { border-radius: 0; aspect-ratio: 16 / 7; }
.hero-body { padding: 22px 28px 28px; }
.hero-label {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--grad-strong);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.hero-title { margin: 12px 0 8px; font-size: 28px; line-height: 1.4; letter-spacing: -0.01em; }
.hero-summary { margin: 0 0 12px; color: var(--muted); font-size: 15px; line-height: 1.7; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 48px;
}
.feature-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}
.feature-card:hover { color: var(--text); }
.feature-card:hover .feature-title { color: var(--link); }
.feature-title { margin: 0; font-size: 17px; line-height: 1.5; transition: color 0.2s; }

/* ---------- トップページ：ピックアップ（横に並べ、PC は矢印・スマホはスワイプで送る） ---------- */
.pickup { margin-bottom: 48px; }
.pickup-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pickup-head .section-title { margin-bottom: 14px; }
.pickup-nav { display: flex; gap: 8px; }
.pickup-arrow {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.pickup-arrow:hover:not(:disabled) { background: var(--border); }
.pickup-arrow:disabled { opacity: 0.35; cursor: default; }
.pickup-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 32px) / 3);
  gap: 16px;
  margin: 0;
  padding: 0 0 8px;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.pickup-track::-webkit-scrollbar { display: none; }
.pickup-track > li { scroll-snap-align: start; }
.pickup-card { display: flex; flex-direction: column; gap: 10px; color: var(--text); text-decoration: none; }
.pickup-card:hover { color: var(--text); }
.pickup-card:hover .pickup-title { color: var(--link); }
.pickup-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.2s;
}

/* ---------- 記事一覧（左にサムネイル、右に本文） ---------- */
.post-list { display: flex; flex-direction: column; }
.post-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.post-row:first-child { padding-top: 0; }
.post-row .thumb { border-radius: var(--radius-sm); }
.post-row-title { margin: 6px 0; font-size: 18px; line-height: 1.5; }
.post-row-title a { color: var(--text); text-decoration: none; }
.post-row-title a:hover { color: var(--link); }
.post-row-summary {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 40px;
}
.pagination a,
.pagination span {
  min-width: 42px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-soft);
  text-align: center;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
}
.pagination a:hover { background: var(--border); color: var(--text); }
.pagination .current { background: var(--grad-strong); color: #fff; font-weight: 600; }
.pagination .page-ellipsis { background: none; min-width: auto; padding: 8px 2px; color: var(--muted); }

/* ---------- 記事・固定ページ ---------- */
.article-header { margin-bottom: 28px; }
.article-title { margin: 14px 0 12px; font-size: 34px; line-height: 1.4; letter-spacing: -0.015em; }
.article-lead { margin: 0 0 16px; color: var(--muted); font-size: 17px; line-height: 1.75; }

.article-eyecatch {
  margin: 0 0 28px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
}
.article-eyecatch img { display: block; width: 100%; height: auto; }

.pr-note {
  margin: 0 0 28px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 13px;
}

.toc {
  margin: 0 0 40px;
  padding: 20px 24px;
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.toc-title { margin: 0 0 10px; font-weight: 700; }
.toc ol { margin: 0; padding-left: 1.4em; font-size: 15px; line-height: 1.7; }
.toc li { margin: 4px 0; }
.toc ul { margin: 2px 0 6px; padding-left: 1.2em; list-style: circle; font-size: 14px; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--link); text-decoration: underline; }

/* 長い目次は折りたたむ（JavaScript で .is-collapsed を付けたときだけ。無効なら全体を表示）
   開閉時の高さは JavaScript が max-height を変えて、ここの transition で動かす */
.toc-body {
  position: relative;
  overflow: hidden;
  transition: max-height 0.35s ease;
}
.toc.is-collapsed .toc-body { max-height: 132px; } /* 閉じているときは4行ほど */
.toc-body::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48px;
  background: linear-gradient(rgba(245, 245, 247, 0), var(--bg-soft));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.toc.is-collapsed .toc-body::after { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .toc-body,
  .toc-body::after { transition: none; }
}
.toc-toggle {
  display: block;
  margin: 12px auto 0;
  padding: 6px 22px;
  border: none;
  border-radius: 999px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.toc-toggle:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.toc-toggle[hidden] { display: none; }

/* 本文 */
.entry { font-size: 16px; line-height: 2; overflow-wrap: anywhere; }
.entry > :first-child { margin-top: 0; }
.entry p { margin: 0 0 1.5em; }
.entry h2,
.entry h3,
.entry h4 { line-height: 1.5; letter-spacing: -0.01em; }
.entry h2 {
  position: relative;
  margin: 2.8em 0 1em;
  padding: 2px 0 2px 20px;
  font-size: 24px;
}
.entry h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 5px;
  border-radius: 3px;
  background: var(--grad);
}
.entry h3 { margin: 2.2em 0 0.8em; font-size: 20px; }
.entry h4 { margin: 1.8em 0 0.6em; font-size: 17px; }
.entry ul,
.entry ol { margin: 0 0 1.5em; padding-left: 1.6em; }
.entry li { margin: 0.35em 0; }
.entry li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.4em; }
.entry li > input[type="checkbox"] { margin-right: 6px; accent-color: var(--accent); }
.entry img { display: block; margin: 0 auto 1.5em; border-radius: var(--radius); }
.entry blockquote {
  margin: 0 0 1.5em;
  padding: 16px 22px;
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: #3a3a3c;
}
.entry blockquote > :last-child { margin-bottom: 0; }
/* 記事本文の太字にマーカー（ピンク。オーロラの紫からの派生色）。画面に入ったら左から引く（site.js）。
   表と引用の中は対象外。JavaScript が動かないときや「動きを減らす」設定では、最初から引いた状態 */
.entry-post strong {
  background-image: linear-gradient(rgba(255, 120, 170, 0.25), rgba(255, 120, 170, 0.25));
  background-repeat: no-repeat;
  background-position: 0 90%;
  background-size: 100% 0.45em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  transition: background-size 0.8s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.entry-post strong.marker-wait { background-size: 0% 0.45em; }
.entry-post :is(table, blockquote) strong { background: none; }
@media (prefers-reduced-motion: reduce) { .entry-post strong { transition: none; } }
.entry hr { margin: 3em 0; border: none; border-top: 1px solid var(--border); }
.entry code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--bg-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
}
.entry pre {
  margin: 0 0 1.5em;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: #f5f5f7;
  overflow-x: auto;
  line-height: 1.65;
}
.entry pre code { padding: 0; background: none; font-size: 14px; color: inherit; }
/* 表：本文の幅いっぱいに広げ、列の幅は中身の量に合わせる。はみ出す場合は枠（.table-wrap）の中で横スクロール */
.entry .table-wrap {
  margin: 0 0 1.5em;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.entry table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  line-height: 1.6;
}
/* 列が5つ以上ある表は、狭い画面で列が細くなりすぎないよう最小幅を持たせる */
.entry table:has(tr > :nth-child(5)) { min-width: 640px; }
.entry th,
.entry td { padding: 12px 16px; border-bottom: 1px solid var(--border); overflow-wrap: break-word; vertical-align: top; } /* 英単語の途中では折り返さない */
.entry th + th,
.entry td + td { border-left: 1px solid var(--border); }
.entry tr:last-child td { border-bottom: none; }
.entry th { background: var(--bg-soft); font-weight: 600; white-space: nowrap; } /* 見出しを折り返さず、短い列が細くなりすぎないようにする */
.entry th:not([align]) { text-align: left; } /* 揃えの指定がない列は、中身と同じ左揃えにする */

/* 記事のタグ */
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 40px 0 0; padding: 0; list-style: none; }
.post-tag {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s, box-shadow 0.2s;
}
.post-tag:hover { color: var(--link); box-shadow: inset 0 0 0 1px var(--accent); }

/* 関連記事 */
.related { margin-top: 64px; padding-top: 40px; border-top: 1px solid var(--border); }
.related-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 20px; }
.related-item { display: flex; flex-direction: column; gap: 10px; color: var(--text); text-decoration: none; }
.related-item:hover { color: var(--text); }
.related-item:hover .related-title { color: var(--link); }
.related-title { font-weight: 600; line-height: 1.5; transition: color 0.2s; }
.related-item time { font-size: 12px; color: var(--muted); }

/* 404 */
.not-found { padding: 48px 0; text-align: center; }
.not-found-code {
  margin: 0;
  font-size: 88px;
  font-weight: 800;
  line-height: 1;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.not-found p { color: var(--muted); }
.not-found-search { max-width: 420px; margin: 32px auto; }
.not-found-search p { margin: 0 0 10px; font-size: 14px; }

/* ---------- サイト内検索 ---------- */
.search-form { position: relative; }
.search-form input {
  width: 100%;
  height: 46px;
  padding: 0 48px 0 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px 未満だと iPhone で入力時に画面が拡大される */
  transition: border-color 0.2s, background 0.2s;
}
.search-form input::placeholder { color: var(--muted); }
.search-form input:focus { outline: none; border-color: var(--accent); background: var(--bg); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18); }
.search-form input::-webkit-search-cancel-button { cursor: pointer; }
.search-form button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 999px;
  background: var(--grad-strong);
  color: #fff;
  cursor: pointer;
}
.search-form button:hover { opacity: 0.9; }
.search-form button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.search-head { margin-bottom: 28px; }
.search-head .search-form { max-width: 560px; margin-top: 18px; }
.search-empty { margin-bottom: 40px; padding: 22px 24px; border-radius: var(--radius); background: var(--bg-soft); }
.search-empty p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.search-empty p:first-child { color: var(--text); font-weight: 600; }

/* ---------- サイドバー ---------- */
.sidebar { display: flex; flex-direction: column; gap: 36px; }
.widget-title {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
}
.widget-card {
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.widget-card .widget-title { margin-bottom: 8px; }
.widget-text { margin: 0 0 10px; font-size: 14px; color: var(--muted); line-height: 1.7; }
.widget-more { font-size: 14px; font-weight: 600; text-decoration: none; }
.widget-list { margin: 0; padding: 0; list-style: none; }
.widget-list li { padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.6; }
.widget-list li:first-child { padding-top: 0; }
.widget-list a { color: var(--text); text-decoration: none; }
.widget-list a:hover { color: var(--link); }
.widget-list time { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.widget-categories a { display: flex; justify-content: space-between; gap: 8px; }
.widget-categories .count {
  min-width: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* 人気ランキング */
.ranking { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; }
.ranking-item {
  display: grid;
  grid-template-columns: 28px 76px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}
.ranking-item:hover { color: var(--link); }
.ranking-num {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ranking-item .thumb { aspect-ratio: 1; border-radius: var(--radius-sm); }
.ranking-title {
  font-size: 14px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* PC 表示ではスクロールに追従（top は public/js/site.js がサイドバーの高さに合わせて設定） */
@media (min-width: 961px) {
  .sidebar {
    position: sticky;
    top: var(--sidebar-top, calc(var(--header-h) + 24px));
    align-self: start;
  }
  /* 記事ページ：サイドバー全体ではなく、一番下の目次だけを追従させる */
  .sidebar.has-toc {
    position: static;
    align-self: stretch;
  }
  .sidebar-toc {
    position: sticky;
    top: calc(var(--header-h) + 24px);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--header-h) - 48px);
  }
}
/* 1カラム表示では、記事冒頭の目次があるのでサイドの目次は出さない */
@media (max-width: 960px) {
  .sidebar-toc { display: none; }
}

.sidebar-toc-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 14px;
  line-height: 1.6;
  counter-reset: toc;
}
.sidebar-toc-list > li { counter-increment: toc; }
.sidebar-toc-list ul { margin: 0; padding: 0; list-style: none; }
.sidebar-toc-list a {
  position: relative;
  display: block;
  padding: 7px 12px 7px 16px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s, background-color 0.2s;
}
.sidebar-toc-list > li > a::before { content: counter(toc) ". "; }
.sidebar-toc-list ul a { padding-left: 32px; font-size: 13px; }
.sidebar-toc-list a:hover { color: var(--text); }
.sidebar-toc-list .is-current-parent > a { color: var(--text); font-weight: 600; }
.sidebar-toc-list a.is-current {
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 600;
}
.sidebar-toc-list a.is-current::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 2px;
  background: var(--grad);
}
@media (prefers-reduced-motion: reduce) {
  .sidebar-toc-list a { transition: none; }
}

/* ---------- フッター ---------- */
.site-footer {
  padding: 56px 0 32px;
  background: var(--bg-soft);
  font-size: 13px;
  color: var(--muted);
}
.footer-title { margin: 0 0 14px; font-size: 15px; font-weight: 700; color: var(--text); }
.footer-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin: 0 0 40px;
  padding: 0;
  list-style: none;
}
.footer-category {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.footer-category:hover { color: var(--link); }
.footer-category .thumb { aspect-ratio: 16 / 9; border-radius: var(--radius-sm); }
.footer-category .count { font-weight: 400; color: var(--muted); font-size: 12px; }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.footer-about { margin: 0 0 6px; max-width: 36em; line-height: 1.7; }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); text-decoration: underline; }
.copyright { margin: 0; }

/* ---------- 管理画面のプレビュー（views/admin/preview.ejs） ---------- */
.preview-bar {
  margin: 0;
  padding: 8px 16px;
  background: #fff7e0;
  color: #8a5a00;
  font-size: 13px;
  text-align: center;
  border-bottom: 1px solid #f1dfa8;
}
/* 本文の幅は、公開ページの PC 表示（本文＋サイドバーの2カラム）の本文と同じにする
   （.container の左右の余白 20px ずつを含めた幅。56px は .layout の gap） */
.preview-main {
  max-width: calc(var(--container) - var(--sidebar-w) - 56px + 40px);
  padding-top: 28px;
  padding-bottom: 80px;
}

/* ---------- タブレット・スマホ ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 64px; }
}

@media (max-width: 720px) {
  .header-inner { flex-wrap: wrap; gap: 0; min-height: 0; padding-top: 12px; }
  .site-logo { font-size: 19px; }
  .logo-mark { width: 26px; height: 26px; }
  .global-nav { order: 1; width: 100%; margin: 6px -12px 4px; }
  .global-nav ul { padding: 0 12px 6px; }
  /* 検索アイコンはナビの下ではなく、ロゴと同じ段の右端に置く */
  .header-search,
  .global-nav + .header-search { margin: 0 -8px 0 auto; }
  .global-nav a { padding: 6px 10px; }
  .layout { padding-top: 20px; }
  .list-title { font-size: 24px; }
  .hero-body { padding: 18px 20px 22px; }
  .hero-title { font-size: 21px; }
  .hero .thumb { aspect-ratio: 16 / 9; }
  .feature-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .pickup-track { grid-auto-columns: 72%; }
  .pickup-nav { display: none; }
  .post-row { grid-template-columns: 112px minmax(0, 1fr); gap: 14px; padding: 16px 0; }
  .post-row-title { font-size: 15px; margin: 4px 0; }
  .post-row-summary { display: none; }
  .article-title { font-size: 25px; }
  .article-lead { font-size: 15px; }
  .entry h2 { font-size: 20px; }
  .entry h3 { font-size: 18px; }
  /* スマホでは列ごとに中身の長さから決めた幅（--col-w）を使う。見出しも折り返す。
     列幅の合計が画面より広い表だけ、枠の中で横スクロールする */
  .entry table { font-size: 14px; table-layout: fixed; width: max(100%, var(--table-w, 100%)); }
  .entry table:has(> colgroup):has(tr > :nth-child(5)) { min-width: 0; } /* 列幅を計算した表は 640px の最小幅を使わない */
  .entry col { width: var(--col-w, auto); }
  .entry th { white-space: normal; }
  /* 横スクロールできるときだけ右端（左へ戻れるときは左端）にうっすら影を付ける。
     白い帯が中身と一緒に動いて、端までスクロールすると影を隠す */
  .entry .table-wrap {
    background:
      linear-gradient(to right, var(--bg) 30%, transparent) left / 32px 100% no-repeat local,
      linear-gradient(to left, var(--bg) 30%, transparent) right / 32px 100% no-repeat local,
      linear-gradient(to right, rgba(0, 0, 0, .12), transparent) left / 12px 100% no-repeat scroll,
      linear-gradient(to left, rgba(0, 0, 0, .12), transparent) right / 12px 100% no-repeat scroll;
  }
  .entry th,
  .entry td { padding: 10px 12px; overflow-wrap: anywhere; }
  .related-list { grid-template-columns: minmax(0, 1fr); }
  .category-hero { padding: 22px 22px 22px 26px; }
  /* スマホでは1カラム：見出し → 画像 → リード文 → 件数の順に並べる。
     記事一覧まで遠くならないよう、グレーの枠はなくし、画像は横長の帯にして高さを抑える */
  .category-hero.has-art { flex-direction: column; align-items: stretch; gap: 0; margin-bottom: 24px; padding: 0; background: none; border-radius: 0; }
  .category-hero.has-art::before { display: none; }
  .category-hero.has-art .category-hero-text { display: contents; }
  .category-hero.has-art .list-title { order: 1; }
  .category-hero.has-art .category-hero-art { order: 2; flex: none; width: 100%; aspect-ratio: 16 / 7; margin-top: 12px; }
  .category-hero.has-art .list-lead { order: 3; margin-top: 12px; }
  .category-hero.has-art .list-count { order: 4; }
}
