/* WordPress投稿コンテンツのスタイル（ブロック・クラシック両対応） */
.wp_content,
.entry-content,
.article {
  line-height: 1.8;
  color: #333;
  /* 画像の左・右寄せ用 Grid（float 不使用） */
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0 1.5em;
  align-items: start;
}

/* コンテナ共通（直下のブロック・要素に適用） */
.wp_content>*,
.entry-content>*,
.article>* {
  max-width: 100%;
  grid-column: 2;
  /* デフォルトは中央列（本文） */
  min-width: 0;
}

/* 段落 */
.wp_content p,
.entry-content p,
.article p,
.wp_content .wp-block-paragraph,
.entry-content .wp-block-paragraph,
.article .wp-block-paragraph {
  margin: 0 0 1.5em;
  line-height: 1.8;
}

.wp_content p:last-child,
.entry-content p:last-child,
.article p:last-child {
  margin-bottom: 0;
}

/* 見出し */
.wp_content h1,
.wp_content h2,
.wp_content h3,
.wp_content h4,
.wp_content h5,
.wp_content h6,
.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6,
.article h1,
.article h2,
.article h3,
.article h4,
.article h5,
.article h6,
.wp_content .wp-block-heading,
.entry-content .wp-block-heading,
.article .wp-block-heading {
  font-weight: bold;
  margin: 2em 0 1em;
  line-height: 1.5;
  color: #333;
}

.wp_content h1,
.entry-content h1,
.article h1,
.wp_content .wp-block-heading h1,
.entry-content .wp-block-heading h1 {
  font-size: 2em;
  border-bottom: 2px solid var(--color);
  padding-bottom: 0.5em;
}

.wp_content h2,
.entry-content h2,
.article h2,
.wp_content .wp-block-heading h2,
.entry-content .wp-block-heading h2 {
  font-size: 1.75em;
  border-bottom: 2px solid var(--color);
  padding-bottom: 0.5em;
}

.wp_content h3,
.entry-content h3,
.article h3,
.wp_content .wp-block-heading h3,
.entry-content .wp-block-heading h3 {
  font-size: 1.5em;
  border-left: 4px solid var(--color);
  padding-left: 0.75em;
}

.wp_content h4,
.entry-content h4,
.article h4 {
  font-size: 1.25em;
}

.wp_content h5,
.entry-content h5,
.article h5 {
  font-size: 1.1em;
}

.wp_content h6,
.entry-content h6,
.article h6 {
  font-size: 1em;
}

/* リスト */
.wp_content ul,
.wp_content ol,
.entry-content ul,
.entry-content ol,
.article ul,
.article ol,
.wp_content .wp-block-list,
.entry-content .wp-block-list,
.article .wp-block-list {
  margin: 1.5em 0;
  padding-left: 2em;
}

.wp_content ul,
.entry-content ul,
.article ul {
  list-style-type: disc;
}

.wp_content ol,
.entry-content ol,
.article ol {
  list-style-type: decimal;
}

.wp_content li,
.entry-content li,
.article li,
.wp_content .wp-block-list li,
.entry-content .wp-block-list li,
.article .wp-block-list li {
  margin: 0.5em 0;
  line-height: 1.8;
}

.wp_content ul ul,
.wp_content ol ol,
.wp_content ul ol,
.wp_content ol ul,
.entry-content ul ul,
.entry-content ol ol,
.entry-content ul ol,
.entry-content ol ul,
.article ul ul,
.article ol ol,
.article ul ol,
.article ol ul {
  margin: 0.5em 0;
}

/* ========== 画像（共通・中央） ========== */
.wp_content img,
.entry-content img,
.article img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

.wp_content figure,
.entry-content figure,
.article figure,
.wp_content .wp-block-image,
.entry-content .wp-block-image,
.article .wp-block-image {
  margin: 2em 0;
}

.wp_content figure img,
.entry-content figure img,
.article figure img,
.wp_content .wp-block-image img,
.entry-content .wp-block-image img,
.article .wp-block-image img {
  display: block;
  margin: 0 auto;
}

.wp_content figcaption,
.entry-content figcaption,
.article figcaption,
.wp_content .wp-block-image figcaption,
.entry-content .wp-block-image figcaption,
.article .wp-block-image figcaption {
  margin-top: 0.5em;
  font-size: 0.9em;
  color: #666;
  text-align: center;
}

/* ========== img を持つ p（中央寄せ・PC版） ========== */
.wp_content p:has(img),
.entry-content p:has(img),
.article p:has(img) {
  /* text-align: center; */
  margin: 2em 0;
}

.wp_content p:has(img) img,
.entry-content p:has(img) img,
.article p:has(img) img {
  display: block;
  margin-left: auto;
  margin-right: auto;
  max-width: 85%;
  height: auto;
}

/* img が2枚の p → 横2列 */
.wp_content p:has(img:nth-of-type(2)):not(:has(img:nth-of-type(3))),
.entry-content p:has(img:nth-of-type(2)):not(:has(img:nth-of-type(3))),
.article p:has(img:nth-of-type(2)):not(:has(img:nth-of-type(3))) {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1em;
  text-align: center;
}

.wp_content p:has(img:nth-of-type(2)):not(:has(img:nth-of-type(3))) img,
.entry-content p:has(img:nth-of-type(2)):not(:has(img:nth-of-type(3))) img,
.article p:has(img:nth-of-type(2)):not(:has(img:nth-of-type(3))) img {
  max-width: 100%;
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* img が3枚の p → 横3列 */
.wp_content p:has(img:nth-of-type(3)):not(:has(img:nth-of-type(4))),
.entry-content p:has(img:nth-of-type(3)):not(:has(img:nth-of-type(4))),
.article p:has(img:nth-of-type(3)):not(:has(img:nth-of-type(4))) {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1em;
  text-align: center;
}

.wp_content p:has(img:nth-of-type(3)):not(:has(img:nth-of-type(4))) img,
.entry-content p:has(img:nth-of-type(3)):not(:has(img:nth-of-type(4))) img,
.article p:has(img:nth-of-type(3)):not(:has(img:nth-of-type(4))) img {
  max-width: 100%;
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* img が4枚以上の p → 横4列 */
.wp_content p:has(img:nth-of-type(4)),
.entry-content p:has(img:nth-of-type(4)),
.article p:has(img:nth-of-type(4)) {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1em;
  text-align: center;
}

.wp_content p:has(img:nth-of-type(4)) img,
.entry-content p:has(img:nth-of-type(4)) img,
.article p:has(img:nth-of-type(4)) img {
  max-width: 100%;
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* ========== 画像の横並び（左・右・中央）Grid 配置 ========== */
.wp_content>.alignleft,
.entry-content>.alignleft,
.article>.alignleft,
.wp_content>.wp-block-image.alignleft,
.entry-content>.wp-block-image.alignleft,
.article>.wp-block-image.alignleft,
.wp_content>figure.alignleft,
.entry-content>figure.alignleft,
.article>figure.alignleft {
  grid-column: 1;
  grid-row: span 999;
  align-self: start;
  justify-self: start;
  margin: 0.5em 1.5em 1em 0;
  max-width: 50%;
}

.wp_content>.alignright,
.entry-content>.alignright,
.article>.alignright,
.wp_content>.wp-block-image.alignright,
.entry-content>.wp-block-image.alignright,
.article>.wp-block-image.alignright,
.wp_content>figure.alignright,
.entry-content>figure.alignright,
.article>figure.alignright {
  grid-column: 3;
  grid-row: span 999;
  align-self: start;
  justify-self: end;
  margin: 0.5em 0 1em 1.5em;
  max-width: 50%;
}

.wp_content>.aligncenter,
.entry-content>.aligncenter,
.article>.aligncenter,
.wp_content>.wp-block-image.aligncenter,
.entry-content>.wp-block-image.aligncenter,
.article>.wp-block-image.aligncenter,
.wp_content>figure.aligncenter,
.entry-content>figure.aligncenter,
.article>figure.aligncenter {
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 2em;
  margin-bottom: 2em;
}

/* img.alignleft / img.alignright は figure や .wp-block-image の子のため、親で配置済み。中央は親が full なので img は block margin auto */
.wp_content img.alignleft,
.entry-content img.alignleft,
.article img.alignleft,
.wp_content img.alignright,
.entry-content img.alignright,
.article img.alignright {
  max-width: 100%;
}

.wp_content .alignwide,
.entry-content .alignwide,
.article .alignwide {
  grid-column: 1 / -1;
  max-width: 100%;
  justify-self: center;
}

.wp_content .alignfull,
.entry-content .alignfull,
.article .alignfull {
  grid-column: 1 / -1;
  max-width: none;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  box-sizing: border-box;
}

/* グループ・クリアフィックス（子レイアウト用） */
.wp_content .wp-block-group,
.entry-content .wp-block-group,
.article .wp-block-group,
.wp_content .clearfix,
.entry-content .clearfix,
.article .clearfix {
  overflow: hidden;
}

/* ========== ギャラリー（ブロック） ========== */
.wp_content .wp-block-gallery,
.entry-content .wp-block-gallery,
.article .wp-block-gallery {
  margin: 2em 0;
  display: grid;
  gap: 1em;
  list-style: none;
  padding: 0;
  margin-left: 0;
  margin-right: 0;
}

.wp_content .wp-block-gallery .wp-block-image,
.entry-content .wp-block-gallery .wp-block-image,
.article .wp-block-gallery .wp-block-image,
.wp_content .wp-block-gallery .blocks-gallery-item,
.entry-content .wp-block-gallery .blocks-gallery-item,
.article .wp-block-gallery .blocks-gallery-item {
  margin: 0;
}

.wp_content .wp-block-gallery img,
.entry-content .wp-block-gallery img,
.article .wp-block-gallery img {
  margin: 0;
  width: 100%;
  height: auto;
  display: block;
}

/* ギャラリー カラム数 */
.wp_content .wp-block-gallery.columns-2,
.entry-content .wp-block-gallery.columns-2,
.article .wp-block-gallery.columns-2 {
  grid-template-columns: repeat(2, 1fr);
}

.wp_content .wp-block-gallery.columns-3,
.entry-content .wp-block-gallery.columns-3,
.article .wp-block-gallery.columns-3 {
  grid-template-columns: repeat(3, 1fr);
}

.wp_content .wp-block-gallery.columns-4,
.entry-content .wp-block-gallery.columns-4,
.article .wp-block-gallery.columns-4 {
  grid-template-columns: repeat(4, 1fr);
}

.wp_content .wp-block-gallery.columns-5,
.entry-content .wp-block-gallery.columns-5,
.article .wp-block-gallery.columns-5 {
  grid-template-columns: repeat(5, 1fr);
}

.wp_content .wp-block-gallery.columns-6,
.entry-content .wp-block-gallery.columns-6,
.article .wp-block-gallery.columns-6 {
  grid-template-columns: repeat(6, 1fr);
}

/* クラシックギャラリー（.gallery） */
.wp_content .gallery,
.entry-content .gallery,
.article .gallery {
  margin: 2em 0;
  display: grid;
  gap: 0.5em;
}

.wp_content .gallery.gallery-columns-2,
.entry-content .gallery.gallery-columns-2,
.article .gallery.gallery-columns-2 {
  grid-template-columns: repeat(2, 1fr);
}

.wp_content .gallery.gallery-columns-3,
.entry-content .gallery.gallery-columns-3,
.article .gallery.gallery-columns-3 {
  grid-template-columns: repeat(3, 1fr);
}

.wp_content .gallery.gallery-columns-4,
.entry-content .gallery.gallery-columns-4,
.article .gallery.gallery-columns-4 {
  grid-template-columns: repeat(4, 1fr);
}

.wp_content .gallery.gallery-columns-5,
.entry-content .gallery.gallery-columns-5,
.article .gallery.gallery-columns-5 {
  grid-template-columns: repeat(5, 1fr);
}

.wp_content .gallery.gallery-columns-6,
.entry-content .gallery.gallery-columns-6,
.article .gallery.gallery-columns-6 {
  grid-template-columns: repeat(6, 1fr);
}

.wp_content .gallery-item,
.entry-content .gallery-item,
.article .gallery-item {
  margin: 0;
}

.wp_content .gallery-caption,
.entry-content .gallery-caption,
.article .gallery-caption {
  font-size: 0.85em;
  color: #666;
  margin-top: 0.25em;
}

/* ========== カラムブロック（横並び） ========== */
.wp_content .wp-block-columns,
.entry-content .wp-block-columns,
.article .wp-block-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 2em;
  margin: 2em 0;
}

.wp_content .wp-block-column,
.entry-content .wp-block-column,
.article .wp-block-column {
  flex: 1;
  min-width: 0;
}

.wp_content .wp-block-columns:not(.is-not-stacked-on-mobile) .wp-block-column,
.entry-content .wp-block-columns:not(.is-not-stacked-on-mobile) .wp-block-column,
.article .wp-block-columns:not(.is-not-stacked-on-mobile) .wp-block-column {
  flex-basis: 0;
  flex-grow: 1;
}

/* メディア＆テキストブロック */
.wp_content .wp-block-media-text,
.entry-content .wp-block-media-text,
.article .wp-block-media-text {
  display: grid;
  margin: 2em 0;
  gap: 0;
}

.wp_content .wp-block-media-text.has-media-on-the-right,
.entry-content .wp-block-media-text.has-media-on-the-right,
.article .wp-block-media-text.has-media-on-the-right {
  direction: rtl;
}

.wp_content .wp-block-media-text.has-media-on-the-right>*,
.entry-content .wp-block-media-text.has-media-on-the-right>*,
.article .wp-block-media-text.has-media-on-the-right>* {
  direction: ltr;
}

.wp_content .wp-block-media-text__media,
.entry-content .wp-block-media-text__media,
.article .wp-block-media-text__media {
  margin: 0;
}

.wp_content .wp-block-media-text__media img,
.entry-content .wp-block-media-text__media img,
.article .wp-block-media-text__media img {
  margin: 0;
  width: 100%;
  height: auto;
  display: block;
}

.wp_content .wp-block-media-text__content,
.entry-content .wp-block-media-text__content,
.article .wp-block-media-text__content {
  padding: 1.5em;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* テーブル */
.wp_content table,
.entry-content table,
.article table,
.wp_content .wp-block-table,
.entry-content .wp-block-table,
.article .wp-block-table {
  width: 100%;
  border-collapse: collapse;
  margin: 2em 0;
  font-size: 0.95em;
}

.wp_content .wp-block-table table {
  width: 100%;
  margin: 0;
}

.wp_content table th,
.wp_content table td,
.entry-content table th,
.entry-content table td,
.article table th,
.article table td,
.wp_content .wp-block-table th,
.wp_content .wp-block-table td,
.entry-content .wp-block-table th,
.entry-content .wp-block-table td,
.article .wp-block-table th,
.article .wp-block-table td {
  padding: 0.75em 1em;
  border: 1px solid #ddd;
  text-align: left;
}

.wp_content table th,
.entry-content table th,
.article table th,
.wp_content .wp-block-table th,
.entry-content .wp-block-table th,
.article .wp-block-table th {
  background: var(--color);
  color: #fff;
  font-weight: bold;
  text-align: center;
}

.wp_content table tr:nth-child(even),
.entry-content table tr:nth-child(even),
.article table tr:nth-child(even) {
  background: #f9f9f9;
}

.wp_content table tr:hover,
.entry-content table tr:hover,
.article table tr:hover {
  background: #f5f5f5;
}

/* リンク */
.wp_content a,
.entry-content a,
.article a {
  color: var(--color);
  text-decoration: underline;
  transition: opacity 0.2s ease;
}

.wp_content a:hover,
.entry-content a:hover,
.article a:hover {
  opacity: 0.8;
  text-decoration: none;
}

/* 引用 */
.wp_content blockquote,
.entry-content blockquote,
.article blockquote,
.wp_content .wp-block-quote,
.entry-content .wp-block-quote,
.article .wp-block-quote {
  margin: 2em 0;
  padding: 1em 1.5em;
  border-left: 4px solid var(--color);
  background: #f9f9f9;
  font-style: italic;
  color: #555;
}

.wp_content blockquote p,
.entry-content blockquote p,
.article blockquote p,
.wp_content .wp-block-quote p,
.entry-content .wp-block-quote p,
.article .wp-block-quote p {
  margin: 0;
}

.wp_content blockquote cite,
.entry-content blockquote cite,
.article blockquote cite,
.wp_content .wp-block-quote cite,
.entry-content .wp-block-quote cite,
.article .wp-block-quote cite {
  display: block;
  margin-top: 0.5em;
  font-size: 0.9em;
  font-style: normal;
  color: #666;
}

/* コード */
.wp_content code,
.entry-content code,
.article code,
.wp_content .wp-block-code code,
.entry-content .wp-block-code code,
.article .wp-block-code code {
  background: #f4f4f4;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9em;
  color: #d63384;
}

.wp_content pre,
.entry-content pre,
.article pre,
.wp_content .wp-block-code,
.entry-content .wp-block-code,
.article .wp-block-code {
  background: #f4f4f4;
  padding: 1em;
  border-radius: 4px;
  overflow-x: auto;
  margin: 2em 0;
  line-height: 1.6;
}

.wp_content .wp-block-code pre {
  padding: 0;
  margin: 0;
}

.wp_content pre code,
.entry-content pre code,
.article pre code,
.wp_content .wp-block-code code,
.entry-content .wp-block-code code,
.article .wp-block-code code {
  background: none;
  padding: 0;
  color: #333;
}

/* 太字・斜体 */
.wp_content strong,
.wp_content b,
.entry-content strong,
.entry-content b,
.article strong,
.article b {
  font-weight: bold;
  color: #333;
}

.wp_content em,
.entry-content em,
.article em,
.wp_content i,
.entry-content i,
.article i {
  font-style: italic;
}

/* 区切り線 */
.wp_content hr,
.entry-content hr,
.article hr,
.wp_content .wp-block-separator,
.entry-content .wp-block-separator,
.article .wp-block-separator {
  border: none;
  border-top: 2px solid #ddd;
  margin: 3em 0;
}

/* 定義リスト */
.wp_content dl,
.entry-content dl,
.article dl {
  margin: 1.5em 0;
}

.wp_content dt,
.entry-content dt,
.article dt {
  font-weight: bold;
  margin-top: 1em;
  color: #333;
}

.wp_content dd,
.entry-content dd,
.article dd {
  margin: 0.5em 0 0 1.5em;
  color: #555;
}

/* ボタンブロック */
.wp_content .wp-block-buttons,
.entry-content .wp-block-buttons,
.article .wp-block-buttons {
  margin: 2em 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
}

.wp_content .wp-block-button__link,
.entry-content .wp-block-button__link,
.article .wp-block-button__link {
  display: inline-block;
  padding: 0.6em 1.2em;
  background: var(--color);
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  transition: opacity 0.2s ease;
}

.wp_content .wp-block-button__link:hover,
.entry-content .wp-block-button__link:hover,
.article .wp-block-button__link:hover {
  opacity: 0.9;
}

/* 埋め込み */
.wp_content iframe,
.entry-content iframe,
.article iframe,
.wp_content embed,
.entry-content embed,
.article embed,
.wp_content object,
.entry-content object,
.article object,
.wp_content .wp-block-embed,
.entry-content .wp-block-embed,
.article .wp-block-embed {
  max-width: 100%;
  margin: 2em auto;
  display: block;
}

.wp_content .wp-block-embed iframe,
.entry-content .wp-block-embed iframe,
.article .wp-block-embed iframe {
  width: 100%;
}

/* クラシックブロック（.wp-block-freeform）内も同じ Grid で画像配置 */
.wp_content .wp-block-freeform,
.entry-content .wp-block-freeform,
.article .wp-block-freeform {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0 1.5em;
  align-items: start;
}

.wp_content .wp-block-freeform>*,
.entry-content .wp-block-freeform>*,
.article .wp-block-freeform>* {
  grid-column: 2;
  min-width: 0;
}

.wp_content .wp-block-freeform>.alignleft,
.entry-content .wp-block-freeform>.alignleft,
.article .wp-block-freeform>.alignleft,
.wp_content .wp-block-freeform>figure.alignleft,
.entry-content .wp-block-freeform>figure.alignleft,
.article .wp-block-freeform>figure.alignleft {
  grid-column: 1;
  grid-row: span 999;
  align-self: start;
  justify-self: start;
  margin: 0.5em 1.5em 1em 0;
  max-width: 50%;
}

.wp_content .wp-block-freeform>.alignright,
.entry-content .wp-block-freeform>.alignright,
.article .wp-block-freeform>.alignright,
.wp_content .wp-block-freeform>figure.alignright,
.entry-content .wp-block-freeform>figure.alignright,
.article .wp-block-freeform>figure.alignright {
  grid-column: 3;
  grid-row: span 999;
  align-self: start;
  justify-self: end;
  margin: 0.5em 0 1em 1.5em;
  max-width: 50%;
}

.wp_content .wp-block-freeform>.aligncenter,
.entry-content .wp-block-freeform>.aligncenter,
.article .wp-block-freeform>.aligncenter,
.wp_content .wp-block-freeform>figure.aligncenter,
.entry-content .wp-block-freeform>figure.aligncenter,
.article .wp-block-freeform>figure.aligncenter {
  grid-column: 1 / -1;
  justify-self: center;
}

/* ========== レスポンシブ ========== */
@media screen and (max-width: 768px) {

  .wp_content h1,
  .entry-content h1,
  .article h1 {
    font-size: 1.75em;
  }

  .wp_content h2,
  .entry-content h2,
  .article h2 {
    font-size: 1.5em;
  }

  .wp_content h3,
  .entry-content h3,
  .article h3 {
    font-size: 1.25em;
  }

  /* img を持つ p（768px：余白・画像幅を調整） */
  .wp_content p:has(img),
  .entry-content p:has(img),
  .article p:has(img) {
    margin: 1.5em 1em;
  }

  .wp_content p:has(img) img,
  .entry-content p:has(img) img,
  .article p:has(img) img {
    max-width: 90%;
  }

  /* img 2・3・4列 → 768px では最大2列 */
  .wp_content p:has(img:nth-of-type(3)):not(:has(img:nth-of-type(4))),
  .entry-content p:has(img:nth-of-type(3)):not(:has(img:nth-of-type(4))),
  .article p:has(img:nth-of-type(3)):not(:has(img:nth-of-type(4))),
  .wp_content p:has(img:nth-of-type(4)),
  .entry-content p:has(img:nth-of-type(4)),
  .article p:has(img:nth-of-type(4)) {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 画像の横並びを解除（縦積み・Grid 上書き） */
  .wp_content>.alignleft,
  .entry-content>.alignleft,
  .article>.alignleft,
  .wp_content>.wp-block-image.alignleft,
  .entry-content>.wp-block-image.alignleft,
  .article>.wp-block-image.alignleft,
  .wp_content>figure.alignleft,
  .entry-content>figure.alignleft,
  .article>figure.alignleft,
  .wp_content>.alignright,
  .entry-content>.alignright,
  .article>.alignright,
  .wp_content>.wp-block-image.alignright,
  .entry-content>.wp-block-image.alignright,
  .article>.wp-block-image.alignright,
  .wp_content>figure.alignright,
  .entry-content>figure.alignright,
  .article>figure.alignright,
  .wp_content .wp-block-freeform>.alignleft,
  .entry-content .wp-block-freeform>.alignleft,
  .article .wp-block-freeform>.alignleft,
  .wp_content .wp-block-freeform>figure.alignleft,
  .entry-content .wp-block-freeform>figure.alignleft,
  .article .wp-block-freeform>figure.alignleft,
  .wp_content .wp-block-freeform>.alignright,
  .entry-content .wp-block-freeform>.alignright,
  .article .wp-block-freeform>.alignright,
  .wp_content .wp-block-freeform>figure.alignright,
  .entry-content .wp-block-freeform>figure.alignright,
  .article .wp-block-freeform>figure.alignright {
    grid-column: 1 / -1;
    grid-row: auto;
    justify-self: center;
    max-width: 100%;
    margin: 1em auto;
  }

  /* ギャラリー カラム数を減らす */
  .wp_content .wp-block-gallery.columns-4,
  .entry-content .wp-block-gallery.columns-4,
  .article .wp-block-gallery.columns-4,
  .wp_content .wp-block-gallery.columns-5,
  .entry-content .wp-block-gallery.columns-5,
  .article .wp-block-gallery.columns-5,
  .wp_content .wp-block-gallery.columns-6,
  .entry-content .wp-block-gallery.columns-6,
  .article .wp-block-gallery.columns-6 {
    grid-template-columns: repeat(2, 1fr);
  }

  .wp_content .wp-block-gallery.columns-3,
  .entry-content .wp-block-gallery.columns-3,
  .article .wp-block-gallery.columns-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .wp_content .gallery.gallery-columns-4,
  .entry-content .gallery.gallery-columns-4,
  .article .gallery.gallery-columns-4,
  .wp_content .gallery.gallery-columns-5,
  .entry-content .gallery.gallery-columns-5,
  .article .gallery.gallery-columns-5,
  .wp_content .gallery.gallery-columns-6,
  .entry-content .gallery.gallery-columns-6,
  .article .gallery.gallery-columns-6 {
    grid-template-columns: repeat(2, 1fr);
  }

  .wp_content .gallery.gallery-columns-3,
  .entry-content .gallery.gallery-columns-3,
  .article .gallery.gallery-columns-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* カラムブロック 縦積み */
  .wp_content .wp-block-columns,
  .entry-content .wp-block-columns,
  .article .wp-block-columns {
    flex-direction: column;
    gap: 1em;
  }

  .wp_content .wp-block-column,
  .entry-content .wp-block-column,
  .article .wp-block-column {
    flex: none;
    width: 100%;
  }

  /* メディア＆テキスト 縦積み */
  .wp_content .wp-block-media-text,
  .entry-content .wp-block-media-text,
  .article .wp-block-media-text {
    grid-template-columns: 1fr;
    direction: ltr;
  }

  .wp_content .wp-block-media-text.has-media-on-the-right .wp-block-media-text__media,
  .entry-content .wp-block-media-text.has-media-on-the-right .wp-block-media-text__media,
  .article .wp-block-media-text.has-media-on-the-right .wp-block-media-text__media {
    order: 1;
  }

  .wp_content .wp-block-media-text.has-media-on-the-right .wp-block-media-text__content,
  .entry-content .wp-block-media-text.has-media-on-the-right .wp-block-media-text__content,
  .article .wp-block-media-text.has-media-on-the-right .wp-block-media-text__content {
    order: 2;
  }

  .wp_content .wp-block-media-text__content,
  .entry-content .wp-block-media-text__content,
  .article .wp-block-media-text__content {
    padding: 1em;
  }

  /* テーブル 横スクロール */
  .wp_content table,
  .entry-content table,
  .article table,
  .wp_content .wp-block-table,
  .entry-content .wp-block-table,
  .article .wp-block-table {
    font-size: 0.85em;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .wp_content table th,
  .wp_content table td,
  .entry-content table th,
  .entry-content table td,
  .article table th,
  .article table td {
    padding: 0.5em;
  }

  /* ボタン 縦積み */
  .wp_content .wp-block-buttons,
  .entry-content .wp-block-buttons,
  .article .wp-block-buttons {
    flex-direction: column;
  }

  .wp_content .wp-block-button__link,
  .entry-content .wp-block-button__link,
  .article .wp-block-button__link {
    display: block;
    text-align: center;
  }
}

@media screen and (max-width: 480px) {

  /* img を持つ p（480px：フル幅寄せ・余白を詰める） */
  .wp_content p:has(img),
  .entry-content p:has(img),
  .article p:has(img) {
    margin: 1em 0;
    padding: 0 0.5em;
  }

  .wp_content p:has(img) img,
  .entry-content p:has(img) img,
  .article p:has(img) img {
    max-width: 100%;
  }

  /* img 2・3・4列 → 480px では1列（縦積み） */
  .wp_content p:has(img:nth-of-type(2)):not(:has(img:nth-of-type(3))),
  .entry-content p:has(img:nth-of-type(2)):not(:has(img:nth-of-type(3))),
  .article p:has(img:nth-of-type(2)):not(:has(img:nth-of-type(3))),
  .wp_content p:has(img:nth-of-type(3)):not(:has(img:nth-of-type(4))),
  .entry-content p:has(img:nth-of-type(3)):not(:has(img:nth-of-type(4))),
  .article p:has(img:nth-of-type(3)):not(:has(img:nth-of-type(4))),
  .wp_content p:has(img:nth-of-type(4)),
  .entry-content p:has(img:nth-of-type(4)),
  .article p:has(img:nth-of-type(4)) {
    grid-template-columns: 1fr;
  }

  .wp_content .wp-block-gallery.columns-2,
  .entry-content .wp-block-gallery.columns-2,
  .article .wp-block-gallery.columns-2,
  .wp_content .wp-block-gallery.columns-3,
  .entry-content .wp-block-gallery.columns-3,
  .article .wp-block-gallery.columns-3,
  .wp_content .wp-block-gallery.columns-4,
  .entry-content .wp-block-gallery.columns-4,
  .article .wp-block-gallery.columns-4,
  .wp_content .wp-block-gallery.columns-5,
  .entry-content .wp-block-gallery.columns-5,
  .article .wp-block-gallery.columns-5,
  .wp_content .wp-block-gallery.columns-6,
  .entry-content .wp-block-gallery.columns-6,
  .article .wp-block-gallery.columns-6 {
    grid-template-columns: 1fr;
  }

  .wp_content .gallery.gallery-columns-2,
  .entry-content .gallery.gallery-columns-2,
  .article .gallery.gallery-columns-2,
  .wp_content .gallery.gallery-columns-3,
  .entry-content .gallery.gallery-columns-3,
  .article .gallery.gallery-columns-3,
  .wp_content .gallery.gallery-columns-4,
  .entry-content .gallery.gallery-columns-4,
  .article .gallery.gallery-columns-4,
  .wp_content .gallery.gallery-columns-5,
  .entry-content .gallery.gallery-columns-5,
  .article .gallery.gallery-columns-5,
  .wp_content .gallery.gallery-columns-6,
  .entry-content .gallery.gallery-columns-6,
  .article .gallery.gallery-columns-6 {
    grid-template-columns: 1fr;
  }
}
