body {
    font-family: sans-serif;
    color: #333;
    margin: 0;
}

.site-container {
    display: flex;
    height: 100vh; /* 画面の高さいっぱいに広げる */
}

.sidebar {
    display: flex; /* Flexboxレイアウトを有効にする */
    flex-direction: column; /* 子要素を縦に並べる */
    width: 240px;
    height: 100vh; /* Fallback for older browsers */
    height: 100svh; /* 動的ツールバーを考慮したビューポートの高さ */
    background-color: #f8f9fa;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    box-sizing: border-box; /* paddingを含めて高さを計算 */
    /* overflow-y: auto; はリスト側に移すため削除 */
}

.sidebar h1 {
    font-size: 1.5em;
    margin-top: 0;
    text-align: left; /* メニュータイトルを左揃えに変更 */
}

.gallery-list {
    list-style: none;
    padding: 0;
    margin: 20px 0; /* 上下のマージンを調整 */
    flex-grow: 1; /* 残りの垂直スペースをすべて埋める */
    overflow-y: auto; /* リストの内容が多ければスクロールさせる */
}

.gallery-list li a {
    display: block;
    padding: 10px 15px;
    margin-bottom: 5px;
    color: #337ab7;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.gallery-list li a:hover {
    background-color: #e9ecef;
}

/* --- SNS共有リンク --- */
.social-share {
    margin-top: auto; /* 残りの空間をすべて使い、要素を一番下に押し下げる */
}

.social-share p {
    margin: 0 0 10px;
    font-weight: bold;
    font-size: 0.9em;
}

.social-share a {
    display: inline-block; /* aタグの領域を画像に合わせる */
}

.social-share img {
    width: 28px; /* ロゴのサイズを調整 */
    height: 28px;
    opacity: 0.6; /* 通常時の透明度 */
    transition: opacity 0.2s ease;
}

.social-share a:hover img {
    opacity: 1; /* ホバー時に不透明にする */
}

.copyright {
    position: absolute; /* 親要素(.content)を基準に配置 */
    bottom: 0;
    left: 0;
    right: 0;
    padding: 5px;
    font-size: 0.8em;
    color: #666;
    text-align: center;
    pointer-events: none; /* コピーライトが下のコンテンツのクリックを妨げないようにする */
}

.content {
    flex-grow: 1; /* 残りの幅をすべて使う */
    display: flex;
}

.content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* --- ハンバーガーメニューボタン --- */
.menu-toggle-button {
    display: none; /* PCでは非表示 */
    position: fixed;
    top: 10px;
    right: 10px; /* 右上に配置 */
    width: 44px;
    height: 44px;    
    background: rgba(255, 255, 255, 0.8); /* 背景を半透明の白に戻す */
    border: 1px solid #ddd; /* 枠線を追加 */
    border-radius: 5px;
    z-index: 1100; /* サイドバーより手前に表示 */
    cursor: pointer;
}

.menu-toggle-button span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: #333; /* 線の色を黒に戻す */
    margin: 5px auto;
    transition: all 0.3s;
}

/* --- スマートフォン向けのスタイル --- */
@media (max-width: 768px) {
    .menu-toggle-button {
        display: block; /* スマホで表示 */
    }

    .site-container {
        flex-direction: column; /* flexアイテムを縦に並べる */
        height: auto;
    }

    .sidebar {
        position: fixed; /* 画面に固定して重ねる */
        left: 0;
        top: 0;
        width: 240px;
        height: 100vh; /* Fallback for older browsers */
        height: 100svh; /* 動的ツールバーを考慮したビューポートの高さ */
        transform: translateX(-100%); /* 初期状態では画面の外(左側)に隠す */
        transition: transform 0.3s ease-in-out; /* スライドアニメーション */
        display: flex; /* Flexboxレイアウトを再度有効にする */
        flex-direction: column; /* 子要素を縦に並べる */
        z-index: 1050; /* コンテンツより手前に */
    }

    .sidebar.open {
        transform: translateX(0); /* activeクラスが付いたら表示 */
    }

    .content {
        width: 100%;
        height: 100vh;
    }
}

/* --- ここからギャラリーページ用のスタイル (style.cssから統合) --- */

/* ギャラリーページのタイトルを中央揃え */
body > h1 {
    text-align: center;
}

/* モーダル表示中に背景をスクロールさせないためのスタイル */
body.modal-open {
    overflow: hidden;
}

.gallery-container {
    display: flex;
    flex-wrap: wrap;
    /* 画面幅で折り返す */
    justify-content: center;
    /* 中央揃え */
    gap: 20px;
    /* イラスト間の余白 */
    padding: 20px;
}

.illust-wrapper {
    position: relative;
    /* 子要素を絶対配置するための基準 */
    width: 200px;
    height: 200px;
    border: 2px solid #ccc;
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    /* はみ出した部分を隠す */
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.illust-wrapper:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* 2枚の画像を同じ位置に配置 */
.illust-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ホバー用の画像は最初は透明にしておく */
.illust-hover {
    opacity: 0;
    transition: opacity 0.4s ease;
    /* 0.4秒かけて透明度を変化させる */
}

/* ラッパーにホバーしたときに、ホバー用の画像を不透明にする */
.illust-wrapper:hover .illust-hover, .illust-wrapper.touch-hover .illust-hover {
    opacity: 1;
}

/* --- モーダルウィンドウのスタイル --- */
.modal-overlay {
    position: fixed; /* 画面に固定 */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh; /* Fallback for older browsers */
    height: 100svh; /* Adjust to the smallest viewport height to prevent scrolling */
    background-color: rgba(0, 0, 0, 0.7); /* 半透明の黒い背景 */
    display: none;   /* 初期状態では非表示 */
    justify-content: center;
    align-items: center;
    z-index: 1000; /* 他の要素より手前に表示 */
}

.modal-overlay.active {
    display: flex; /* activeクラスが付いたら表示 */
}

.modal-content {
    position: relative;
    width: 90vw; /* 画面幅の90%まで */
    height: 100%; /* 親要素(overlay)の高さいっぱいに広げる */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px 20px 110px; /* 下部の余白を110pxに広げる */
    box-sizing: border-box; /* paddingを含めて高さを計算 */
}

.modal-image-container {
    display: flex;
    gap: 20px;
    width: 100%;
    height: 100%; /* 親要素(content)のpaddingを引いた残りの領域いっぱいに広がる */
    justify-content: center;
    align-items: center;
    transition: opacity 0.2s ease-in-out; /* 画像切り替え時のフェードアニメーション */
}

.modal-image-wrapper {
    max-width: calc(50% - 10px); /* gapの半分を引いて、はみ出さないようにする */
    max-height: 100%;
}

.modal-image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain; /* 画像の縦横比を保ったままコンテナに収める */
}

.close-button {
    position: absolute;
    top: 10px;
    padding-top: env(safe-area-inset-top); /* Adjust for iOS notch */
    right: 20px;
    font-size: 40px;
    color: white;
    cursor: pointer;
}

/* --- モーダル内SNSシェアボタン --- */
.modal-social-share {
    position: absolute;
    top: 20px; /* 左上への配置調整 */
    padding-top: env(safe-area-inset-top); /* Adjust for iOS notch */
    left: 20px;
}

.modal-social-share a {
    display: inline-block; /* クリック範囲をアイコンのサイズに合わせる */
}

.modal-social-share img {
    width: 32px; /* ロゴサイズ */
    height: 32px;
    opacity: 0.7; /* 通常時の透明度 */
    transition: opacity 0.2s ease;
}

.modal-social-share a:hover img {
    opacity: 1; /* ホバー時に不透明にする */
}

/* --- モーダル内ナビゲーション矢印 --- */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 48px;
    font-weight: bold;
    color: white;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    user-select: none; /* テキスト選択を無効化 */
    transition: background-color 0.2s ease;
    z-index: 1010; /* 画像より手前に表示 */
    line-height: 1;
}

.modal-nav:hover {
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-nav.prev { left: 15px; }
.modal-nav.next { right: 15px; }

/* --- スマートフォン向けのスタイル (ギャラリーページ) --- */
@media (max-width: 768px) {
    .gallery-container {
        gap: 10px;
        padding: 10px;
    }

    .illust-wrapper {
        /* 画面幅に応じてサイズが変わるように調整 */
        /* 2列表示にする場合 (gapを考慮) */
        width: calc(50% - 25px);
        height: auto;
        aspect-ratio: 1 / 1; /* 幅と高さを同じにする */
    }

    .modal-image-container {
        flex-direction: column; /* スマートフォンでは画像を縦に並べる */
        gap: 10px; /* 画像間の余白 */
        /* position関連の指定は不要になるため削除 */
    }

    .modal-image-wrapper {
        max-width: 90%; /* 縦並びなので横幅は広く取る */
        max-height: calc(50% - 5px); /* コンテナの高さの半分からgap分を引いて、はみ出さないようにする */
    }

    .modal-social-share {
        /* ブラウザのメニューバーに隠れないように、セーフエリアを考慮した位置調整 */
        bottom: calc(15px + env(safe-area-inset-bottom));
        right: 15px;
    }

    .modal-nav {
        font-size: 32px;
        padding: 8px;
        background-color: rgba(0, 0, 0, 0.3); /* スマホでも背景を表示して視認性を確保 */
    }
}