* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', Courier, monospace;
    background-color: #f5f5f5;
    padding: 20px;
    min-padding: 10px;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background-color: white;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-radius: 8px;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
        margin: 0;
    }
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 40px 20px;
    background: linear-gradient(135deg, #6c757d, #495057);
    border-radius: 8px;
    color: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

header h1 {
    font-family: Arial, sans-serif;
    color: #fff;
    margin-bottom: 15px;
    font-size: 2.5em;
    font-weight: 300;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.4);
}

header p {
    font-family: Arial, sans-serif;
    color: #e9ecef;
    font-size: 1.1em;
    font-weight: 300;
}

@media (max-width: 768px) {
    header {
        padding: 25px 15px;
    }
    header h1 {
        font-size: 2em;
    }
}

.input-section {
    margin-bottom: 30px;
}

.input-section label {
    display: block;
    font-family: Arial, sans-serif;
    margin-bottom: 8px;
    color: #333;
    font-weight: bold;
}

.input-section input[type="text"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: Arial, sans-serif;
}

.url-input-container {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.input-wrapper {
    position: relative;
    display: flex;
    flex-grow: 1;
}

.url-input-container input[type="text"] {
    margin-bottom: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    /* Add padding to prevent input text from flowing under the clear button */
    padding-right: 40px;
}

.clear-url-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #999;
    font-size: 22px;
    line-height: 1;
    display: none; /* Hidden by default, shown with JS */
    user-select: none;
}

.clear-url-btn:hover {
    color: #333;
}

.url-input-container .save-url-button {
    padding: 12px 8px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    font-family: Arial, sans-serif;
    transition: background-color 0.2s;
    flex-grow: 0;
    flex-shrink: 0;
    width: auto;
}

.url-input-container .save-url-button:hover {
    background-color: #5a6268;
}

.input-section input[type="text"]:focus {
    outline: none;
    border-color: #4285f4;
}

.input-section button {
    width: 100%;
    padding: 12px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    font-family: Arial, sans-serif;
    transition: background-color 0.2s;
}

.input-section button:hover {
    background-color: #5a6268;
}

.input-section button:active {
    background-color: #495057;
}

.error-message {
    display: none;
    padding: 12px;
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 4px;
    color: #c33;
    margin-bottom: 20px;
    font-family: Arial, sans-serif;
}

.error-message.show {
    display: block;
}

.loading-indicator {
    display: none;
    text-align: center;
    padding: 20px;
    font-family: Arial, sans-serif;
    color: #666;
}

.loading-indicator.show {
    display: block;
}

.saved-urls-section {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.saved-urls-section label {
    display: block;
    font-family: Arial, sans-serif;
    margin-bottom: 8px;
    color: #333;
    font-weight: bold;
}

.saved-urls-section select {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-family: Arial, sans-serif;
}

.saved-urls-buttons {
    display: flex;
    gap: 5px;
}

.saved-urls-buttons button {
    padding: 8px 16px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    font-family: Arial, sans-serif;
    transition: background-color 0.2s;
}

.saved-urls-buttons button:hover {
    background-color: #5a6268;
}

.display-options {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.display-options.show {
    display: flex;
}

.display-options label {
    margin-bottom: 10px;
    font-family: Arial, sans-serif;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.display-options label:last-child {
    margin-bottom: 0;
}

.display-options input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.display-options .copy-button {
    display: inline-block;
    padding: 8px 16px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    font-family: Arial, sans-serif;
    transition: background-color 0.2s;
}

.display-options .copy-button:hover {
    background-color: #5a6268;
}

.display-options .font-size-selector {
    padding: 4px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-family: Arial, sans-serif;
    margin-left: 5px;
    cursor: pointer;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.script-output {
    display: none;
    margin-top: 30px;
    border-top: 2px solid #ddd;
    padding-top: 30px;
}

.script-output.show {
    display: block;
}

#scriptContent {
    font-family: 'Courier New', Courier, monospace;
    font-size: var(--script-font-size, 12pt);
    line-height: 1.5;
    white-space: pre-wrap;
    background-color: #fafafa;
    padding: 30px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow-x: auto;
    word-wrap: break-word;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#scriptContent.arial-font {
    font-family: Arial, sans-serif;
}

#scriptContent.serif-font {
    font-family: "Times New Roman", Times, serif;
}

/* Style for the script title (H1) */
#scriptContent h1 {
    text-align: center;
    font-size: 18pt;
    margin-bottom: 2em;
}

#scriptContent.dark-background {
    background-color: #1a1a1a;
    border-color: #333;
    color: #fff;
}

#scriptContent.dark-background .action-line {
    color: #ccc;
}

#scriptContent.dark-background .scene-heading {
    color: #fff;
}

#scriptContent.dark-background h1 {
    color: #fff;
}

#scriptContent.dark-background .transition-line {
    color: #999;
}

#scriptContent.dark-background .stage-direction {
    color: #ccc; /* Match action line color */
}

#scriptContent.dark-background .character-line,
#scriptContent.dark-background .dialogue-line {
    /* Colors remain as set inline - they're bright enough for dark background */
}

#scriptContent.dark-background .parenthetical {
    color: #ccc; /* Match action line color */
}

#scriptContent.no-colors .character-line,
#scriptContent.no-colors .dialogue-line,
#scriptContent.no-colors .parenthetical {
    color: #333 !important;
}

#scriptContent.dark-background.no-colors .character-line,
#scriptContent.dark-background.no-colors .dialogue-line,
#scriptContent.dark-background.no-colors .parenthetical {
    color: #fff !important;
}

@media (max-width: 768px) {
    #scriptContent {
        padding: 15px;
        /* Mobile-specific padding overrides are no longer needed with the new CSS-based indentation */
    }
}

/* Character color classes */
.character-line {
    font-weight: bold;
    padding-left: 20ch;
}

.dialogue-line {
    font-weight: bold;
    padding-left: 10ch;
}

.parenthetical {
    font-style: italic;
    padding-left: 15ch;
    color: #333; /* Match action line color */
}

.stage-direction {
    font-style: italic;
    color: #333; /* Match action line color */
    padding-left: 15ch;
}

.scene-heading {
    font-weight: bold;
    color: #000;
}

.action-line {
    color: #333;
}

.action-line.single-action {
    font-weight: bold;
}

.transition-line {
    font-style: italic;
    color: #666;
    text-align: right;
}

/* New style for table wrapper to override pre-wrap */
#scriptContent .script-table-wrapper {
    white-space: normal; /* Override pre-wrap for tables */
}

/* Table styling within script content */
#scriptContent table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

#scriptContent th,
#scriptContent td {
    border: 1px solid #ccc;
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

/* Link styling within script content */
#scriptContent a {
    color: #4285f4;
    text-decoration: underline;
}

#scriptContent a:hover {
    color: #357ae8;
}

#scriptContent.dark-background a {
    color: #8ab4f8;
}

#scriptContent.dark-background a:hover {
    color: #aec7f7;
}

/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    /* overflow is handled by modal-content now */
    background-color: rgba(0,0,0,0.5); /* Black w/ opacity */
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto; /* 5% from the top and centered */
    max-height: 85vh; /* Limit the height to 85% of the viewport */
    overflow-y: auto; /* Add a scrollbar if the content overflows */
    padding: 30px;
    border: 1px solid #888;
    width: 80%; /* Could be more or less, depending on screen size */
    max-width: 700px;
    border-radius: 8px;
    position: relative;
    font-family: Arial, sans-serif;
    line-height: 1.6;
}

.modal-content h2, .modal-content h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
}

.modal-content h3 {
    margin-top: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.modal-content ul, .modal-content ol {
    padding-left: 20px;
}

.modal-content li {
    margin-bottom: 10px;
}

.modal-content code {
    background-color: #eee;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
}
