/* 共通スタイル。画面幅別の指定は後方にまとめる。
   同じセレクタが残る箇所は、他の指定との優先順を保つために分けている。 */
/* ページ全体 */
body {
    font-family: sans-serif;
    color: #222;
    background: #fafafa;
    margin: 0;
}

/* 検索フォーム */
form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: white;
    border: 1px solid #ccc;
}

/* 選択部分だけ横幅100% */
fieldset {
    flex-basis: 100%;
}

/* 選択部分だけ横幅100% */
fieldset label {
    display: inline-block;
    margin: 8px;
}

/* 検索窓、選択欄、ボタン全部に共通設定 */
input,
select,
button {
    font: inherit;
    padding: 8px;
}

/* 検索ボタンにマウスを乗せた時、カーソルを指の形に */
button {
    cursor: pointer;
}

/* エラー文用。文字を赤系、背景を薄い赤 */
.error {
    color: #9b2020;
    background: #fff0f0;
    padding: 12px;
}

/* ページ全体を崩さずに表部分だけ横スクロール */
.table-wrap {
    overflow-x: auto;
}

/* 表の横幅・セル同士の枠線・表の背景*/
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

/* 表の見出しとデータ部分 */
th,
td {
    text-align: left;
    padding: 12px;
    border: 1px solid #ccc;
}

/* 長い文字列を途中で折り返す */
td {
    overflow-wrap: anywhere;
}

/* 商品ページURLの横幅を制限 */
td:last-child {
    max-width: 240px;
}

/* 商品画像を枠の中に収める */
img {
    object-fit: contain;
}

/* 価格を途中で改行させない */
.price {
    white-space: nowrap;
}

/* ページ指定ボタン */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
}

.pagination a {
    padding: 8px 12px;
}

/* URLリンク用 */
.product-link {
    text-decoration: none;
}

/* リンクホバー時の挙動 */
.product-link:hover {
    text-decoration: underline;
}

/* ページジャンプ用 */
.page-jump-inline {
    display: inline;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}

/* Chrome・Edge・Safariの上下矢印を消す */
.page-jump-input::-webkit-outer-spin-button,
.page-jump-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Firefoxの上下矢印を消す */
.page-jump-input {
    width: 32px;
    height: 28px;
    padding: 0;
    margin: 0;
    text-align: center;
    font-size: 1rem;
    border: 1px solid #aaa;
    border-radius: 3px;
    -moz-appearance: textfield;
    appearance: textfield;
}

/* サイト別比較の全体 */
.compare-grid {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding-bottom: 8px;
}

/* サイトごとの列 */
.compare-column {
    flex: 0 0 320px;
    min-width: 0;
}

/* 各商品 */
.compare-item {
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid #ccc;
}

/* 比較表示の商品名 */
.compare-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    overflow: hidden;
    line-height: 1.5;
    min-height: 3em;
    overflow-wrap: anywhere;
}

/* サイト別比較の価格を目立たせる */
.compare-item .price {
    font-size: 1.4rem;
    font-weight: bold;
    margin: 12px 0;
}

/* 評価の☆ */
.rating-row {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* 評価の☆ */
.star-rating {
    position: relative;
    display: inline-block;
    color: #ccc;
}

/* 評価の☆ */
.star-rating::before {
    content: "★★★★★";
    position: absolute;
    left: 0;
    top: 0;
    width: var(--rating-percent);
    overflow: hidden;
    color: #f4b400;
    white-space: nowrap;
}

/* 閲覧履歴サイドバー */
.history-sidebar {
    position: fixed;
    top: 0;
    right: -360px;
    width: 320px;
    height: 100vh;
    background: white;
    border-left: 1px solid #ccc;
    padding: 20px;
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
    box-sizing: border-box;
    overscroll-behavior: contain;
}

/* 閲覧履歴サイドバーを開いた状態 */
.history-sidebar.open {
    right: 0;
}

/* サイドバー表示中の背景 */
.history-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    display: none;
    z-index: 999;
}

.history-overlay.open {
    display: block;
}

/* 閲覧履歴の商品1件 */
.history-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid #ccc;
    position: relative;
}

/* 閲覧履歴の商品名 */
.history-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    line-height: 1.5;
    margin: 0;
    overflow-wrap: anywhere;
}

/* 商品情報側は残りの横幅を全部使う */
.history-info {
    flex: 1;
    min-width: 0;
}

/* 価格・サイト名・削除ボタン */
.history-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
    row-gap: 4px;
    align-items: center;
    width: 100%;
}

/* 価格 */
.history-meta p {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
}

/* サイト名 */
.history-meta a {
    white-space: nowrap;
    grid-column: 1;
    grid-row: 2;
    font-size: 14px;
}

/* 個別削除ボタン */
.history-meta .favorite-delete-button {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    font-size: 11px;
    padding: 2px 5px;
    white-space: nowrap;
}

/* 同一商品を横並びにする */
.same-product-group {
    margin-bottom: 32px;
}

/* 型番などの見出しは1行全部使う */
.same-product-group h3 {
    flex: 0 0 100%;
    grid-column: 1 / -1;
}

/* 最安値ラベル */
.lowest-price-label {
    display: block;
    position: absolute;
    top: 0;
    left: 16px;
    width: fit-content;
    margin: 0;
    padding: 0 8px;
    border: none;
    border-radius: 0;
    font-weight: bold;
    z-index: 2;
}

/* 検索ボタン */
.main-search-button {
    font-size: 16px;
}

/* 検索サイト選択タブ */
.site-select-details {
    position: relative;
    display: inline-block;
}

/* 「検索サイトを選ぶ」ボタン部分 */
.site-select-details summary {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #999;
    border-radius: 6px;
    background-color: white;
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.site-select-details summary::-webkit-details-marker {
    display: none;
}

/* 閉じている時の矢印 */
.site-select-details summary::after {
    content: " ▼";
    font-size: 12px;
}

/* 開いている時の矢印 */
.site-select-details[open] summary::after {
    content: " ▲";
}

/* 開いた時に表示するサイト一覧 */
.site-select-options {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 260px;
    padding: 10px 12px;
    background-color: white;
    border: 1px solid #bbb;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

/* サイトを縦に並べる */
.site-select-options label {
    display: block;
    padding: 6px 4px;
    cursor: pointer;
    white-space: nowrap;
}

/* 絞り込みと検索結果の2カラム */
.content-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
    align-items: start;
    margin-top: 24px;
}

/* 左側の絞り込み */
.filter-sidebar {
    padding: 20px;
    border-right: 1px solid #ddd;
    position: sticky;
    top: 20px;
}

/* 絞り込みタイトル */
.filter-sidebar h2 {
    margin-top: 0;
}

/* 右側の検索結果 */
.result-area {
    min-width: 0;
}

/* ページ全体を画面幅いっぱいに使う */
main {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 24px 32px;
    box-sizing: border-box;
}

/* 最低価格と最高価格 */
.price-range-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

/* ～ と最高価格をセットにする */
.price-max-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 入力欄本体 */
.price-input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid #999;
    background-color: white;
    padding: 0 8px;
    height: 48px;
    box-sizing: border-box;
}

/* 数字を入力する部分 */
.price-input-wrap input {
    width: 5ch;
    border: none;
    outline: none;
    margin: 0;
    font: inherit;
    background: transparent;
}

/* ～ */
.price-separator {
    white-space: nowrap;
}

/* 数値入力の上下矢印を消す */
.price-input-wrap input[type="number"]::-webkit-outer-spin-button,
.price-input-wrap input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.price-input-wrap input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

/* 絞り込み実行ボタン */
.filter-submit-button {
    width: 100%;
    height: 44px;
    margin-top: 20px;
    cursor: pointer;
    font-size: 16px;
}

/* 絞り込み専用フォームは、検索フォームの見た目を引き継がない */
#filter-form {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    box-sizing: border-box;
}

/* 除外キーワードはサイドバー内に収める */
#filter-form #exclude_keywords {
    width: 100%;
    box-sizing: border-box;
}

/* 商品検索の1段目 */
.search-main-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

/* 商品検索欄を広くする */
.search-main-row input[type="search"] {
    flex: 1;
    min-width: 400px;
    max-width: 1100px;
    height: 48px;
    padding: 0 14px;
    font-size: 16px;
    box-sizing: border-box;
}

/* 検索ボタン */
.search-main-row .main-search-button {
    height: 48px;
    padding: 0 26px;
    font-size: 16px;
}

/* =========================
表示設定
========================= */
.search-option-row {
    width: 100%;
}

/* サイトロゴ＋サイト名 */
.site-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

/* 検索ボタン */
.main-search-button {
    width: 58px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

/* SVGが切れないようにする */
.main-search-button svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    display: block;
    flex-shrink: 0;
    overflow: visible;
}

/* ラベル */
.search-option-item label {
    white-space: nowrap;
    font-size: 14px;
    font-weight: 700;
    color: #444;
    margin-left: 4px;
}

/* セレクトボックス */
.search-option-item select {
    min-width: 180px;
    height: 46px;
    padding: 0 14px;
    font-size: 16px;
    border: 1px solid #cfcfcf;
    border-radius: 12px;
    background: #fafafa;
    cursor: pointer;
}

/* フォーカス時 */
.search-option-item select:focus {
    outline: none;
    border-color: #666;
}

/* 表示設定の行 */
.search-option-row {
    display: flex;
    align-items: flex-end;
    gap: 22px;
}

/* 「表示方法」など、文字と選択欄の間 */
.search-option-item {
    white-space: nowrap;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

/* 閲覧履歴・お気に入りも少し余裕を持たせる */
.top-option-button {
    font-size: 16px;
    white-space: nowrap;
    padding-left: 18px;
    padding-right: 18px;
}

/* 右側も左から続けて配置 */
.display-settings-block {
    flex: 0 1 auto;
}

/* 表示設定の余計な余白をなくす */
.search-option-row {
    margin-top: 0;
}

/* 検索窓 */
.keyword-search-box input {
    flex: 1;
    min-width: 0;
    border-right: none;
    border-radius: 0;
    box-sizing: border-box;
}

/* 検索欄と下の設定欄の距離を詰める */
.search-main-row {
    margin-bottom: 8px;
}

/* 検索サイトと表示設定を横並び */
.search-settings-row {
    display: flex;
    align-items: center;
    gap: 24px;
    width: 100%;
    margin-top: 0;
}

/* サイト名一覧 */
.selected-sites {
    border-radius: 6px;
    box-sizing: border-box;
    min-height: 28px;
}

/* 枠タイトル */
.selected-sites-fieldset legend {
    font-size: 16px;
    padding: 0 8px;
    font-weight: bold;
}

/* 検索サイト側は必要な幅だけ使う */
.site-settings-block {
    flex: 0 0 auto;
    width: auto;
}

/* 選択中サイトの枠とボタンを横並び */
.selected-sites-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: nowrap;
}

/* 選択中サイトの枠 */
.selected-sites-fieldset {
    border: 1px solid #bdbdbd;
    border-radius: 8px;
    width: auto;
    min-width: 520px;
    margin: 0;
    padding: 12px 16px 14px;
    box-sizing: border-box;
}

/* サイト名部分 */
.selected-sites {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    width: auto;
    min-width: 0;
    padding: 0;
    border: none;
    background: transparent;
}

/* 検索サイト選択ボタンは縮ませない */
.site-select-details {
    flex: 0 0 auto;
}

/* 価格入力欄が小さくなりすぎないようにする */
.price-input-wrap input {
    min-width: 105px;
    height: 48px;
    padding: 0 10px;
    box-sizing: border-box;
}

/* 絞り込み項目の縦間隔を統一 */
#exclude_keywords {
    margin-bottom: 16px;
}

.filter-price {
    margin-bottom: 16px;
}

/* 検索窓＋検索ボタン全体の枠 */
.keyword-search-box {
    display: flex;
    flex: 1;
    min-width: 0;
    border: 1px solid #777;
    box-sizing: border-box;
}

/* 商品検索入力欄 */
.keyword-search-box input[type="search"] {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    box-sizing: border-box;
}

/* 検索ボタン */
.keyword-search-box .main-search-button {
    border-radius: 0;
    width: 58px;
    flex: 0 0 58px;
    margin: 0;
    border: none;
    border-left: 1px solid #777;
    box-sizing: border-box;
}

/* 上部広告エリア */
.top-ad-area {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* 仮表示 */
.top-ad-area span {
    color: #999;
    font-size: 14px;
}

/* 上部の楽天バナーを少し大きく表示 */
.top-ad-area img {
    display: block;
    width: 520px;
    max-width: 90vw;
    height: auto;
}

/* サイドバー下の広告 */
.sidebar-ad-area {
    margin-top: 28px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    box-sizing: border-box;
    transform: translateX(-3px);
}

/* 広告画像がサイドバーからはみ出さないようにする */
.sidebar-ad-area img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* 広告画像がはみ出さないようにする */
.result-ad-area img {
    display: block;
    max-width: 100%;
    height: auto;
}

.result-ad-area {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 32px;
    box-sizing: border-box;
    margin-top: 60px;
}

/* フッターのサービス表記を中央寄せ */
footer {
    font-size: 0.85rem;
    width: 100%;
    text-align: center;
    margin-top: 30px;
}

/* 検索後のページ下広告 */
.bottom-ad-area {
    width: 100%;
    margin: 36px auto 30px;
    text-align: center;
    box-sizing: border-box;
}

/* 広告本体を中央へ */
.bottom-ad-area > * {
    margin-left: auto !important;
    margin-right: auto !important;
}

.bottom-ad-area img {
    display: block;
    max-width: 100%;
    height: auto;
}

.top-option-button {
    width: 75px;
    height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 3px 6px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

/* 上側のアイコン */
.top-option-icon {
    font-size: 22px;
    line-height: 1;
}

/* お気に入りの星 */
.favorite-icon {
    color: #e0a800;
}

/* 下側の文字 */
.top-option-label {
    font-size: 12px;
    white-space: nowrap;
}

/* マウスを乗せた時 */
.top-option-button:hover {
    background: #f5f5f5;
    border-color: #999;
}

/* 商品カード上段 */
.compare-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

/* 商品画像 */
.compare-image img {
    display: block;
    object-fit: contain;
}

/* お気に入りとショップ */
.compare-top-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

/* ショップ名 */
.compare-shop {
    margin: 0;
    font-size: 14px;
    text-align: right;
}

/* 商品名 */
.compare-title {
    margin: 16px 0;
}

/* 価格と送料 */
.compare-price-row {
    display: flex;
    align-items: baseline;
    gap: 18px;
}

/* 価格を少し大きく */
.compare-price {
    margin: 0;
    font-size: 26px;
    font-weight: bold;
}

/* 送料は価格より小さく */
.compare-postage {
    margin: 0;
    font-size: 14px;
}

/* 評価は価格の下 */
.compare-rating {
    margin-top: 8px;
}

/* 最下段 */
.compare-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
}

/* ポイント */
.compare-point {
    margin: 0;
}

/* 商品名リンク */
.compare-title-link {
    color: #0000ee;
    text-decoration: underline;
}

/* 一度開いた商品も青のまま */
.compare-title-link:visited {
    color: #7b00ee;
}

/* カーソルを合わせた時 */
.compare-title-link:hover {
    color: #0000bb;
}

/* 最安値ラベル */
.lowest-price-label {
    color: #b88600;
    background: #fafafa;
}

/* 同一商品比較のサイト名 */
.same-product-site {
    margin: 0;
    font-size: 14px;
    text-align: right;
}

/* 通常の商品カード */
.same-product-item {
    position: relative;
    border: 1px solid #ccc;
    padding: 16px;
    border-radius: 8px;
}

/* 最安値の商品だけ金色 */
.same-product-item.lowest-item {
    border: 2px solid #e0a800;
}

/* 同一商品を横並びにする */
.same-product-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: stretch;
}

/* 同一商品比較：1列に3枚並べる */
.same-product-wrapper {
    flex: 0 0 calc((100% - 32px) / 3);
    max-width: calc((100% - 32px) / 3);
    min-width: 0;
    position: relative;
    padding-top: 12px;
    box-sizing: border-box;
}

/* 同一商品グループの見出し */
.same-product-group > h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 100%;
}

/* 商品件数の右側に区切り線 */
.same-product-group > h3::after {
    content: "";
    flex: 1;
    height: 2px;
    background: #ddd;
}

/* 通常一覧：画像列 */
.table-wrap th:nth-child(1),
.table-wrap td:nth-child(1) {
    width: 140px;
    text-align: center;
    vertical-align: middle;
}

/* 通常一覧：商品名列 */
.table-wrap th:nth-child(2),
.table-wrap td:nth-child(2) {
    width: 42%;
    text-align: center;
    vertical-align: middle;
}

/* 通常一覧：見出しをコンパクトにする */
.table-wrap th {
    padding: 8px 10px;
    font-size: 15px;
    line-height: 1.2;
    vertical-align: middle;
}

/* ショップ・サイト / お気に入り は1行にする */
.table-wrap th:nth-child(4),
.table-wrap th:nth-child(5) {
    white-space: nowrap;
}

/* 検索結果件数と表示件数を横並び */
.result-heading-row {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 20px;
}

/* 検索結果の見出し */
.result-heading-row h2 {
    margin: 0;
}

/* 表示件数だけコンパクトなデザイン */
.result-limit-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #555;
}

/* 表示件数の選択欄 */
.result-limit-control select {
    height: 34px;
    min-width: 76px;
    padding: 0 8px;
    font-size: 14px;
    border: 1px solid #bbb;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
}

/* 検索設定の列全体を中央に寄せる */
.search-settings-row {
    justify-content: center;
}

/* 選択中のサイトの枠を少し上に調整 */
.selected-sites-fieldset {
    position: relative;
    top: -4px;
}

/* コムパロのロゴ */
.site-brand-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

/* 横長ロゴ画像 */
.site-brand-logo {
    width: 210px;
    height: auto;
    display: block;
}

/* お気に入りボタン */
.favorite-button {
    font-size: 13px;
    padding: 5px 10px;
    color: #333;
    background: #f3f3f3;
    border: 1px solid #bbb;
    border-radius: 7px;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    cursor: pointer;
}

/* カーソルを乗せた時 */
.favorite-button:hover {
    background: #e9e9e9;
    border-color: #999;
}

/* 押した時 */
.favorite-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* 通常一覧のお気に入りボタンだけ1行表示 */
.table-wrap td:nth-child(5) .favorite-button {
    white-space: nowrap;
    font-size: 13px;
    padding: 5px 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 通常一覧：画像下のお気に入り */
.list-favorite-button {
    display: block;
    margin: 8px auto 0;
    font-size: 13px;
    padding: 5px 8px;
    white-space: nowrap;
}

/* 絞り込み見出し + リセットボタン */
.filter-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-bottom: 16px;
}

.filter-header h2 {
    margin: 0;
}

.filter-reset-form {
    display: block;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
}

.filter-reset-btn {
    padding: 4px 9px;
    font-size: 12px;
    background-color: #f5f5f5;
    color: #222;
    font-weight: 600;
    border: 1px solid #cfcfcf80;
    border-radius: 7px;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    top: 2px;
}

.filter-reset-btn:hover {
    background-color: #ebebeb;
}

/* 表示方法・並び順・検索精度を1列にする */
.search-option-row {
    flex-wrap: nowrap;
}

/* 検索精度は短いので少しコンパクトにする */
#search_mode {
    min-width: 85px;
    width: 85px;
}

/* 表示方法を少しコンパクトにする */
#display_mode {
    min-width: 150px;
    width: 150px;
}

/* 送料・ポイントの絞り込み */
.filter-extra-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 18px;
}

/* 絞り込み用チェックボックス */
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* スマホ用の絞り込みタブ
PCでは表示しない */
.mobile-filter-toggle {
    display: none;
}

.filter-checkbox input {
    margin: 0;
}

/* PCでは今までと同じ並びにする */
.same-product-scroll {
    display: contents;
}

/* 通常はPC広告を表示 */
.bottom-ad-pc {
    display: block;
}

.bottom-ad-mobile {
    display: none;
}

/* =========================
タブレット・少し狭いPC
========================= */
@media (max-width: 1450px) {
    /* 検索サイトと表示設定を必要に応じて折り返す */
    .search-settings-row {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 16px;
    }

    /* 検索サイト側は1行分使う */
    .site-settings-block {
        width: 100%;
        flex: 1 1 100%;
    }

    /* 選択中サイトとボタン */
    .selected-sites-row {
        width: 100%;
        flex-wrap: wrap;
    }

    /* 520px固定を解除して縮められるようにする */
    .selected-sites-fieldset {
        flex: 1 1 520px;
        min-width: 0;
    }

    /* 表示方法・並び順・検索精度も1行分使う */
    .display-settings-block {
        width: 100%;
        flex: 1 1 100%;
    }

    /* 幅が足りなければ自然に折り返す */
    .search-option-row {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
}

/* =========================
画面幅が狭い時の調整
========================= */
@media (max-width: 900px) {
    /* ページ左右の余白を縮める */
    main {
        padding: 16px;
    }

    /* 900px以下ではページ全体を横スクロールさせない */
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* 上段を折り返せるようにする */
    .search-main-row {
        flex-wrap: wrap;
    }

    /* ロゴ */
    .site-brand-logo {
        width: 180px;
    }

    /* 検索サイト・表示設定を縦方向へ */
    .search-settings-row {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    /* サイト枠とボタンを折り返す */
    .selected-sites-row {
        flex-wrap: wrap;
    }

    /* 表示方法・並び順・検索精度も折り返す */
    .search-option-row {
        flex-wrap: wrap;
    }

    /* 左の絞り込みと右の結果を1列にする */
    .content-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* サイト別比較の商品部分だけ横スクロール */
    .compare-grid {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* スマホでは絞り込みを固定しない */
    .filter-sidebar {
        position: static;
        top: auto;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }

    /* 上部広告は狭い画面では縦に並べる */
    .top-ad-area {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* 広告1枚で1行使う */
    .top-ad-area > a {
        flex: 0 0 100%;
        max-width: 100%;
        display: flex;
        justify-content: center;
    }

    /* 広告を画面幅からはみ出させない */
    .top-ad-area img {
        width: auto;
        max-width: 100%;
        height: auto;
    }

    /* 狭い画面では絞り込みタブを表示 */
    .mobile-filter-toggle {
        display: block;
        width: 100%;
        margin: 12px 0 16px;
        padding: 12px 16px;
        text-align: left;
        font-size: 16px;
        font-weight: 700;
        background: #fff;
        border: 1px solid #ccc;
        border-radius: 6px;
        cursor: pointer;
    }

    /* 最初は絞り込み本体を閉じておく */
    .filter-sidebar {
        display: none;
    }

    /* タブを押した時だけ表示 */
    .filter-sidebar.mobile-open {
        display: block;
    }

    /* 上段をグリッド配置にする */
    .search-main-row {
        display: grid;
        grid-template-columns: auto auto;
        justify-content: center;
        gap: 12px 16px;
    }

    /* ロゴは中央で1行使う */
    .site-brand {
        grid-column: 1 / -1;
        width: 100%;
        justify-content: center;
    }

    /* 検索窓も1行全部使う */
    .keyword-search-box {
        flex: 1 1 100%;
        grid-column: 1 / -1;
        width: 100%;
    }

    /* 閲覧履歴・お気に入りを中央に2個並べる */
    #history-open-button {
        justify-self: end;
    }

    #favorite-open-button {
        justify-self: start;
    }

    /* 選択中サイト＋検索サイトボタン */
    .selected-sites-row {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    /* 選択中サイトは横幅いっぱい */
    .selected-sites-fieldset {
        min-width: 0;
        flex: 0 0 auto;
        height: auto;
        width: 100%;
    }

    /* 検索サイトを選ぶボタンは中央 */
    .site-select-details {
        align-self: center;
        margin-bottom: 18px;
    }

    /* 表示方法・並び順・検索精度を縦に並べる */
    .search-option-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    /* 各設定を1行ずつ使う */
    .search-option-item {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        padding-left: 18px;
        box-sizing: border-box;
    }

    /* ラベル幅を揃える */
    .search-option-item label {
        width: 72px;
        margin-left: 0;
    }

    /* 900px以下では設定タブの横幅を揃える */
    #display_mode,
    #sort,
    #search_mode {
        width: 225px;
        min-width: 225px;
    }

    /* 商品一覧をスマホでは2列表示にする */
    .table-wrap thead {
        display: none;
    }

    .table-wrap table,
    .table-wrap tbody {
        display: block;
        width: 100%;
    }

    /* 商品一覧をスマホ用の配置にする */
    .table-wrap tbody tr {
        display: grid;
        grid-template-columns: 160px minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        width: 100%;
        margin-bottom: 14px;
        box-shadow: 0 2px 7px rgba(0, 0, 0, 0.10);
    }

    .table-wrap tbody tr:last-child {
        margin-bottom: 0;
    }

    /* 画像：左上 */
    .table-wrap tbody td:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
    }

    /* 価格・送料・評価・ポイント：右上 */
    .table-wrap tbody td:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
    }

    /* 商品名：画像と価格の下を横いっぱい使う */
    .table-wrap tbody td:nth-child(2) {
        grid-column: 1 / -1;
        grid-row: 2;
        border-bottom: none;
    }

    /* ショップ・サイト：商品名の下を横いっぱい使う */
    .table-wrap tbody td:nth-child(4) {
        grid-column: 1 / -1;
        grid-row: 3;
        border-top: none;
    }

    /* PC用の列幅をスマホでは解除 */
    .table-wrap tbody td:nth-child(1),
    .table-wrap tbody td:nth-child(2),
    .table-wrap tbody td:nth-child(3),
    .table-wrap tbody td:nth-child(4) {
        width: auto;
        max-width: none;
        min-width: 0;
        box-sizing: border-box;
    }

    /* 商品一覧の商品名は2行まで表示 */
    .table-wrap tbody td:nth-child(2) .compare-title-link {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        overflow: hidden;
        line-height: 1.5;
        max-height: 3em;
        overflow-wrap: anywhere;
    }

    /* 商品一覧の価格情報を2列×2段にする */
    .table-wrap tbody td:nth-child(3) {
        display: grid;
        grid-template-columns: 140px minmax(0, 1fr);
        grid-template-areas: "price rating" "postage point";
        column-gap: 8px;
        row-gap: 8px;
        align-items: center;
        padding-left: 28px;
    }

    /* 価格と送料の親要素をGrid上では透明化 */
    .table-wrap tbody td:nth-child(3) .compare-price-row {
        display: contents;
    }

    /* 価格 */
    .table-wrap tbody td:nth-child(3) .compare-price {
        grid-area: price;
    }

    /* 送料 */
    .table-wrap tbody td:nth-child(3) .compare-postage {
        grid-area: postage;
        white-space: nowrap;
    }

    /* 評価 */
    .table-wrap tbody td:nth-child(3) .compare-rating {
        grid-area: rating;
        margin: 0;
    }

    /* ポイント */
    .table-wrap tbody td:nth-child(3) > p {
        grid-area: point;
        margin: 0;
    }

    /* 同一商品比較は商品カード部分だけ横スクロール */
    .same-product-scroll {
        display: flex;
        gap: 16px;
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }

    /* スマホ：次の商品が少し見える幅にする */
    .same-product-scroll .same-product-wrapper {
        flex: 0 0 min(330px, calc(100vw - 80px));
        max-width: min(330px, calc(100vw - 80px));
    }

    /* スマホでは注意書きを少しコンパクトにする */
    .display-note {
        font-size: 14px;
        line-height: 1.5;
        margin-top: 10px;
        margin-bottom: 14px;
    }

    /* 検索結果件数と表示件数をスマホでも1行にする */
    .result-heading-row {
        flex-wrap: nowrap;
        gap: 10px;
    }

    /* 「検索結果：全○○件」を改行させない */
    .result-heading-row h2 {
        white-space: nowrap;
        font-size: 20px;
        flex-shrink: 0;
    }

    /* 表示件数部分も改行させない */
    .result-limit-control {
        flex-shrink: 0;
        gap: 6px;
    }

    /* 「表示件数」を1行固定 */
    .result-limit-control label {
        white-space: nowrap;
        font-size: 13px;
    }

    /* 件数選択も少しコンパクトに */
    .result-limit-control select {
        min-width: 68px;
        padding: 0 6px;
        font-size: 13px;
    }
}

/* 各表示モードの注意書き */
.display-note {
    line-height: 1.6;
}

/* ページ送りの＜ ＞は通常時は下線なし */
.pagination .page-arrow {
    text-decoration: none;
}

/* ホバーした時だけ下線を表示 */
.pagination .page-arrow:hover {
    text-decoration: underline;
}

/* 閲覧履歴・お気に入りのヘッダー */
.history-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

/* タイトルと閉じるボタンを横並び */
.history-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* タイトルの余白を整理 */
.history-title-row h2 {
    margin: 0;
}

#history-close-button,
#favorite-close-button {
    flex: 0 0 auto;
    margin-left: auto;
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-family: Arial, sans-serif;
    line-height: 1;
    background: #f5f5f5;
    border: 1px solid #bbb;
    border-radius: 6px;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    cursor: pointer;
}

/* 押した時 */
#history-close-button:active,
#favorite-close-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

#history-clear-button,
#favorite-clear-button {
    align-self: flex-start;
    font-size: 13px;
    padding: 5px 9px;
}

/* 気になる一覧の商品ごとの削除ボタン */
.favorite-delete-button {
    font-size: 13px;
    padding: 5px 8px;
    background: #f5f5f5;
    border: 1px solid #bbb;
    border-radius: 5px;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    cursor: pointer;
}

.favorite-delete-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* =========================
スマホ：価格・評価まわりの最終調整
========================= */
@media (max-width: 900px) {
    /* 右上の価格情報エリア */
    .table-wrap tbody td:nth-child(3) {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        padding: 18px 14px;
        box-sizing: border-box;
        min-width: 0;
        overflow: hidden;
    }

    /* 価格と送料を縦に並べる */
    .table-wrap tbody td:nth-child(3) .compare-price-row {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        margin: 0;
        width: 100%;
    }

    /* 送料 */
    .table-wrap tbody td:nth-child(3) .compare-postage {
        margin: 0;
        font-size: 19px;
        line-height: 1.2;
        white-space: nowrap;
    }

    /* 評価・レビュー・ポイント部分 */
    .table-wrap tbody td:nth-child(3) .compare-bottom-row {
        display: block;
        width: 100%;
        margin: 0;
    }

    /* 評価部分 */
    .table-wrap tbody td:nth-child(3) .compare-rating-block {
        width: 100%;
        min-width: 0;
    }

    /* 星 + 評価数 */
    .table-wrap tbody td:nth-child(3) .compare-rating {
        display: flex;
        align-items: center;
        gap: 6px;
        margin: 0;
        white-space: nowrap;
        flex-wrap: nowrap;
    }

    /* 評価数 */
    .table-wrap tbody td:nth-child(3) .rating-value {
        font-size: 18px;
        white-space: nowrap;
    }

    /* レビュー件数 */
    .table-wrap tbody td:nth-child(3) .compare-review-count {
        margin: 2px 0 0;
        font-size: 16px;
        white-space: nowrap;
    }

    /* ポイント */
    .table-wrap tbody td:nth-child(3) .compare-point {
        margin: 7px 0 0;
        font-size: 17px;
        white-space: nowrap;
        text-align: left;
    }

    /* 価格 */
    .table-wrap tbody td:nth-child(3) .compare-price {
        margin: 0;
        font-size: 26px;
        font-weight: bold;
        white-space: nowrap;
        width: 100%;
        max-width: 100%;
    }

    /* 商品名 */
    .table-wrap tbody td:nth-child(2) {
        padding: 10px 14px 4px;
    }

    /* ショップ・サイト */
    .table-wrap tbody td:nth-child(4) {
        padding: 4px 14px 10px;
    }

    /* ショップ名・サイト名の標準余白を消す */
    .table-wrap tbody td:nth-child(4) p {
        margin: 0;
    }

    /* ショップ名とサイト名の間だけ少し空ける */
    .table-wrap tbody td:nth-child(4) p + p {
        margin-top: 8px;
    }
}

/* 普段は非表示 */
.search-loading {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.78);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

/* 検索中だけ表示 */
.search-loading.show {
    display: flex;
}

/* アイコンと文字のまとまり */
.search-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px 32px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 16px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15);
}

/* 検索中のコムパロ */
.search-loading-icon {
    width: 90px;
    height: 90px;
    object-fit: contain;
}

/* 「検索中...」 */
.search-loading-content p {
    margin: 0;
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

/* =========================
PC版 商品一覧
価格・評価・ポイントの配置
========================= */
@media (min-width: 901px) {
    /* 価格と送料を横並び */
    .table-wrap tbody td:nth-child(3) .compare-price-row {
        display: flex;
        align-items: baseline;
        gap: 16px;
        margin-bottom: 12px;
    }

    /* 評価部分とポイントを縦に並べる */
    .table-wrap tbody td:nth-child(3) .compare-bottom-row {
        display: block;
    }

    /* 星・評価数・レビュー件数を横並び */
    .table-wrap tbody td:nth-child(3) .compare-rating-block {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    /* 星と評価数 */
    .table-wrap tbody td:nth-child(3) .compare-rating {
        margin: 0;
        white-space: nowrap;
    }

    /* レビュー件数を評価の横へ */
    .table-wrap tbody td:nth-child(3) .compare-review-count {
        margin: 0;
        white-space: nowrap;
    }

    /* ポイントは次の行 */
    .table-wrap tbody td:nth-child(3) .compare-point {
        margin: 10px 0 0;
        white-space: nowrap;
        text-align: left;
    }
}

/* =========================
上部広告の背景ライン
========================= */
.top-ad-area {
    position: relative;
    background: linear-gradient( to bottom, #f7f7f7 0%, #ececec 50%, #f7f7f7 100% );
    border-top: 1px solid #d9d9d9;
    border-bottom: 1px solid #d9d9d9;
    min-height: 0;
    padding: 6px 0;
    margin-bottom: 8px;
}
