/* メインコンテンツの重なり順を調整 */
#ILLUST_SEARCH {
    position: relative;
    z-index: 1; /* メニューが上に表示されるように設定 */
}

/* 検索条件欄 */
.search-container {
    border: 1px solid white;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.search-container h3.search-toggle {
    background-color: rgba(255, 255, 255, 0.5);
    padding: 10px;
    margin: -15px -15px 15px -15px; /* 上下左右のpaddingを打ち消し、下にマージン */
    cursor: pointer;
    border-bottom: 1px solid #ccc;
}

.search-container h3.search-toggle.closed {
    margin-bottom: -15px; /* コンテナのpadding-bottomを相殺 */
    border-bottom: none;
}

.search-container .form-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.search-container input[type="date"],
.search-container select {
    padding: 4px 6px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* 項目名（src_titleクラスを持つラベル）のスタイル */
.search-container .form-group .src_title {
    flex-shrink: 0; /* ラベルが縮まないようにする */
    font-weight: bold;
    color: #ff7f50; /* 項目名の文字色 */
    width: 120px;
}

/* 項目名以外のラベル（ラジオボタンなど）のスタイル */
.search-container .form-group label:not(.src_title) {
    font-weight: normal;
    color: white;
}

.search-container .form-group span,
.search-container h3 {
    color: white;
}

/* キャラ選択UI */
#selected-charas-display {
    /* 背景色と枠線をなくす */
    background-color: transparent;
    border: none;
    padding: 0;
    vertical-align: middle;
    line-height: normal;
}

#open-chara-modal-btn {
    vertical-align: middle;
    background-color: #e0e0e0;
    border: 1px solid #aaa;
    border-radius: 3px;
    padding: 3px 11px;
    font-size: inherit;
    cursor: pointer;
    color: black;
}

/* キャラ選択モーダル */
#chara-modal-overlay {
    display: none; /* JSで制御 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#chara-modal-content {
    background-color: white;
    color: black;
    padding: 20px 30px;
    border-radius: 8px;
    max-height: 80vh;
    width: 90%;
    max-width: 900px; /* 横幅を広げて5列表示しやすくする */
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

#chara-checkbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.modal-buttons {
    position: sticky;
    bottom: -20px; /* 親要素のpadding-bottomを打ち消す */
    /* 親要素の左右paddingを打ち消し、上下マージンを設定 */
    margin: 20px -30px -20px;
    padding: 15px 30px;
    background-color: rgba(255, 255, 255, 0.95); /* 半透明の白 */
    border-top: 1px solid #ddd;
    text-align: right;
}

/* ポップアップ用 */
#popup-overlay {
    display: none; /* JSで制御 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

#popup-content {
    position: relative;
    width: 100%;
    max-width: 90vw;
    max-height: 90vh; /* 画面内に収まるように */
    display: flex;
    flex-direction: column;
    background-color: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.popup-main-content {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    flex: 1;
    overflow: hidden; /* はみ出し防止 */
    min-height: 0; /* flexアイテムのはみ出し防止 */
}

#popup-image {
    flex: 1; /* 残りのスペースを埋める */
    min-width: 0; /* flexアイテムのはみ出し防止 */
    max-height: 100%;
    object-fit: contain;
}

#popup-comment {
    margin: 0;
    color: black;
    text-align: left;
    line-height: 1.7;
    flex: 0 0 320px; /* 幅を320pxに固定 */
    overflow-y: auto; /* コメントが長い場合にスクロール */
    padding-right: 10px;
}

/* 検索ボタン */
.search-container button[type="submit"] {
    width: 100%;
    font-size: 16px;
    padding: 10px;
    margin-top: 10px;
    cursor: pointer;
    background-color: #f60;
    border: none;
    border-radius: 3px;
    color: white;
    font-weight: bold;
}

#popup-close {
    align-self: flex-end;
    padding: 8px 16px;
}

/* 検索結果サムネイル */
.thumbnail-grid {
    display: grid;
    /* 画面幅に応じて列数を自動調整。各列の最小幅は150px */
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    margin: 5px 0;
    gap: 15px; /* サムネイル間の隙間 */
}

.thumbnail-grid .thumbnail-link {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #ddd;
    background-color: #fff;
    padding: 2px; /* 中余白を減らす */
    aspect-ratio: 1 / 1;
    overflow: hidden;
    transition: padding 0.2s ease-in-out; /* アニメーション */
}

.thumbnail-grid .thumbnail-link:hover {
    padding: 0; /* ホバー時に余白をなくす */
}

.thumbnail-grid .thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover; /* アスペクト比を維持してコンテナいっぱいに表示 */
}

.pagination {
    margin-top: 5px;
}

/* Skebリンク */
.skeb-link {
    display: inline-block;
    color: #ffffff !important;
    background-color: #30b396;
    padding: 4px 10px;
    margin: 4px 0;
    text-decoration: none;
    border-radius: 4px;
}
