.archive, .blog, .search {
    background-color: #f7f7f7;
}

.p-entry-header {
    text-align: center; /* テキストを中央寄せ */
    padding: 40px 0;    /* 上下の余白（お好みで調整） */
    background: #f7f7f7; /* 背景色がある場合 */
}

.p-archive-layout {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 40px; /* メインとサイドバーの間の溝 */
    width: 100%;
}

.p-archive-layout__main {
    flex: 1; /* 残りの幅をすべて使う */
    min-width: 0;
    overflow: hidden;
    background-color: var(--wp--preset--color--white);
    padding: 20px;
    margin-bottom: 30px;
}

/* 記事内の画像・動画・表が突き抜けないようにする */
.p-archive-layout__main img,
.p-archive-layout__main iframe,
.p-archive-layout__main table,
.p-archive-layout__main video {
    max-width: 100% !important;
    height: auto !important;
}

/* 長いURLや英単語が突き抜けないように折り返す */
.p-archive-layout__main p,
.p-archive-layout__main h1,
.p-archive-layout__main h2,
.p-archive-layout__main h3 {
    word-break: break-all;
    overflow-wrap: break-word;
}

/* サイドバーがない時のメインエリア（全幅） */
.p-archive-layout__full {
    width: 100%;
    max-width: 1000px; /* お好みで。広すぎると読みづらいため */
    margin: 0 auto;    /* 中央寄せ */
}

/* =====================
   ブログカード一覧（2カラム設定）
===================== */
/* --- ブログ一覧（2カラム）専用のスタイル --- */
.p-blog-list {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important; /* 強制2列 */
    gap: 40px 24px;
    width: 100%;
}

/* カードの中身を「横並び」から「縦並び」に変える */
.p-blog-list .c-card-item__link {
    display: block !important; /* flexを解除 */
    text-decoration: none;
}

/* 画像のサイズを2枚並びに最適化 */
.p-blog-list .c-card-item__thumbnail {
    width: 100% !important; /* 横幅いっぱい（カードの半分） */
    margin-bottom: 15px;
}

.p-blog-list .c-card-item__thumbnail img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9; /* アスペクト比を固定するときれいに並びます */
    object-fit: cover;
    border-radius: 8px;
}

/* タイトルの調整 */
.p-blog-list .c-card-item__title {
    font-size: 16px;
    line-height: 1.5;
    color: #333;
}

/* --- 3枚並び専用のスタイル --- */
.p-blog-list--wide {
    grid-template-columns: repeat(3, 1fr) !important; /* 強制的に3列にする */
    gap: 40px 24px;
    max-width: 1200px; /* 必要に応じて調整 */
    margin: 0 auto;
}

/* =====================
   ページネーション（正方形デザイン）
===================== */
.p-pagination {
    display: flex;
    justify-content: center;
    margin-top: 60px;
    margin-bottom: 20px;
}

.p-pagination .nav-links {
    display: flex;
    gap: 8px; /* 数字同士の隙間 */
}

/* 数字と記号の共通スタイル */
.p-pagination .page-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;  /* 正方形の幅 */
    height: 40px; /* 正方形の高さ */
    background: #f5f5f5; /* グレーの背景 */
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
}

/* 現在のページのスタイル（オレンジ背景） */
.p-pagination .page-numbers.current {
    background: var(--wp--preset--color--main-color, #ff7a00);
    color: #fff;
}

/* ホバー時のスタイル */
.p-pagination a.page-numbers:hover {
    background: #e0e0e0;
}

/* 「...」（省略記号）のスタイル調整 */
.p-pagination .page-numbers.dots {
    background: transparent; /* 省略記号は背景なしにする場合 */
    color: #999;
}

/* 「次へ」「前へ」の記号調整 */
.p-pagination .next,
.p-pagination .prev {
    font-family: serif; /* 記号の見た目を調整 */
}

@media (max-width: 1024px) {
    .p-archive-layout {
        flex-direction: column; /* メインとサイドバーを縦並びに */
        gap: 30px;
    }

    .p-archive-layout__sidebar {
        width: 100%;
    }
}

@media (max-width: 599px) {
    .p-archive-layout__main {
        padding: 15px; /* 余白を少し削ってカードを大きく見せる */
    }

    /* 通常のブログリストを1枚並びに強制 */
    .p-blog-list {
        grid-template-columns: 1fr !important;
        gap: 30px 0 !important; /* 横の隙間を消し、縦だけ空ける */
    }

    /* 3枚並び(wide)設定も1枚並びに強制 */
    .p-blog-list--wide {
        grid-template-columns: 1fr !important;
        gap: 30px 0 !important;
    }

    /* カード内のレイアウト調整 */
    .p-blog-list .c-card-item__link {
        display: block !important; /* 縦並びを確定 */
    }

    .p-blog-list .c-card-item__thumbnail {
        width: 100% !important;
        margin-bottom: 12px;
    }

    .p-blog-list .c-card-item__title {
        font-size: 17px; /* スマホで読みやすいサイズ */
        line-height: 1.4;
    }
}