#detail-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;

  background-color: rgba(255, 255, 255, 0.98);
  z-index: 900;
  display: flex;
  justify-content: center;  /* 横センター */
  align-items: flex-start;  /* ★縦センターをやめる（ここが本丸） */

  overflow-y: auto;
  padding: 80px 0 40px;     /* 上に余白（ナビと干渉しない） */
  box-sizing: border-box;
}

#detail-overlay .detail-container{
  position: relative;
  top: auto;
  left: auto;
  transform: none;

  margin: 0 auto; /* ★80px は overlay 側で持つ */
  width: min(1100px, calc(100% - 40px));
  height: auto;
  box-sizing: border-box;
}

#detail-overlay .close-button{
  position: absolute;
  top: 20px;
  left: 20px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  z-index: 201;
}

/* 画像(左) + テキスト(右) */
#detail-overlay #detail-content{
  margin-top: 20px;
  display: grid;

  grid-template-columns: minmax(0, 1fr) 320px;

  /* 列は20px、行は12px（ヒーロー↔サムネ間） */
  column-gap: 20px;
  row-gap: 12px;

  /* 右カラムをヒーロー行に高さ追従させる */
  align-items: stretch;
}

/* ===== Images block ===== */
#detail-overlay .detail-images {
  /* 子要素（hero img / thumbs）を #detail-content の grid item として扱う */
  display: contents;
}

/* ===== Detail hero image: keep aspect ratio / never stretch ===== */
#detail-overlay img.detail-main {
  display: block;
  width: 100%;
  height: auto !important;
  max-height: 82vh;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.7));

  /* ===== grid placement: hero (row1 col1) ===== */
  grid-column: 1;
  grid-row: 1;
}

/* サムネ群 */
#detail-overlay .detail-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;

  /* ===== grid placement (thumb row) ===== */
  grid-column: 1;
  grid-row: 2;
}

#detail-overlay img.detail-thumb {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  object-fit: cover;
  cursor: pointer;
  border-radius: 2px;
  opacity: 0.9;
}

#detail-overlay img.detail-thumb:hover {
  opacity: 1;
}

/* ===== Text block ===== */
#detail-overlay .detail-info {
  margin: 0;
  max-width: 320px;

  /* ===== grid placement (hero row right) ===== */
  grid-column: 2;
  grid-row: 1;

  display: flex;
  flex-direction: column;
  height: 100%;
}

#detail-overlay .detail-info h2 {
  font-size: 20px;
  line-height: 1.25;
  margin: 0 0 10px;
}

/* ===== Detail Tags (chips) =====
   detail.main.js: <a class="detail-tag"...>
   detail.renderer.js: <div class="detail-tags"...>
================================= */
#detail-overlay [data-role="detail-tags"]  {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 10px 0 0 0;
  padding: 0;
}

#detail-overlay .detail-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 4px 6px;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 777px;

  background: rgba(0,0,0,0.02);
  color: #333;
  text-decoration: none;

  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.01em;
  opacity: 1;
}

#detail-overlay .detail-tag:hover {
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.26);
  color: #111;
}

#detail-overlay .detail-tag:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.15);
}
/* ===== /Detail Tags (chips) ===== */

#detail-overlay .detail-meta {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.55;
}

#detail-overlay .detail-meta-row {
  display: grid;
  grid-template-columns: 64px 1fr; /* ラベル幅固定 */
  column-gap: 10px;
}

#detail-overlay .detail-meta-label {
  opacity: 0.7;
  white-space: nowrap;
}

#detail-overlay .detail-meta-value {
  word-break: break-word;
}

#detail-overlay .detail-info p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.6;
}

/* ===== Detail: Related Works ===== */
#detail-overlay .related-works {
  /* 右カラムの最下部へ */
  margin-top: auto;
  padding-top: 20px; /* 既存の20px余白は“上側の間隔”として維持 */
}

/* 見出しが h3/h4 どちらでも同じ見た目に固定（太字・デカ文字事故を防ぐ） */
#detail-overlay .related-works h3,
#detail-overlay .related-works h4 {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.0em;
  opacity: 0.7;
  font-weight: 200;
  line-height: 1.2;
}

/* 4列固定（右カラム320pxに合わせて 71px×4 + gap12px×3 = 320px） */
#detail-overlay .related-grid {
  display: grid;
  grid-template-columns: repeat(4, 71px);
  gap: 12px;
}

/* タイルを block 化して「デカくなる」事故を防ぐ */
#detail-overlay .related-item {
  display: block;
  width: 71px;
  height: 71px;
  overflow: hidden;
  border-radius: 6px;
}

/* B案: トリミング無し（全体を入れる） */
#detail-overlay .related-item img {
  display: block;
  width: 71px;
  height: 71px;
  object-fit: contain;
  object-position: center;
}

/* ===== Detail Overlay Nav (× / < / >) =====
   - × : 左上
   - < > : 画面の垂直中央・左右端
   - 背景の◯は作らない（ミニマム）
   - pointer-events はボタンだけ有効
======================================== */

/* ===== Detail Overlay Controls =====
   座標系をここで宣言して固定する（他で触らない）
   - overlayは header より下（headerは見せる）
   - × は header下に固定（Contact link 等と当たり判定が競合しない）
   - < > は 画面縦中央・左右端
   - pointer-events はボタンだけ有効
==================================== */

/* ナビ用の全面レイヤ（ただし header よりは下） */
#detail-overlay .detail-navigation {
  position: fixed;
  inset: 0;
  z-index: 901;          /* overlay(900)の“中”で前面 */
  pointer-events: none;  /* 背景はクリック透過、ボタンだけ拾う */
}

/* ボタン共通（◯なし・最小） */
#detail-overlay .nav-button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #111;
  opacity: 0.55;
}
#detail-overlay .nav-button:hover { opacity: 0.95; }
#detail-overlay .nav-button:focus { outline: none; }

/* Prev/Next（縦中央・左右端） */
#detail-overlay #prev-work,
#detail-overlay #next-work {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 902;
}
#detail-overlay #prev-work { left: 12px; }
#detail-overlay #next-work { right: 12px; }

/* ===== Detail: Close Button (X) ===== */
#detail-overlay #close-detail {
  display: none; /* 表示は body.detail-open 側で制御 */

  position: fixed;
  top: calc(var(--header-h) + 12px);
  left: 12px;

  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;

  opacity: 0.75;
  cursor: pointer;
  z-index: 903; /* nav内の最前面（ただし header よりは下） */
}

/* Back疑似要素は使わない（SVGの×を使う） */
#detail-overlay #close-detail::before { content: none; }

#detail-overlay #close-detail:hover { opacity: 1; }
/* ===== /Detail: Close Button (X) ===== */

/* Show close button only when overlay is open */
body.detail-open #detail-overlay #close-detail {
  display: block;
}

/* SVG（nav-button共通） */
#detail-overlay .nav-button svg {
  width: 20px;
  height: 20px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;

  pointer-events: none;
}

/* ===== Responsive (detail) ===== */
@media screen and (max-width: 820px) {
#detail-overlay #detail-content{
    grid-template-columns: 1fr;
  }
  #detail-overlay .detail-info {
    max-width: none;
  }
}


/* =========================
   Safety: hidden must hide
========================= */
#detail-overlay .hidden{
  display: none !important;
}

#detail-overlay.hidden {
  display: none !important;
}

/* =========================
   Responsive: grid density
   - 旧設計を維持しつつ、--grid-columns も同期
========================= */
@media screen and (max-width: 1199px) {
  :root { --grid-cols: 4; --grid-columns: 4; }
}

@media screen and (max-width: 899px) {
  :root { --grid-cols: 3; --grid-columns: 3; }
}

@media screen and (max-width: 599px) {
  :root { --grid-cols: 2; --grid-columns: 2; }
}

/* ===== Footer Copyright ===== */
#site-copyright{
  position: fixed;
  right: 14px;
  bottom: 14px;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0em;
  opacity: 0.55;
  z-index: 9999;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}
