body {
    font-family: 'Roboto Mono', monospace;
    background-color: #1a1a1a;
    color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

#app {
    width: 100%;
    max-width: 600px;
    text-align: center;
    background-color: #2a2a2a;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

h1 {
    color: #4dff91;
    font-size: 2.2em;
    margin-bottom: 10px;
}

p {
    color: #ccc;
}

.prompt-container {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 20px;
}

textarea {
    flex-grow: 1;
    height: 100px;
    padding: 10px;
    box-sizing: border-box;
    border-radius: 5px;
    border: 1px solid #444;
    background-color: #333;
    color: #f0f0f0;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
}

textarea::placeholder {
    color: #777;
}

#theme-selector {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    color: #ccc;
}

#theme-selector label {
    font-weight: bold;
}

#theme-selector select {
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #444;
    background-color: #333;
    color: #f0f0f0;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

#length-selector {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 20px;
    color: #ccc;
    flex-wrap: wrap;
}

#length-selector label {
    display: flex;
    align-items: center;
    cursor: pointer;
    white-space: nowrap;
}

#length-selector input[type="radio"] {
    margin-right: 8px;
    accent-color: #4dff91;
}

button {
    margin-top: 20px;
    padding: 12px 25px;
    font-size: 16px;
    font-weight: bold;
    color: #1a1a1a;
    background-color: #4dff91;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

button:hover {
    background-color: #8affbc;
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    background-color: #555;
    color: #999;
    cursor: not-allowed;
}

#loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    color: #8affbc;
    font-style: italic;
    gap: 10px;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid #4dff91;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#episode-output {
    margin-top: 30px;
    text-align: left;
    background-color: #333;
    padding: 20px;
    border-radius: 5px;
    border-left: 5px solid #4dff91;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.hidden {
    display: none;
}

#episode-output h2 {
    margin-top: 0;
    color: #4dff91;
}

#episode-output h3 {
    text-align: left;
    color: #8affbc;
    margin-top: 30px;
    margin-bottom: 15px;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}

#episode-logline {
    margin-bottom: 25px;
    font-style: italic;
    color: #ddd;
}

#character-list {
    margin-bottom: 20px;
}

.character {
    background-color: #3f3f3f;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.character-name {
    font-weight: bold;
    color: #8affbc;
    font-size: 1.1em;
    display: block;
    margin-bottom: 5px;
}

.character p {
    margin: 0 0 5px 0;
    line-height: 1.5;
    color: #ddd;
}

.character p:last-child {
    margin-bottom: 0;
}

.character strong {
    color: #aaeec8;
}

.scene {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #3f3f3f;
    border-radius: 4px;
}

.scene:last-child {
    margin-bottom: 0;
}

.scene h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #8affbc;
    font-size: 1em;
    font-weight: bold;
    letter-spacing: 1px;
}

.scene p {
    margin: 0;
    color: #f0f0f0;
    line-height: 1.6;
}

.scene-description {
    font-style: italic;
    color: #ccc !important;
    margin-bottom: 15px !important;
}

.dialogue-container {
    margin-top: 10px;
}

.dialogue-line {
    margin-bottom: 8px !important;
}

.dialogue-line:last-child {
    margin-bottom: 0 !important;
}

.dialogue-char {
    font-weight: bold;
    color: #f0f0f0;
    text-transform: uppercase;
}

.editable {
    transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    border-radius: 3px;
    padding: 2px 4px;
    margin: -2px -4px; /* Offset padding to keep layout stable */
}

.editable:hover {
    background-color: #4f4f4f;
    cursor: text;
}

.editable:focus {
    background-color: #5a5a5a;
    box-shadow: 0 0 0 2px #4dff91;
    outline: none;
}

.edit-hint {
    text-align: center;
    font-style: italic;
    font-size: 0.9em;
    color: #8affbc;
    background-color: rgba(77, 255, 145, 0.1);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
}

#inspire-btn {
    padding: 10px 15px;
    font-size: 14px;
    font-weight: bold;
    color: #4dff91;
    background-color: transparent;
    border: 2px solid #4dff91;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    white-space: nowrap;
    height: 44px; /* Matches padding + border of textarea */
}

#inspire-btn:hover {
    background-color: #4dff91;
    color: #1a1a1a;
}

#custom-characters-container {
    margin-top: 30px;
    padding: 20px;
    background-color: #3f3f3f;
    border-radius: 5px;
    text-align: left;
}

#custom-characters-container h3 {
    text-align: center;
    margin-top: 0;
    color: #8affbc;
}

#custom-characters-container p {
    text-align: center;
    font-size: 0.9em;
    margin-top: -10px;
    margin-bottom: 20px;
}

#custom-characters-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.custom-character {
    background-color: #2a2a2a;
    padding: 15px;
    border-radius: 4px;
    border-left: 3px solid #4dff91;
    display: flex;
    flex-direction: column;
}

.custom-character .name {
    font-weight: bold;
    color: #8affbc;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.custom-character .desc {
    font-size: 0.9em;
    color: #ccc;
    line-height: 1.5;
    flex-grow: 1;
    margin-bottom: 10px;
}

.custom-character .remove-char-btn {
    background-color: #ff4d4d;
    color: white;
    border: none;
    padding: 5px 10px;
    font-size: 0.8em;
    border-radius: 3px;
    cursor: pointer;
    align-self: flex-end;
    margin: 0;
}

#add-character-form {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#add-character-form input, #add-character-form textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #444;
    background-color: #333;
    color: #f0f0f0;
    font-family: inherit;
    font-size: 1rem;
}

#add-character-form textarea {
    height: 80px;
    resize: vertical;
}

#add-character-form .form-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

#add-character-form button {
    margin: 0;
    padding: 8px 15px;
    font-size: 0.9rem;
}

#cancel-char-btn {
    background-color: #555;
    color: #eee;
}

#add-character-btn {
    display: block;
    margin: 0 auto;
}

#feedback-container {
    margin-top: 40px;
    padding: 20px;
    background-color: #3f3f3f;
    border-radius: 5px;
    border-top: 2px solid #4dff91;
}

#feedback-container.hidden {
    display: none;
}

#feedback-container h3 {
    text-align: center;
    color: #8affbc;
    margin-top: 0;
}

#feedback-container p {
    text-align: center;
    font-size: 0.9em;
    margin-bottom: 20px;
}

.rating-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.stars {
    display: flex;
    flex-direction: row-reverse; /* To make hover effect work left-to-right */
    justify-content: flex-end;
}

.star {
    font-size: 1.8em;
    color: #777;
    cursor: pointer;
    transition: color 0.2s, transform 0.1s;
    padding: 0 3px;
}

.star:hover {
    transform: scale(1.2);
}

.stars:hover .star {
    color: #4dff91;
}

.star:hover ~ .star {
    color: #4dff91;
}

.stars[data-rating] .star {
    color: #777; /* Reset color for re-rating */
}

.stars[data-rating] .star.selected,
.stars[data-rating] .star.selected ~ .star {
    color: #4dff91;
}

#feedback-comments {
    width: 100%;
    height: 100px;
    padding: 10px;
    box-sizing: border-box;
    border-radius: 5px;
    border: 1px solid #444;
    background-color: #333;
    color: #f0f0f0;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    margin-top: 10px;
}

#feedback-comments::placeholder {
    color: #777;
}

#submit-feedback-btn {
    display: block;
    width: 100%;
    margin: 15px 0 0 0;
}