#TableOfContents {
  border: 1px solid black;
  padding: 1em;
  margin: 1em;
}

@media screen and (min-width:600px){
  #TableOfContents {
    width: 200px;
    float: right;
  }
}

.sidebar-label {
  font-size: small;
  font-family:"MS Pゴシック",sans-serif;
  text-decoration: none;
}

.tag-cloud a{
  text-decoration: none;
}

pre {
  border-radius: 10px;
}

pre > code {
  padding: 20px;
}

/* タグページのカバー画像 */
.tag-cover-image {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 2em;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.tag-cover-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* タグページの説明文 */
.tag-description {
  font-size: 1.1em;
  color: #666;
  margin: 1em 0 1.5em 0;
  line-height: 1.6;
}

.tag-content {
  margin: 0 0 2em 0;
  padding: 1.5em;
  background: #f9f9f9;
  border-radius: 4px;
  line-height: 1.7;
}

.tag-content p {
  margin: 0.5em 0;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .tag-cover-image {
    margin: 0 0 1.5em;
    border-radius: 4px;
  }
  
  .tag-description {
    font-size: 1em;
    padding: 0 0.5em;
  }
  
  .tag-content {
    padding: 1em;
    margin-left: 0;
    margin-right: 0;
  }
}

/* 更新日付表示 */
.meta .lastmod {
  color: #e67e22;
  font-weight: 500;
  margin-left: 0.5em;
}

/* ============================================
   Related Posts & Popular Tag Posts Styling
   ============================================ */

/* Related Posts Section */
.related-posts {
  margin-top: 3em;
  padding-top: 2em;
  border-top: 2px solid #e0e0e0;
}

.related-posts-title {
  font-size: 1.5em;
  color: #333;
  margin-bottom: 1.5em;
  font-weight: bold;
}

.related-posts-list {
  display: grid;
  gap: 1.5em;
}

.related-post-item {
  padding: 1.2em;
  background: #f9f9f9;
  border-radius: 6px;
  border-left: 4px solid #3498db;
  transition: transform 0.2s, box-shadow 0.2s;
}

.related-post-item:hover {
  transform: translateX(5px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.related-post-title {
  font-size: 1.1em;
  margin: 0 0 0.5em 0;
}

.related-post-title a {
  color: #2c3e50;
  text-decoration: none;
  font-weight: 600;
}

.related-post-title a:hover {
  color: #3498db;
}

.related-post-date {
  display: block;
  font-size: 0.85em;
  color: #888;
  margin-bottom: 0.5em;
}

.related-post-summary {
  font-size: 0.9em;
  color: #666;
  line-height: 1.6;
  margin: 0.5em 0;
}

.related-post-tags {
  margin-top: 0.8em;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
}

.related-post-tag {
  display: inline-block;
  padding: 0.2em 0.6em;
  background: #ecf0f1;
  color: #555;
  font-size: 0.75em;
  border-radius: 3px;
  font-weight: 500;
}

/* Popular Tag Posts Section */
.popular-tag-posts {
  margin: 2em 0;
  padding: 1.5em;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

.popular-posts-title {
  font-size: 1.3em;
  color: #333;
  margin-bottom: 1.2em;
  font-weight: bold;
  border-bottom: 2px solid #3498db;
  padding-bottom: 0.5em;
}

.popular-posts-list {
  display: grid;
  gap: 1.2em;
}

.popular-post-item {
  padding: 1em;
  background: #f9f9f9;
  border-radius: 4px;
  border-left: 3px solid #e67e22;
}

.popular-post-title {
  font-size: 1em;
  margin: 0 0 0.5em 0;
}

.popular-post-title a {
  color: #2c3e50;
  text-decoration: none;
  font-weight: 600;
}

.popular-post-title a:hover {
  color: #e67e22;
}

.popular-post-date {
  display: block;
  font-size: 0.8em;
  color: #888;
  margin-bottom: 0.5em;
}

.popular-post-summary {
  font-size: 0.85em;
  color: #666;
  line-height: 1.5;
  margin: 0;
}

/* Related Tags Section */
.related-tags-section {
  margin: 2em 0;
  padding: 1.5em;
  background: #f0f8ff;
  border-radius: 6px;
}

.related-tags-title {
  font-size: 1.2em;
  color: #333;
  margin-bottom: 1em;
  font-weight: bold;
}

.related-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8em;
}

.related-tag-link {
  display: inline-block;
  padding: 0.5em 1em;
  background: #3498db;
  color: #fff;
  text-decoration: none;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s;
}

.related-tag-link:hover {
  background: #2980b9;
  transform: translateY(-2px);
  box-shadow: 0 2px 6px rgba(52, 152, 219, 0.3);
}

/* Responsive Design */
@media (min-width: 768px) {
  .related-posts-list {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .popular-posts-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 767px) {
  .related-posts {
    margin-top: 2em;
    padding-top: 1.5em;
  }
  
  .related-posts-title,
  .popular-posts-title,
  .related-tags-title {
    font-size: 1.2em;
  }
  
  .popular-tag-posts,
  .related-tags-section {
    padding: 1em;
    margin: 1.5em 0;
  }
  
  .related-post-item,
  .popular-post-item {
    padding: 0.8em;
  }
}

/* 記事のカバー画像 */
.cover-image {
  width: 100%;
  max-width: 1200px;
  margin: 1.5em auto;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.cover-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* レスポンシブ対応 */
@media screen and (max-width: 768px) {
  .cover-image {
    margin: 1em 0;
    border-radius: 4px;
  }
}

/* ============================================
   Sidebar Responsive Behavior with Toggle
   ============================================ */

/* サイドバートグルボタン */
.sidebar-toggle-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: none;
  transition: all 0.3s ease;
  padding: 0;
}

.sidebar-toggle-btn span {
  display: block;
  line-height: 56px;
  text-align: center;
}

.sidebar-toggle-btn:hover {
  background: #2980b9;
  transform: scale(1.1);
}

.sidebar-toggle-btn:active {
  transform: scale(0.95);
}

/* 1199px以下でトグルボタンを表示 */
@media screen and (max-width: 1199px) {
  .sidebar-toggle-btn {
    display: block;
  }
}

/* サイドバーオーバーレイ（背景の暗転） */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* タブレット以下でのサイドバー */
@media screen and (max-width: 1199px) {
  aside.sidebar {
    position: fixed !important;
    top: 0 !important;
    right: -400px !important;  /* 完全に隠す（パディング含む実際の幅より大きく） */
    width: 320px !important;
    height: 100% !important;
    overflow-y: auto !important;
    background: #fff !important;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15) !important;
    z-index: 1001 !important;
    transition: right 0.3s ease !important;
    padding: 20px !important;
    box-sizing: border-box !important;  /* パディングを幅に含める */
    float: none !important;
    margin: 0 !important;
  }
  
  /* サイドバーが開いている状態 */
  aside.sidebar.active {
    right: 0 !important;
    display: block !important;
    visibility: visible !important;
  }
  
  /* サイドバーが開いている状態 */
  aside.sidebar.active {
    right: 0 !important;
  }
  
  /* サイドバー非表示時はコンテンツ幅を最大化 */
  #content {
    margin-right: 0 !important;
  }
  
  /* サイドバー内のセクション調整 */
  aside.sidebar section {
    width: 100% !important;
    float: none !important;
    margin-left: 0 !important;
  }
  
  /* 閉じるボタン */
  aside.sidebar::before {
    content: '×';
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 36px;
    color: #666;
    cursor: pointer;
    z-index: 1002;
  }
}

/* デスクトップ（1200px以上）では通常表示 */
@media screen and (min-width: 1200px) {
  aside.sidebar {
    display: block;
    position: static !important;
    right: auto !important;
  }
  
  .sidebar-toggle-btn,
  .sidebar-overlay {
    display: none !important;
  }
}
