body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    box-sizing: border-box;
}

.app-container {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 30px;
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

h1 {
    text-align: center;
    color: #0056b3;
    margin-bottom: 10px;
    font-size: 2.5em;
    letter-spacing: -0.5px;
}

p {
    text-align: center;
    margin-bottom: 25px;
    color: #555;
    font-size: 1.1em;
}

.input-section, .output-section {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 25px;
    background-color: #fdfdfd;
}

.input-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #444;
}

textarea {
    width: calc(100% - 20px);
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1em;
    min-height: 80px;
    resize: vertical;
    box-sizing: border-box;
}

.tweak-controls {
    margin-top: 20px;
    margin-bottom: 20px;
    padding-top: 15px;
    border-top: 1px dashed #e0e0e0;
}

.tweak-controls h2 {
    font-size: 1.4em;
    color: #0056b3;
    margin-top: 0;
    margin-bottom: 15px;
}

.control-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
}

.control-group label {
    flex: 0 0 120px;
    margin-bottom: 0;
}

.control-group input[type="text"],
.control-group select {
    flex: 1 1 200px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
    box-sizing: border-box;
    min-width: 150px;
}

.control-group span {
    font-size: 0.85em;
    color: #777;
    flex: 1 1 auto;
    margin-left: 10px;
}


button {
    background-color: #007bff;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.3s ease, transform 0.2s ease;
    width: auto;
    display: block;
    margin: 0 auto;
}

button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
}

.output-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.story-output, .visuals-output, .audio-output {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #eee;
}

.output-section h2 {
    color: #007bff;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.6em;
}

.story-content {
    white-space: pre-wrap;
    font-size: 1.1em;
    line-height: 1.6;
    background-color: #fff;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e9e9e9;
    min-height: 100px;
    margin-bottom: 15px;
    overflow-y: auto;
    max-height: 300px;
}

.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.image-gallery img {
    width: 100%;
    height: 150px; /* Fixed height for consistency */
    object-fit: cover; /* Cover the area, cropping if necessary */
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease;
}

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

audio {
    width: 100%;
    margin-top: 15px;
}

.hidden {
    display: none !important;
}

.loading-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #007bff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 20px;
    }

    h1 {
        font-size: 2em;
    }

    .input-section, .output-section {
        padding: 15px;
    }

    .control-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .control-group label {
        flex: auto;
        width: 100%;
    }

    .control-group input[type="text"],
    .control-group select {
        width: 100%;
    }

    .control-group span {
        margin-left: 0;
        margin-top: 5px;
    }
}

