@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
    --primary-color: #4a90e2;
    --background-color: #f0f2f5;
    --container-bg: #ffffff;
    --text-color: #333;
    --border-color: #d9d9d9;
    --header-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.header {
    background-color: var(--container-bg);
    padding: 0 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    flex-shrink: 0;
}

h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

h1 span {
    font-size: 0.8rem;
    color: #999;
    font-weight: normal;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

/* .input-section と .output-section を分けて書きます */

.output-section {
    background-color: var(--container-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 右側はタブ切り替えの中身でスクロールさせるのでhiddenでOK */
}

.input-section {
    background-color: var(--container-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    
    /* ▼ 修正箇所：ここを auto に変更します ▼ */
    overflow-y: auto; 
}

.input-section {
    padding: 1.5rem;
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

#prompt-input {
    width: 100%;
    min-height: 100px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.75rem;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 1rem;
}

#generate-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    margin-top: auto; /* 下に配置 */
}

#generate-btn:hover {
    background-color: #357abd;
}

#generate-btn:disabled {
    background-color: #a0c3e8;
    cursor: not-allowed;
}

.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 3px solid #fff;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden { display: none !important; }

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.tab-link {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 1rem;
    position: relative;
    color: #666;
}

.tab-link.active {
    color: var(--primary-color);
    font-weight: 500;
}
.tab-link.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary-color);
}

.tab-content {
    display: none;
    height: 100%;
    overflow: auto;
    position: relative;
}
.tab-content.active {
    display: block;
}

#preview-frame {
    width: 100%;
    height: 100%;
    border: none;
}
pre {
    margin: 0;
    height: 100%;
}
pre code {
    display: block;
    padding: 1rem;
    height: 100%;
    font-size: 0.9rem;
}

.copy-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: #555;
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.tab-content:hover .copy-btn {
    opacity: 1;
}

#download-btn {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 1rem;
    margin: 1rem;
    align-self: flex-end;
}

.image-upload-area {
    width: 100%;
    margin-bottom: 1.5rem;
    position: relative;
}

#image-upload-label {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    display: block;
    color: #888;
    transition: background-color 0.2s, border-color 0.2s;
}

#image-upload-label:hover, #image-upload-label.dragover {
    background-color: #f8f9fa;
    border-color: var(--primary-color);
}

#image-preview-container {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f8f9fa;
}

#image-preview {
    max-width: 100%;
    max-height: 200px;
    display: block;
    object-fit: contain;
}

#remove-image-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}