body {
    font-family: Arial, sans-serif;
    background-color: #121212; /* Dark background */
    color: #e0e0e0; /* Light text */
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    box-sizing: border-box;
}

.container {
    background-color: #1e1e1e; /* Slightly lighter surface */
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    padding: 30px;
    width: 100%;
    max-width: 900px;
    box-sizing: border-box;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: #9b59b6; /* Purple accent */
    margin-bottom: 10px;
}

h2, h3 {
    color: #e0e0e0;
    margin-top: 20px;
    margin-bottom: 15px;
}

/* Tabs Navigation */
.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #333;
}

.tab-button {
    padding: 12px 20px;
    text-decoration: none;
    color: #e0e0e0;
    background-color: #2a2a2a;
    border: none;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-right: 5px;
    font-weight: bold;
}

.tab-button:hover:not(.disabled) {
    background-color: #3a3a3a;
}

.tab-button.active {
    background-color: #9b59b6; /* Purple accent for active tab */
    color: #ffffff;
}

.tab-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Tab Content */
.tab-panel {
    display: none;
    padding: 20px 0;
}

.tab-panel.active {
    display: block;
}

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.form-group {
    flex: 1;
    min-width: 200px; /* Adjust as needed */
    display: flex;
    flex-direction: column;
}

.manual-char-inputs {
    display: flex;
    flex-wrap: nowrap; /* Ensure they stay in one row */
    gap: 15px;
    align-items: flex-end; /* Align labels at the bottom */
}

.manual-char-inputs > div {
    flex: 1; /* Distribute space evenly */
    min-width: 150px; /* Minimum width for each input group */
    display: flex;
    flex-direction: column;
}

.manual-char-inputs label {
    margin-bottom: 5px;
}

.manual-char-inputs input[type="text"],
.manual-char-inputs input[type="number"] {
    width: 100%;
    box-sizing: border-box;
}

label {
    font-weight: bold;
    color: #e0e0e0;
}

input[type="text"],
input[type="number"],
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #555;
    border-radius: 5px;
    background-color: #333;
    color: #e0e0e0;
    resize: vertical;
    box-sizing: border-box;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
    outline: none;
    border-color: #9b59b6;
    box-shadow: 0 0 5px rgba(155, 89, 182, 0.5);
}

button {
    padding: 12px 20px;
    background-color: #9b59b6; /* Purple accent */
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

button:hover:not(:disabled) {
    background-color: #8e44ad; /* Darker purple on hover */
}

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

/* Character Manager - Drop Zone */
.drop-zone {
    border: 2px dashed #9b59b6;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.drop-zone:hover {
    background-color: #2a2a2a;
}

.drop-zone p {
    margin: 0;
    color: #e0e0e0;
}

/* Uploaded Characters List */
#characterList {
    list-style: none;
    padding: 0;
    margin-top: 20px;
}

#characterList li {
    background-color: #2a2a2a;
    padding: 10px 15px;
    margin-bottom: 8px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow items to wrap if space is limited */
}

.character-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px; /* Space between items */
}

.character-item span {
    flex-shrink: 0; /* Prevent shrinking */
}

.character-item .delete-char-btn {
    margin-left: auto; /* Push delete button to the right */
}

.character-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
    justify-content: center;
}

.character-actions button {
    flex: 1;
    max-width: 200px;
}

.character-item strong {
    color: #9b59b6; /* Purple accent for labels */
}

.delete-char-btn {
    background-color: #e74c3c; /* Red for delete */
    padding: 8px 12px;
    font-size: 14px;
}

.delete-char-btn:hover {
    background-color: #c0392b;
}

/* Results Section */
.results-section {
    background-color: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    margin-top: 30px;
}

.results-tabs {
    display: flex;
    margin-bottom: 15px;
    border-bottom: 1px solid #444;
}

.results-tab-button {
    padding: 10px 15px;
    background-color: #3a3a3a;
    color: #e0e0e0;
    border: none;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    margin-right: 5px;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.results-tab-button:hover {
    background-color: #4a4a4a;
}

.results-tab-button.active {
    background-color: #9b59b6;
    color: #ffffff;
}

.results-panel {
    display: none;
    padding-top: 10px;
}

.results-panel.active {
    display: block;
}

.results-panel ul {
    list-style: disc;
    margin-left: 20px;
    padding: 0;
}

.results-panel li {
    margin-bottom: 5px;
}

.session-entry {
    border-bottom: 1px dashed #555;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.session-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* Character Import/Export Section */
.character-io-section {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 15px; /* Space between import form and export form */
    margin-top: 20px;
    justify-content: center; /* Center the forms */
    align-items: flex-start; /* Align items to the top */
}

.character-io-section form {
    flex: 1; /* Allow forms to grow and shrink */
    min-width: 280px; /* Ensure forms don't get too small */
    display: flex; /* Make form content a flex container */
    flex-direction: column; /* Stack form elements vertically */
    gap: 10px; /* Space between form elements */
}

.character-io-section .drop-zone {
    flex-grow: 1; /* Allow drop zone to take available height */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 120px; /* Ensure minimum height for drop zone */
}

.character-io-section button {
    width: 100%; /* Make buttons full width within their form */
}

/* Visual feedback for drag-and-drop */
.drop-zone.dragover {
    background-color: #3a3a3a; /* Darker background when dragging over */
    border-color: #c0392b; /* Red border to indicate active drop zone */
}

.export-button {
    width: auto;
    align-self: flex-end;
    margin-top: 20px;
}

/* Error Banner */
.error-banner {
    background-color: #e74c3c;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

.language-setting {
    /* Removed background, padding, border-radius, box-shadow to remove the "frame" */
    margin-bottom: 15px; /* Adjusted margin */
    display: flex;
    flex-wrap: wrap; /* Allow items to wrap on smaller screens */
    align-items: center;
    justify-content: center; /* Center content horizontally */
    gap: 10px; /* Adjusted gap for better spacing without frame */
    max-width: 100%; /* Allow it to take full width if needed */
    margin-left: auto; /* Center the block */
    margin-right: auto; /* Center the block */
}

.language-setting label {
    font-weight: bold;
    color: #e0e0e0;
    white-space: nowrap; /* Prevent label from wrapping */
    font-size: 13px; /* Slightly smaller font for label */
    flex-shrink: 0; /* Prevent label from shrinking */
}

.language-setting input[type="text"],
.language-setting select { /* Apply styles to select as well */
    flex-grow: 1; /* Allow input to take available space */
    padding: 6px 10px; /* Reduced padding */
    border: 1px solid #555;
    border-radius: 5px;
    background-color: #333;
    color: #e0e0e0;
    min-width: 100px; /* Further reduced min-width */
    max-width: 200px; /* Set a max-width */
    font-size: 13px; /* Slightly smaller font for input */
    -webkit-appearance: none; /* Remove default browser styling for select */
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%20viewBox%3D%220%200%20292.4%20292.4%22%3E%3Cpath%20fill%3D%22%23e0e0e0%22%20d%3D%22M287%2C197.1L159.1%2C69.2c-3.7-3.7-9.7-3.7-13.4%2C0L5.4%2C197.1c-3.7%2C3.7-3.7%2C9.7%2C0%2C13.4l13.4%2C13.4c3.9%2C3.9%2C10.1%2C3.9%2C14%2C0l118-118l118%2C118c3.9%2C3.9%2C10.1%2C3.9%2C14%2C0l13.4-13.4C290.7%2C206.8%2C290.7%2C200.8%2C287%2C197.1z%22%2F%3E%3C%2Fsvg%3E'); /* Custom arrow */
    background-repeat: no-repeat;
    background-position: right 8px top 50%;
    background-size: 12px auto;
    padding-right: 25px; /* Make space for the arrow */
}

.language-setting input[type="text"]:focus,
.language-setting select:focus { /* Apply focus styles to select as well */
    outline: none;
    border-color: #9b59b6;
    box-shadow: 0 0 5px rgba(155, 89, 182, 0.5);
}

.language-setting form {
    display: flex;
    flex-wrap: nowrap; /* Try to keep elements on one line */
    align-items: center;
    gap: 8px; /* Further reduced gap */
    width: auto; /* Allow form to shrink to content */
    max-width: 100%; /* Ensure it doesn't overflow */
}

.language-setting button {
    padding: 6px 12px; /* Reduced padding */
    font-size: 13px; /* Slightly smaller font for button */
    white-space: nowrap; /* Prevent button text from wrapping */
    background-color: #9b59b6; /* Purple accent */
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.language-setting button:hover {
    background-color: #8e44ad; /* Darker purple on hover */
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    display: none; /* Hidden by default */
}

.spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #9b59b6;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

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

/* Suggested Prompts Section */
.suggested-prompts-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #333;
}

.suggested-prompts-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.suggested-prompt-button {
    background-color: #555;
    color: #e0e0e0;
    padding: 8px 15px;
    border: 1px solid #666;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    font-size: 14px;
}

.suggested-prompt-button:hover {
    background-color: #777;
    border-color: #9b59b6;
}

.suggested-prompts-list p {
    color: #a0a0a0;
    font-style: italic;
}
