/* 全体コンテナ */
.rk-amazon-container {
    container-type: inline-size;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 20px auto !important;
    padding: 0 !important; /* 外枠の余白を完全にゼロにする */
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    font-family: sans-serif;
    box-sizing: border-box;
    overflow: hidden; /* 角丸からはみ出さないように */
}

.rk-amazon-container * { box-sizing: border-box; }

/* ダイナミックグリッドシステム */
.rk-ad-dynamic-grid {
    display: grid !important;
    gap: 0 !important; /* グリッド間の隙間をゼロにする（セル側で調整） */
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.rk-ad-grid-cell {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: stretch !important; /* 横に引き伸ばす */
    text-align: center !important;
    width: 100% !important;
    padding: 15px; /* ここで内側の余白を確保 */
}

/* 共通パーツスタイル */
.rk-ad-header { width: 100%; margin-bottom: 10px; display: flex; justify-content: center; }
.rk-ad-title-div { 
    line-height: 1.4; 
    text-align: left !important; 
    display: block; 
    width: 100%; 
    font-weight: bold;
    min-height: 3.5em;
}
.rk-ad-image-box { 
    width: 100% !important; 
    margin-bottom: 10px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    min-height: 100px; 
}
.rk-ad-image-box img { 
    height: auto; 
    object-fit: contain; 
}

/* 説明文・スペック表の共通調整: 枠は中央、中身は左寄せ */
.rk-ad-description,
.rk-ad-features {
    display: inline-block;
    width: auto;
    max-width: 100%;
    margin: 10px auto;
    text-align: left !important; /* 文字は左寄せ */
    line-height: 1.6;
    align-self: center; /* stretchされているセル内でも中央に配置 */
}

.rk-ad-features { 
    padding: 0; 
    list-style: none; 
}
.rk-ad-feature-item { 
    display: grid; 
    grid-template-columns: auto 1fr; /* 項目名に合わせて自動調整 */
    gap: 15px;
    padding: 8px 0; 
    border-bottom: 1px dotted #ddd; 
    align-items: start;
}
.rk-ad-feature-label { font-weight: bold; opacity: 0.8; white-space: nowrap; }
.rk-ad-feature-value { text-align: left !important; word-break: break-all; }

/* 価格表示エリアを横いっぱいに */
.rk-ad-price-box { 
    width: 100% !important;
    text-align: center; 
    padding: 15px !important; 
    background: #fffafa; 
    border-radius: 0; /* 端まで広げるため角丸なし */
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 10px 0;
}
.rk-ad-price-label { font-size: 12px; font-weight: bold; opacity: 0.7; }
.rk-ad-price-value { display: block; line-height: 1.1; margin-top: 2px; }
.rk-ad-timestamp { display: block; font-size: 9px; color: #999; margin-top: 4px; }

/* ボタン周辺スタイル */
.rk-ad-button-box { 
    width: 100% !important; 
    text-align: center; 
    padding: 10px 0 !important; 
}
.rk-ad-button-msg { font-size: 11px; color: #e67e22; font-weight: bold; margin-bottom: 8px; }
.rk-ad-button-inner-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100% !important;
}
.rk-ad-pr-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    border: 1px solid #ccc;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    color: #888;
    background: #f9f9f9;
    flex-shrink: 0;
}
.rk-ad-btn-amazon {
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    width: 100% !important;
    border-radius: 10px;
    background: linear-gradient(to bottom, #f7dfa1 0%, #f0c14b 100%) !important;
    color: #111 !important;
    border: 1px solid #a88734 !important;
    font-weight: 900;
    text-decoration: none !important;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    transition: all 0.1s;
    padding: 12px 15px !important;
    min-height: 44px !important;
    white-space: normal;
    text-align: center;
    word-break: break-all;
}

/* コンテナクエリによる自動調整 */
@container (max-width: 340px) {
    .rk-ad-grid-cell { padding: 10px; }
    .rk-ad-title-div { font-size: 0.85em !important; min-height: 3.5em; }
    .rk-ad-button-inner-wrap {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .rk-ad-btn-amazon {
        font-size: clamp(9px, 4.5cqi, 13px);
        padding: 6px 4px !important;
        min-height: 32px !important;
        word-break: keep-all;
        overflow-wrap: anywhere;
    }
    .rk-ad-price-box { min-height: 60px; padding: 10px !important; }
    .rk-ad-price-value { font-size: 1.1em !important; }
}

@container (max-width: 220px) {
    .rk-ad-button-msg { display: none; }
    .rk-ad-btn-amazon { font-size: clamp(8px, 5cqi, 11px); }
    .rk-ad-pr-circle {
        width: 22px !important;
        height: 22px !important;
        font-size: 7px;
    }
}

@media (max-width: 600px) {
    .rk-ad-dynamic-grid { 
        grid-template-columns: 1fr !important; 
        display: block !important;
    }
    .rk-ad-grid-cell { width: 100% !important; margin-bottom: 15px; }
}

.rk-ad-note { font-size: 10px; color: #999; margin-top: 10px; text-align: center; }
