/* 全体のスタイル */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    background-color: #f8f9fa;
    color: #212529;
    margin: 0;
    padding: 20px;
}

/* モーダルが開いている間、背景のスクロールを禁止 */
body.modal-open {
    overflow: hidden;
}

h1 {
    text-align: center;
    color: #343a40;
    margin-bottom: 40px;
}

/* コンテナ */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ボタンコントロール */
.controls {
    text-align: center;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.control-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.control-btn:hover {
    background-color: #5a6268;
}

.control-btn.active {
    background-color: #007bff;
}

/* カードレイアウト */
.cards-container {
    display: grid;
    grid-template-columns: 1fr; /* 常に1カラム */
    gap: 25px;
    transition: grid-template-columns 0.4s ease;
}

.card {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: row;
}

.card-image-wrapper {
    flex: 1 1 55%; /* 画像エリアを広くする */
    overflow: hidden;
    background-color: #f0f0f0; /* 背景色を再追加 */
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    cursor: pointer; /* クリックできることを示すカーソル */
    transition: transform 0.3s ease;
}

.card-image:hover {
    transform: scale(1.03);
}

.card-main-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 60%; /* コンテンツエリアの幅を調整 */
}

.card-content {
    padding: 20px;
    flex-grow: 1;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 15px;
}

.prompt-section {
    margin-bottom: 15px;
    max-width: 90%; /* 親要素に対する最大幅 */
    margin-left: auto; /* 右寄せにする */
    position: relative; /* コピーボタンの配置基準 */
}

.copy-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: #6c757d;
    opacity: 0.5;
    transition: opacity 0.3s, color 0.3s;
}

.copy-btn:hover {
    opacity: 1;
    color: #007bff;
}

.copy-btn svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.prompt-label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 5px;
}

.prompt-text {
    font-size: 0.85rem; 
    color: #495057;
    background-color: #f1f3f5;
    padding: 10px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.card-footer {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    font-size: 0.9rem;
    color: #6c757d;
    text-align: right;
}

/* --- プロンプト非表示モードのスタイル --- */
.cards-container.no-prompt-mode {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.cards-container.no-prompt-mode .card {
    /* 枠線と影を消して画像だけに見せる */
    border: none;
    box-shadow: none;
    border-radius: 0;
    background-color: transparent;
    flex-direction: column;
}

.cards-container.no-prompt-mode .card-main-content {
    display: none; /* テキスト部分をすべて非表示 */
}

.cards-container.no-prompt-mode .card-image-wrapper {
    flex-basis: auto;
}


/* レスポンシブ対応 */
@media (max-width: 768px) {
    .card {
        flex-direction: column;
    }
    .card-image-wrapper, .card-main-content {
        flex-basis: auto;
    }
}

/* --- 画像拡大モーダルのスタイル --- */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    cursor: pointer;
    animation: fadeIn 0.3s ease;
}

.image-modal-content {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    cursor: default;
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.image-modal-close:hover {
    color: #bbb;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}