/* Main layout */
:root {
    --primary-color: #1d3557;
    --secondary-color: #1d3557;
    --dark-color: #1d3557;
    --dark-color-rgb: 29, 53, 87;
    --light-color: #f1faee;
    --gray-color: #a8dadc;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --error-color: #e74c3c;
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Roboto', sans-serif;
    --font-script: 'Roboto', sans-serif;

    /* Script colors */
    --john-color: #4a9eff;
    --alice-color: #4a9eff; 
    --bob-color: #e83e8c;
    --officer-color: #e83e8c;
    --character-bg: rgba(30, 32, 48, 0.3);
    --script-bg: #1e2030;
    --script-text: #ffffff;

    /* Added from landing.css */
    --primary-light: rgba(230, 57, 70, 0.1);
    --secondary-light: rgba(69, 123, 157, 0.1);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --border-radius: 8px;
    --transition-base: all 0.3s ease;
    --accent-color: #007bff;
    --vk-bottom: 0px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Ensure anything marked as hidden is truly removed from layout across the app */
[hidden] {
    display: none !important;
}

body {
    font-family: var(--font-body);
    line-height: 1.6;
    color: var(--dark-color);
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
    min-height: 100dvh; /* Use dynamic viewport height on mobile */
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-container {
    padding: 0 20px 20px 20px; /* RESTORED side padding, keep bottom */
    display: flex;
    flex-direction: column;
    min-height: 100dvh; /* Use dynamic viewport height on mobile */
}

/* New Header Styles (from landing.css) */
header {
    background-color: rgba(255, 255, 255, 0.98);          /* Original */
    /* background-color: blue; */                         /* TEMPORARY CHANGE for verification */
    padding: 1.5rem 0;                                    /* Removed horizontal padding */
    border-bottom: 1px solid rgba(237, 242, 247, 0.8);

    /* Header should scroll with the page (non-sticky) */
    position: static;
    z-index: 100;

    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
    margin-bottom: 2rem;                                  /* Re-add bottom margin */
    text-align: left;                                     /* Reset text-align from old header */
}

header:hover {
    box-shadow: var(--shadow-md);
}

header nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* max-width: 1200px; */ /* REMOVED max-width */
    /* margin: 0 auto; */ /* REMOVED margin auto */
    padding: 0 20px; /* ADD padding to nav to align content with main container */
}

.nav-buttons {
    display: flex;
    gap: 1rem;
    align-items: center; /* Align items vertically */
}

.nav-button {
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-base);
}

.nav-button:first-child:not(.logout-button) { /* Style for login button */
    color: var(--dark-color);
    background-color: rgba(241, 250, 238, 0.7);
}

.nav-button.primary { /* Style for register button */
    color: white;
    background-color: var(--primary-color);
}

.nav-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Standard text link style for navigation */
.nav-link {
    color: var(--dark-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    transition: var(--transition-base);
    position: relative;
}

.nav-link:hover {
    color: #e63946;
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: #e63946;
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

header .logo {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark-color);
    letter-spacing: -0.5px;
    position: relative;
    overflow: hidden;
    display: inline-block;
    text-decoration: none; /* Ensure logo isn't underlined */
}

header .logo .highlight {
    color: #e63946;
    position: relative;
    display: inline-block;
}

header .logo .highlight::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 4px;
    bottom: 0;
    left: 0;
    background-color: #e63946;
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease-out;
    opacity: 0.2;
}

header .logo:hover .highlight::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

/* Styles for Logged-in State */
.welcome-message {
    font-weight: 500;
    color: var(--dark-color);
    margin-right: 1rem;
}

.logout-button {
    color: white;
    background-color: var(--secondary-color); /* Use secondary blue */
    box-shadow: var(--shadow-sm);
}

.logout-button:hover {
    background-color: #152a45; /* Darker blue on hover */
}

/* Remove conflicting old header styles */
/* Delete or comment out: header h1, header .tagline, header { text-align: center; padding: 1.5rem 0; border-bottom: 1px solid rgba(0,0,0,0.1); } */

.main-content {
    flex: 1;
}

/* Left panel - Script (OLD LAYOUT - DISABLED) */
.left-panel-old {
    flex: 1;
    min-width: 0;
}

.script-container-old {
    background: var(--script-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.panel-header h2 {
    font-family: var(--font-heading);
    margin: 0;
    color: var(--light-color);
}

.script-actions {
    display: flex;
    gap: 8px;
}

.script-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
    background-color: #1e2736;
    color: #e0e0e0;
    border-radius: 8px;
    font-family: 'Roboto', sans-serif;
}

.hidden-input {
    display: none;
}

/* Script formatting */
.script-title {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 1.5rem;
    text-align: center;
    font-family: 'Playfair Display', serif;
    color: #ffffff;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.character-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
}

.character-list ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0;
    list-style: none;
}

.character-item {
    background-color: #2a3547;
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.character-item:hover {
    background-color: #3a4557;
    transform: translateY(-2px);
}

.script-line {
    margin-bottom: 1.5rem;
    line-height: 1.5;
    font-size: 1.1rem;
}

/* Character styling */
.character {
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    font-family: 'Roboto', sans-serif;
    display: block;
}

/* Character-specific colors */
.character-john {
    color: #4a9dff;
}

.character-alice {
    color: #ff6b9d;
}

.character-bob {
    color: #6bff9d;
}

.character-officer, .character-officer-hudson {
    color: #ff6b9d;
}

.character-dad, .character-mayor, .character-dave {
    color: #ffb86b;
}

.character-emily {
    color: #ff6b9d;
}

.character-jake {
    color: #4a9dff;
}

.character-tim {
    color: #ff5555;
}

.character-sarah {
    color: #aa88ff;
}

.dialogue {
    margin-left: 1rem;
    margin-bottom: 0.8rem;
    line-height: 1.6;
    font-size: 1.1rem;
    color: #ffffff;
    display: block;
}

/* Add more space between different characters' dialogue blocks */
.script-line + .script-line {
    margin-top: 2rem;
}

.parenthetical {
    margin-left: 2rem;
    margin-bottom: 0.5rem;
    color: #b0b0b0;
    font-style: italic;
    font-size: 0.95rem;
}

/* Add section headings for script sections */
.section-heading {
    font-size: 1.4rem;
    text-transform: uppercase;
    font-weight: bold;
    margin: 2rem 0 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 0.5rem;
    font-family: 'Playfair Display', serif;
    letter-spacing: 1px;
}

.general-text {
    white-space: pre-wrap;
    font-family: var(--font-script);
}

/* Right panel - Rehearsal area (OLD LAYOUT - DISABLED) */
.right-panel-old {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.rehearsal-controls {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: block;
    flex-shrink: 0;
}

.rehearsal-controls h2 {
    font-family: var(--font-heading);
    margin-top: 0;
    margin-bottom: 1rem;
    text-align: center;
}

.system-status {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    margin-bottom: 1.5rem;
}

.status-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.status-label {
    font-weight: 500;
    color: #555;
}

.status-value {
    font-size: 0.85rem;
    font-weight: 500;
    color: #2d3748;
    white-space: normal; /* Allow text to wrap */
}

.control-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 1rem 0;
    margin-bottom: 1.5rem;
}

.conversation-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 300px;
    flex: 1;
}

.conversation-panel h2 {
    font-family: var(--font-heading);
    padding: 1rem;
    margin: 0;
    background-color: #e8f5e9;
    color: #2e7d32;
    border-bottom: 1px solid #a5d6a7;
}

.transcript {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background-color: #fff;
    border-radius: 0 0 8px 8px;
    line-height: 1.7;
    font-size: 1.1rem;
}

/* Buttons & Interactive Elements */
.btn-primary, .btn-secondary {
    border: none;
    border-radius: 4px;
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #152a45;
}

.btn-primary:disabled {
    background-color: #999;
    cursor: not-allowed;
}

.btn-primary.loading {
    cursor: wait;
}

.btn-spinner {
    display: none;
    width: 1em;
    height: 1em;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-top-color: #fff;
    border-radius: 50%;
    animation: button-spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes button-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Upload status elements */
.upload-status {
    padding: 10px;
    text-align: center;
    color: rgba(255,255,255,0.8);
}

/* Enhanced progress bar styling */
progress {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin: 10px 0;
    -webkit-appearance: none;
    appearance: none;
}

progress::-webkit-progress-bar {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
}

progress::-webkit-progress-value {
    background: linear-gradient(to right, var(--secondary-color), var(--primary-color));
    border-radius: 5px;
    transition: width 0.2s ease;
}

progress::-moz-progress-bar {
    background: linear-gradient(to right, var(--secondary-color), var(--primary-color));
    border-radius: 5px;
}

.upload-progress-container {
    position: relative;
    margin: 0 15px;
}

.upload-progress-label {
    position: absolute;
    top: -20px;
    right: 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    font-weight: 500;
}

.success-badge {
    background: var(--success-color);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 10px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: fit-content;
}

.success-badge .icon {
    font-weight: bold;
}

.doc-id {
    font-size: 0.9em;
    opacity: 0.8;
    margin-left: 5px;
}

/* Error and notes */
.error {
    background-color: rgba(231, 76, 60, 0.1);
    color: var(--error-color);
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    border-left: 4px solid var(--error-color);
    display: none;
}

.note {
    background-color: rgba(241, 196, 15, 0.1);
    color: #8e5d00;
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    border-left: 4px solid #f1c40f;
}

/* Footer */
footer {
    background-color: var(--dark-color);
    background-image: linear-gradient(180deg, rgba(13, 33, 54, 1) 0%, rgba(10, 28, 47, 1) 100%);
    padding: 6rem 2rem 4.5rem;
    color: var(--light-color);
    font-size: 0.95rem;
    margin-top: 8rem;
    border-top: 1px solid rgba(226, 232, 240, 0.12);
    position: relative;
}

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    opacity: 0.1;
}

.footer-content {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    align-items: start;
    max-width: 1280px;
    margin: 0 auto 3.5rem auto;
    gap: 6rem;
}

.footer-info { max-width: 300px; }

.footer-logo {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--light-color);
    position: relative;
    display: inline-block;
}

.footer-logo .highlight { color: #e63946; }

.footer-tagline {
    color: var(--light-color);
    font-size: 1.05rem;
    margin-bottom: 1.25rem;
    font-weight: 300;
    max-width: 420px;
    line-height: 1.7;
}

.footer-logo::after {
    content: '';
    position: absolute;
    width: 40%;
    height: 3px;
    background: linear-gradient(to right, var(--primary-color), transparent);
    bottom: -10px;
    left: 0;
}

.footer-links {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

/* Ensure footer links render without bullets like on the landing page */
.footer-links ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.footer-links h3 {
    margin-bottom: 1.4rem;
    color: var(--light-color);
    font-weight: 600;
    font-size: 1.05rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    display: inline-block;
    padding-bottom: 0.5rem;
}

.footer-links h3::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 2px;
    background-color: var(--light-color);
    bottom: 0;
    left: 0;
    opacity: 0.6;
}

.footer-links ul li {
    margin-bottom: 0.9rem;
    transition: transform 0.2s ease;
}

.footer-links ul li:hover { transform: translateX(3px); }

.footer-links a {
    color: var(--light-color);
    text-decoration: none;
    transition: var(--transition-base);
    display: inline-block;
    font-size: 1.05rem;
    line-height: 1.9;
}

.footer-links a:hover { color: var(--gray-color); }

.footer-bottom {
    border-top: 1px solid rgba(226, 232, 240, 0.7);
    padding-top: 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1280px;
    margin: 0 auto;
    flex-wrap: wrap;
    color: var(--light-color);
}

.footer-bottom p {
    margin-bottom: 0.5rem;
    margin-right: 1rem;
    color: var(--light-color);
}

@media (max-width: 768px) {
    .footer-content { display: flex; flex-direction: column; gap: 2rem; }
    .footer-links { gap: 3rem; }
}

@media (max-width: 480px) {
    .footer-links { flex-direction: column; gap: 2rem; }
}

.policy-container {
    max-width: 900px;
    margin: 3rem auto;
    padding: 2.5rem 2rem;
    line-height: 1.75;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

/* Policy page typography */
.policy-container h1 {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    color: var(--dark-color);
    margin-bottom: 0.75rem;
}

.policy-container h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    color: var(--dark-color);
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

.policy-lead {
    color: #334155;
    font-size: 1.05rem;
}

.policy-container ul {
    list-style: disc;
    padding-left: 1.25rem;
    margin: 0.5rem 0 0.75rem;
}

.policy-container li { margin-bottom: 0.4rem; }

.policy-container a { color: var(--dark-color); text-decoration: underline; }

.policy-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
    border-radius: 8px;
}

.policy-container address {
    font-style: normal;
    line-height: 1.8;
}

/* Responsive design */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }

    .script-container, .conversation-panel {
        height: 400px;
    }
}

@media (max-width: 600px) {
    header h1 {
        font-size: 2rem;
    }

    .app-container {
        padding: 10px;
    }

    .control-buttons {
        flex-direction: column;
    }

    /* Responsive character setup table */
    .character-table, .character-table thead, .character-table tbody, .character-table th, .character-table td, .character-table tr {
        display: block;
        width: 100%;
    }

    .character-table thead {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .character-table tr {
        background: #fff;
        margin-bottom: 0.75rem;
        border-radius: 8px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.05);
        padding: 0.75rem 1rem;
    }

    .character-table td {
        text-align: left;
        padding: 0.5rem 0;
        position: relative;
    }

    .character-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        display: block;
        margin-bottom: 0.25rem;
    }

    /* Stack radio + dropdown horizontally */
    .character-table .gender-column, .character-table .voice-column, .character-table td:last-child {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .character-table .gender-select, .character-table .voice-select {
        flex: 1 1 60%;
    }

    /* Center PDF viewer and prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }
    /* If script panel had any residual padding causing overflow */
    .script-panel {
        padding-left: 0;
        padding-right: 0;
    }
}

.script-section {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
}

.script-lines {
    font-family: 'Roboto', sans-serif;
    line-height: 1.8;
    margin-top: 1.5rem;
}

/* Voice indicator styles */
.voice-indicator {
    position: relative;
    margin: 1rem 0;
    margin-bottom: 1.5rem;
    padding: 10px;
    background-color: var(--dark-color);
    border-radius: 8px;
    border: 1px solid var(--dark-color);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.voice-indicator-text {
    color: var(--light-color);
    font-size: 14px;
    font-weight: 500;
}

.voice-waves {
    display: flex;
    align-items: center;
    height: 20px;
}

.voice-wave {
    width: 4px;
    height: 100%;
    margin: 0 2px;
    background-color: #4a9dff;
    border-radius: 2px;
    /* Default state - static height */
    height: 10%;
}

/* Only apply animations when active */
.voice-indicator.active .voice-wave {
    animation: voice-wave-animation 1s infinite ease-in-out;
}

.voice-indicator.active .voice-wave:nth-child(2) {
    animation-delay: 0.2s;
}

.voice-indicator.active .voice-wave:nth-child(3) {
    animation-delay: 0.4s;
}

.voice-indicator.active .voice-wave:nth-child(4) {
    animation-delay: 0.6s;
}

.voice-indicator.active .voice-wave:nth-child(5) {
    animation-delay: 0.8s;
}

@keyframes voice-wave-animation {
    0% {
        height: 10%;
    }
    50% {
        height: 100%;
    }
    100% {
        height: 10%;
    }
}

/* Script Assistant Chat Interface */
.script-assistant {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    background-color: #fff;
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.script-assistant.minimized {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.script-assistant.minimized .script-assistant-header {
    padding: 0;
}

.script-assistant.minimized .script-assistant-header h3 {
    display: none;
}

.script-assistant.minimized .toggle-btn {
    font-size: 1.8rem;
    width: 100%;
    height: 100%;
}

.script-assistant-header {
    background-color: var(--dark-color);
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.script-assistant-header h3 {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 1.1rem;
}

.toggle-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.script-assistant-body {
    height: 350px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f5f7fa;
}

.user-message, .assistant-message {
    margin-bottom: 15px;
    max-width: 85%;
    position: relative;
}

.user-message {
    margin-left: auto;
    background-color: var(--secondary-color);
    color: white;
    border-radius: 15px 15px 3px 15px;
    padding: 10px 15px;
}

.assistant-message {
    margin-right: auto;
    background-color: white;
    color: var(--dark-color);
    border-radius: 15px 15px 15px 3px;
    padding: 10px 15px;
    border: 1px solid #ddd;
}

.message-content {
    line-height: 1.4;
    font-size: 0.95rem;
}

.chat-input-container {
    display: flex;
    padding: 10px;
    border-top: 1px solid #e5e5e5;
    background-color: white;
}

.chat-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 0.95rem;
}

.send-btn {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 15px;
    margin-left: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.send-btn:hover {
    background-color: #34617d; /* Darker version of secondary color */
}

.script-assistant.minimized .script-assistant-body {
    display: none;
}

/* Loading indicator for the chat */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
}

.chat-loading-dot {
    width: 8px;
    height: 8px;
    background-color: var(--secondary-color);
    border-radius: 50%;
    margin: 0 3px;
    animation: chat-loading 1.4s infinite ease-in-out both;
}

.chat-loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.chat-loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes chat-loading {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Media query for mobile */
@media (max-width: 768px) {
    .script-assistant {
        width: 300px;
        bottom: 10px;
        right: 10px;
    }

    .script-assistant-body {
        height: 300px;
    }
}

@media (max-width: 480px) {
    .script-assistant {
        width: 100%;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
    }
    .script-assistant-body {
        height: 250px;
    }
}

/* PDF upload specific styling */
.pdf-upload::-webkit-progress-value {
    background: linear-gradient(to right, #2980b9, #e74c3c);
    background-size: 200% 200%;
    animation: gradient-shift 2s ease infinite;
}

.pdf-upload::-moz-progress-bar {
    background: linear-gradient(to right, #2980b9, #e74c3c);
    background-size: 200% 200%;
    animation: gradient-shift 2s ease infinite;
}

@keyframes gradient-shift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Processing animation for when PDF is being parsed */
.processing-pulse {
    animation: processing-pulse 1.5s ease-in-out infinite;
}

@keyframes processing-pulse {
    0% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.7;
    }
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
}

.btn-primary:hover {
    background-color: #152a45;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
}

.btn-secondary:hover {
    background-color: #152a45;
}

.btn-danger {
    background-color: var(--error-color);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
}

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

.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Status message styling */
.success-message {
    color: var(--success-color);
    font-weight: 500;
    background-color: rgba(46, 204, 113, 0.1);
    padding: 8px 12px;
    border-radius: 4px;
    animation: fadeIn 0.3s ease-in-out;
}

.error-message {
    color: var(--error-color);
    font-weight: 500;
    background-color: rgba(231, 76, 60, 0.1);
    padding: 8px 12px;
    border-radius: 4px;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    0% { opacity: 0; transform: translateY(-10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Script content fade effect */
.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

/* Group buttons in the script actions for better spacing */
.script-actions {
    display: flex;
    gap: 8px;
}

/* Button size consistency */
.btn-primary, .btn-secondary, .btn-danger {
    min-width: 100px;
    white-space: nowrap;
}

/* Character Selection Dropdown specific styles */
#characterSelectionContainer {
    margin: 1rem 0;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 6px;
}

#characterSelectionContainer label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

/* Styles for dynamically added shortcut buttons container */
.shortcut-buttons {
    display: flex;
    gap: 10px;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    justify-content: center;
}

/* === Styles moved from inline index.html === */

/* Welcome Banner Styles */
.welcome-banner {
    background-color: #f0f9ff;
    border-bottom: 1px solid #b3e0ff;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.welcome-banner.collapsed .welcome-content {
    max-height: 0;
    padding: 0 20px;
}

.welcome-banner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #e1f5fe;
    cursor: pointer;
}

.welcome-banner-header h3 {
    margin: 0;
    color: #0277bd;
    font-size: 16px;
    font-weight: 500;
}

/* Specific toggle button for welcome banner */
.welcome-banner .toggle-btn {
    background: none;
    border: none;
    color: #0277bd;
    font-size: 16px; /* Different from chat toggle */
    cursor: pointer;
    transition: transform 0.3s;
    width: 24px;
    height: 24px;
    padding: 0;
}

.welcome-banner.collapsed .toggle-btn {
    transform: rotate(180deg);
}

.welcome-content {
    padding: 15px 20px;
    max-height: 1000px; /* Adjust as needed */
    transition: all 0.3s ease;
}

.quick-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.step {
    background-color: white;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
}

.step span {
    background-color: #0277bd;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    margin-right: 8px;
    font-weight: bold;
}

.command-examples {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-label {
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

.command-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.command-chip {
    background-color: white;
    border: 1px solid #b3e0ff;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 13px;
    color: #0277bd;
}

/* Dialogue Styling for Transcript Area */
#transcript { /* Targeting the specific ID used in HTML */
    white-space: pre-wrap; /* Keep this */
    /* Inherits padding, line-height, etc. from .transcript rule (line 337) */
}

.dialogue-container {
    display: flex;
    flex-direction: column;
    gap: 20px; /* Spacing between lines */
    padding: 10px 0;
}

.dialogue-line {
    padding: 12px 15px;
    border-radius: 8px;
    position: relative;
    margin-bottom: 5px;
    animation: fadeInDialogue 0.3s ease-out; /* Renamed keyframe */
}

@keyframes fadeInDialogue { /* Renamed keyframe */
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.dialogue-line .character-name { /* More specific selector */
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 5px;
    display: block;
}

.ai-line {
    background-color: #e8f5e9;
    border-left: 4px solid #43a047;
    align-self: flex-start;
    max-width: 85%;
}

.ai-line .character-name {
    color: #2e7d32;
}

.user-line {
    background-color: #e3f2fd;
    border-left: 4px solid #1976d2;
    align-self: flex-start;
    max-width: 85%;
}

.user-line .character-name {
    color: #1565c0;
}

.direction-text {
    font-style: italic;
    color: #757575;
    font-size: 14px;
    padding: 5px 10px;
    background-color: #f5f5f5;
    border-radius: 4px;
    display: inline-block; /* Or block if preferred */
    margin: 5px 0; /* Add some margin */
}

.your-turn-indicator {
    background-color: #fff8e1;
    border: 1px dashed #ffc107;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 10px 0;
    color: #ff8f00;
    font-weight: 500;
    animation: pulseIndicator 2s infinite; /* Renamed keyframe */
    text-align: center; /* Center text */
}

@keyframes pulseIndicator { /* Renamed keyframe */
    0% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(255, 193, 7, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0); }
}

.system-message {
    background-color: #f5f5f5;
    padding: 10px 15px;
    border-radius: 8px;
    font-style: italic;
    color: #616161;
    text-align: center;
    margin: 15px 0;
}

/* Responsive adjustments from inline */
@media (max-width: 768px) {
    .quick-steps {
        flex-direction: column;
    }
    /* Add other 768px rules here if needed */
}


/* PDF iframe styling - 100% width, no horizontal scroll */
.pdf-container iframe {
    width: 100%;
    height: 100%;
    display: inline-block;
    margin: 0 auto;
}

.pdf-info { /* This class wasn't used in HTML, but included from inline */
    text-align: center;
    padding: 10px;
    background: #f0f0f0;
}

/* Rehearsal Controls - Compact styling */
/* OLD rehearsal-controls style - keeping for backward compatibility */
.rehearsal-controls-old {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    flex-shrink: 0;
    margin-bottom: 10px; /* Add space below controls */
}

.rehearsal-controls-old h2 {
    font-family: var(--font-heading);
    margin-top: 0;
    margin-bottom: 0.8rem;
    text-align: center;
    font-size: 1.3rem; /* Slightly smaller */
}

.system-status {
    background-color: #f8f9fa;
    padding: 0.8rem;
    border-radius: 6px;
    margin: 0.8rem 0;
    font-size: 0.9rem; /* Smaller font */
}

.status-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    font-size: 0.9rem; /* Smaller font */
}

.status-label {
    font-weight: 500;
    color: #555;
    font-size: 0.85rem; /* Smaller font */
}

.status-value {
    color: var(--dark-color);
    font-size: 0.85rem; /* Smaller font */
}

.control-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 0.8rem 0;
}

/* Character Setup - Compact styling */
.character-setup-container {
    margin-top: 1rem;
    padding: 1rem;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-color);
}

.character-setup-title {
    font-family: var(--font-heading);
    color: var(--dark-color);
    font-size: 1rem; /* Smaller font */
    margin-bottom: 0.8rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--gray-color);
}

.character-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0.8rem;
    font-size: 0.85rem; /* Smaller font for table */
}

.character-table th,
.character-table td {
    padding: 0.6rem 0.5rem;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-color);
}

.character-table th {
    font-weight: 500;
    color: var(--secondary-color);
    font-size: 0.8rem; /* Smaller font */
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.character-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

/* Style the radio button */
.role-select {
    transform: scale(1.4);
    accent-color: var(--secondary-color);
    cursor: pointer;
    margin-right: 4px;
}

.role-label {
    cursor: pointer;
    font-size: 0.95rem;
}

/* Highlight selected row */
tr.selected-role td {
    background-color: rgba(69, 123, 157, 0.05);
}

/* Adjust spacing for the 'Playing as' text */
.character-setup-container .info-text {
    margin-top: 0.8rem;
    font-size: 0.9rem; /* Smaller font */
}

/* Voice indicator - compact */
.voice-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0.8rem;
    background-color: #e8f5e9;
    border-radius: 6px;
    margin: 0.8rem 0;
}

.voice-indicator-text {
    font-size: 0.85rem; /* Smaller font */
    font-weight: 500;
    color: var(--dark-color);
}

/* Script content area adjustments */
.script-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0; /* Remove padding to maximize PDF space */
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* === End of Styles moved from inline index.html === */

/* --- NEW STYLES FOR DROPDOWN --- */
#characterSelect {
    width: 100%;
    padding: 10px 15px;
    font-size: 1rem; /* Match button font size */
    font-family: var(--font-body);
    color: var(--dark-color);
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px; /* Match button border-radius */
    -webkit-appearance: none; /* Remove default browser styling */
    -moz-appearance: none;
    appearance: none;
    /* Add custom dropdown arrow */
    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%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 12px auto;
    cursor: pointer; /* Indicate it's clickable */
}

/* Style for the selected character display */
#selectedCharacterDisplay {
    font-weight: bold;
    color: var(--secondary-color);
}

/* Hover and focus styles */
#characterSelect:hover {
    border-color: #aaa;
}

#characterSelect:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(69, 123, 157, 0.2);
}
/* --- END NEW STYLES --- */

/* Styles for dynamically added shortcut buttons container */
.shortcut-buttons {
    display: flex;
    gap: 10px;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    justify-content: center;
}

/* === NEW Character Setup Styles --- */

.character-setup-container {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background-color: rgba(255, 255, 255, 0.6); /* Slightly transparent white background */
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-color);
}

.character-setup-title {
    font-family: var(--font-heading);
    color: var(--dark-color);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-color);
}

.character-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem; /* Space before 'Playing as' text */
}

.character-table th,
.character-table td {
    padding: 0.8rem 0.6rem;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-color); /* Light separator line */
}

.character-table th {
    font-weight: 600;
    font-size: 1rem; /* Increased font size */
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.character-table td {
    color: var(--dark-color);
    font-size: 0.85rem;
}

/* Style the select dropdown */
.gender-select,
.voice-select {
    padding: 0.6rem;
    border-radius: 6px;
    border: 1px solid #ccc;
    background-color: white;
    min-width: 120px;
    font-size: 1rem;
}

.gender-select:disabled,
.voice-select:disabled {
    background-color: #f8f9fa;
    color: #adb5bd;
    cursor: not-allowed;
}

/* Style the radio button */
.role-select {
    transform: scale(1.4);
    accent-color: var(--secondary-color);
    cursor: pointer;
    margin-right: 4px;
}

.role-label {
    cursor: pointer;
    font-size: 0.95rem;
}

/* Highlight selected row */
tr.selected-role {
    background-color: var(--secondary-light) !important;
    border-left: 4px solid var(--secondary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transform: scale(1.02);
}

tr.selected-role td, tr.rehearsal-active td {
    font-weight: 600;
    color: var(--dark-color);
}

tr.rehearsal-active {
    background-color: #e9ecef !important; /* A slightly darker "locked" color */
    border-left: 4px solid #6c757d; /* A muted border color */
    cursor: not-allowed;
    box-shadow: none;
    transform: scale(1);
}

tr.rehearsal-active:hover {
    transform: scale(1); /* No hover effect when active */
}

/* Adjust spacing for the 'Playing as' text */
.character-setup-container .info-text {
    margin-top: 1rem; /* Add space above */
    font-size: 1rem;
}

/* --- END Character Setup Styles --- */

/* === IMPROVED REHEARSAL PAGE LAYOUT === */

/* Main rehearsal layout container */
.rehearsal-layout {
    display: grid;
    grid-template-columns: 2fr 1fr; /* 66% / 33% split */
    gap: 2rem;
    align-items: flex-start;
    min-height: calc(100dvh - 80px); /* Allow content to grow so footer is never overlapped */
    padding: 1rem 2rem; /* Add some padding */
}

.script-panel {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden; /* This is important! */
    height: 100%;
    min-width: 0; /* allow the column to shrink */
}

.script-panel .panel-header {
    background: #1d3557;
    color: white;
    padding: 1.5rem;
    text-align: center;
    border-bottom: none;
}

.script-panel .panel-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

#scriptSearch {
    margin: 1rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    width: calc(100% - 2rem);
    box-sizing: border-box;
}

.script-panel .script-content {
    flex: 1; /* take remaining space */
    /* MODIFIED: Let this container handle centering */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1.5rem; /* Restore padding for general content */
    overflow-y: auto;
    position: relative;
    background-color: #f8f9fa;
}

.script-tab-bar {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f1f3f5;
    border-bottom: 1px solid #dee2e6;
}

.script-tab {
    border: 1px solid transparent;
    background: transparent;
    color: #1d3557;
    font-weight: 600;
    padding: 0.45rem 1.2rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.script-tab:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    color: rgba(29, 53, 87, 0.7);
    background: rgba(29, 53, 87, 0.08);
    border-color: rgba(29, 53, 87, 0.3);
    text-decoration: underline dotted;
}

.script-tab.active {
    background: #1d3557;
    color: #fff;
}


.script-body {
    flex: 1;
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    min-height: 26rem;
}

.script-body > .script-view-container,
.script-body > .script-editor-container {
    grid-area: 1 / 1 / 2 / 2;
    min-height: 0;
    width: 100%;
}

.script-body > [hidden] {
    display: none !important;
}

.script-view-container,
.script-editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.script-editor-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.script-editor-container {
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
    overflow-y: auto;
}

.script-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.script-editor-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: #1d3557;
    line-height: 1.35;
    flex: 1 1 auto;
    word-break: break-word;
}

.editor-close-btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.script-editor-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.9) 0%, rgba(255, 255, 255, 0.9) 100%);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    box-shadow: 0 12px 35px rgba(15, 23, 42, 0.12);
}

.editor-guide {
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95) 0%, rgba(255, 255, 255, 0.9) 100%);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    transition: var(--transition-base);
}

.editor-guide.expanded {
    background: #ffffff;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.16);
}

.editor-guide-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: none;
    background: transparent;
    color: #1d3557;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0;
}

.guide-label {
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}

.editor-guide-toggle:focus-visible {
    outline: 2px solid rgba(69, 123, 157, 0.75);
    outline-offset: 4px;
    border-radius: 8px;
}

.editor-guide.expanded .editor-guide-toggle {
    margin-bottom: 0.75rem;
}

.guide-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(29, 53, 87, 0.9) 0%, rgba(69, 123, 157, 0.9) 100%);
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 6px 12px rgba(69, 123, 157, 0.3);
}

.editor-guide-content {
    color: #0f172a;
}

.editor-guide-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.editor-guide-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1d3557;
}

.editor-guide-dismiss {
    border: none;
    border-radius: 999px;
    padding: 0.35rem 0.95rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #1d3557 0%, #457b9d 100%);
    cursor: pointer;
    transition: var(--transition-base);
}

.editor-guide-dismiss:hover,
.editor-guide-dismiss:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(29, 53, 87, 0.25);
    outline: none;
}

.editor-guide-intro,
.editor-guide-footnote {
    font-size: 0.92rem;
    color: rgba(15, 23, 42, 0.82);
}

.editor-guide-intro {
    margin-bottom: 0.65rem;
}

.editor-guide-list {
    margin-left: 1.15rem;
    margin-bottom: 0.65rem;
    display: grid;
    gap: 0.55rem;
    list-style: disc;
}

.editor-guide-list li {
    font-size: 0.92rem;
    color: rgba(15, 23, 42, 0.9);
}

.editor-guide-list em {
    font-style: normal;
    font-weight: 600;
    color: #1d3557;
}

.editor-guide-footnote {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: rgba(15, 23, 42, 0.7);
}

@media (min-width: 768px) {
    .script-editor-toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.editor-mode-toggle {
    display: inline-flex;
    align-items: center;
    background: #ffffff;
    border-radius: 999px;
    padding: 0.3rem;
    gap: 0.35rem;
    border: 1px solid rgba(148, 163, 184, 0.6);
    box-shadow: inset 0 1px 3px rgba(148, 163, 184, 0.25), 0 10px 24px rgba(15, 23, 42, 0.12);
}

.mode-toggle-button {
    border: none;
    background: transparent;
    color: #0f172a;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.mode-toggle-button.active {
    background: linear-gradient(135deg, #1d3557 0%, #457b9d 100%);
    color: #fff;
    box-shadow: 0 12px 22px rgba(69, 123, 157, 0.45);
}

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

.mode-toggle-button:not(.active):not(:disabled):hover {
    background: rgba(71, 85, 105, 0.12);
}

.mode-toggle-button:focus-visible {
    outline: 2px solid rgba(69, 123, 157, 0.7);
    outline-offset: 2px;
}

.editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
    align-items: center;
}

.script-editor-toolbar .btn-primary,
.script-editor-toolbar .btn-secondary {
    min-height: 42px;
    padding: 0.55rem 1.25rem;
    font-size: 0.95rem;
    box-shadow: none;
}

.script-editor-toolbar .btn-primary {
    background: linear-gradient(135deg, #1d3557 0%, #2a6f97 100%);
}

.script-editor-toolbar .btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 25px rgba(29, 53, 87, 0.25);
}

.script-editor-toolbar .btn-secondary {
    background: #ffffff;
    color: #1d3557;
    border: 1px solid rgba(29, 53, 87, 0.3);
}

.script-editor-toolbar .btn-secondary:hover:not(:disabled) {
    background: rgba(15, 23, 42, 0.06);
    color: #0f172a;
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
}

.editor-actions .role-helper-text {
    flex-basis: 100%;
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.4;
    color: rgba(15, 23, 42, 0.72);
}

.script-editor-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
    min-height: 0;
}

.text-editor-wrapper,
.line-editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
}

.text-preview-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.text-preview-toggle {
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(241, 245, 249, 0.9);
    color: #1d3557;
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.text-preview-toggle:hover,
.text-preview-toggle:focus-visible {
    background: rgba(226, 232, 240, 0.95);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
    outline: none;
}

.text-preview-toggle[aria-pressed="true"] {
    background: linear-gradient(135deg, rgba(29, 53, 87, 0.9), rgba(69, 123, 157, 0.95));
    color: #ffffff;
    border-color: transparent;
}

.text-preview-container {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* allow the textarea to size within viewport */
}

.text-preview-container.preview-active #scriptTextEditor {
    padding-left: 4.5rem;
}

.text-preview-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    font-family: 'Source Sans 3', 'Segoe UI', Tahoma, sans-serif;
    line-height: 1.5;
    padding: 1rem 1.25rem;
    display: none;
    z-index: 3;
    overflow: hidden;
}

.text-preview-overlay.preview-active {
    display: block;
}

.text-preview-overlay-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.text-preview-line {
    min-height: 1.5em;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: inherit;
}

.text-preview-line::after {
    content: '';
    flex: 1;
}

.text-preview-highlight-marker {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 999px;
    background: #e63946;
    box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.2);
}

.text-preview-chip {
    pointer-events: none;
    font-size: 0.7rem;
    line-height: 1;
    padding: 0.15rem 0.5rem;
}

#scriptTextEditor {
    flex: 1;
    width: 100%;
    min-height: 0; /* allow flex height to govern; min-height provided below still caps */
    min-height: 320px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    font-family: 'Source Sans 3', 'Segoe UI', Tahoma, sans-serif;
    line-height: 1.5;
    resize: vertical;
    background: #fff;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    z-index: 2;
}

#scriptTextEditor:focus {
    outline: none;
    border-color: #2a6f97;
    box-shadow: 0 0 0 3px rgba(69, 123, 157, 0.2);
}

.line-editor-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid rgba(148, 163, 184, 0.5);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: inset 0 1px 3px rgba(148, 163, 184, 0.18);
    padding: 0.35rem 0;
    font-family: 'Source Sans 3', 'Segoe UI', Tahoma, sans-serif;
}

.line-editor-helper {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-family: 'Source Sans 3', 'Segoe UI', Tahoma, sans-serif;
    color: #425466;
    font-size: 0.9rem;
}

.line-editor-role-prompt {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    border-radius: 10px;
    border: 1px dashed rgba(148, 163, 184, 0.7);
    background: rgba(241, 245, 249, 0.6);
    color: #425466;
    font-size: 0.85rem;
    font-weight: 500;
}

.line-editor-role-prompt .role-prompt-icon {
    font-size: 1rem;
}

.line-filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.line-jump-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.line-jump-btn {
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(241, 245, 249, 0.95);
    color: #1d3557;
    border-radius: 8px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.line-jump-btn:hover,
.line-jump-btn:focus-visible {
    background: rgba(226, 232, 240, 0.95);
    border-color: rgba(69, 123, 157, 0.65);
    color: #1d3557;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
    outline: none;
}

.line-jump-btn:active {
    background: rgba(29, 53, 87, 0.85);
    color: #ffffff;
    border-color: rgba(29, 53, 87, 0.85);
}

.line-filter-button {
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(241, 245, 249, 0.9);
    color: #1d3557;
    border-radius: 999px;
    padding: 0.25rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.line-filter-button:hover,
.line-filter-button:focus-visible {
    background: rgba(226, 232, 240, 0.95);
    color: #1d3557;
    border-color: rgba(69, 123, 157, 0.65);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
    outline: none;
}

.line-filter-button.active {
    background: #1d3557;
    color: #ffffff;
    border-color: #1d3557;
    box-shadow: 0 6px 18px rgba(29, 53, 87, 0.25);
}

.line-filter-button.active:hover,
.line-filter-button.active:focus-visible {
    background: #274c77;
    border-color: #274c77;
}

.line-filter-summary {
    font-size: 0.78rem;
    color: #64748b;
}

.line-filter-summary-empty {
    color: #c53030;
    font-weight: 600;
}

.line-editor-helper .helper-text {
    font-weight: 500;
}

.line-editor-legend-strip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    align-self: flex-start;
    padding: 0.3rem 0.55rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(226, 232, 240, 0.4);
    color: #475569;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.line-editor-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: #64748b;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.legend-dot { 
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(148, 163, 184, 0.6);
    background: #fff;
}

.legend-dot-blue {
    border-color: rgba(25, 118, 210, 0.45);
    background: rgba(191, 219, 254, 0.6);
}

.legend-dot-red {
    border-color: rgba(220, 53, 69, 0.45);
    background: rgba(248, 113, 113, 0.2);
}

.legend-dot-neutral {
    border-color: rgba(148, 163, 184, 0.45);
    background: rgba(241, 245, 249, 0.6);
}

.line-row {
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: 0.65rem;
    align-items: start;
    padding: 0.65rem 0.95rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.85);
    background: rgba(248, 250, 252, 0.8);
}

.line-row-hidden {
    display: none;
}

.line-row.line-row-user {
    background: rgba(219, 234, 254, 0.85);
    border-left: 3px solid rgba(25, 118, 210, 0.7);
}

.line-row.line-row-user:hover {
    background: rgba(191, 219, 254, 0.9);
}

.line-row:last-child {
    border-bottom: none;
}

.line-row:hover {
    background: rgba(226, 232, 240, 0.7);
}

.line-row.line-row-user .line-number {
    color: #1d4ed8;
}

.line-row.line-row-highlight:hover {
    background: rgba(254, 226, 226, 0.9);
}

.line-row.line-row-highlight {
    background: rgba(254, 226, 226, 0.85);
    border-left: 3px solid rgba(220, 53, 69, 0.7);
}

.line-row.ai-suggested {
    background-image: linear-gradient(90deg, rgba(69, 123, 157, 0.08), rgba(255, 255, 255, 0));
}

.line-number {
    font-weight: 600;
    color: #1d3557;
    text-align: right;
    font-family: 'Source Sans 3', 'Segoe UI', Tahoma, sans-serif;
}

.line-row.line-row-highlight .line-number {
    color: #c53030;
}

.line-input {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.55);
    border-radius: 10px;
    padding: 0.45rem 0.75rem;
    font-family: 'Source Sans 3', 'Segoe UI', Tahoma, sans-serif;
    font-size: 1rem;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.line-input:focus {
    outline: none;
    border-color: #2a6f97;
    box-shadow: 0 0 0 3px rgba(69, 123, 157, 0.2);
}

.line-row.line-row-highlight .line-input {
    border-color: rgba(248, 113, 113, 0.75);
    background: rgba(254, 242, 242, 0.95);
}

.line-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.line-action-btn {
    border: none;
    background: rgba(241, 245, 249, 0.9);
    color: #475569;
    border-radius: 999px;
    padding: 0.25rem 0.55rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.line-action-btn:hover,
.line-action-btn:focus-visible {
    background: rgba(226, 232, 240, 0.9);
    color: #1d3557;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
    outline: none;
}

.line-highlight-toggle[aria-pressed="true"],
.line-row.line-row-highlight .line-highlight-toggle {
    background: rgba(248, 113, 113, 0.18);
    color: #c53030;
}

.line-highlight-indicator {
    display: inline-block;
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    border: 2px solid rgba(100, 116, 139, 0.55);
    background: #fff;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

@media (min-width: 901px) {
    #scriptEditorContainer {
        display: flex;
        flex-direction: column;
        max-height: var(--editor-viewport-height, calc(100vh - 140px));
        overflow: hidden;
    }

    #scriptEditorContainer .script-editor-body {
        flex: 1;
        min-height: 0;
        overflow: auto;
    }

    #scriptEditorContainer .script-editor-toolbar {
        position: sticky;
        top: 0;
        z-index: 3;
        background: var(--surface, #fff);
        border-bottom: 1px solid rgba(148, 163, 184, 0.25);
        padding-top: 0.5rem;
    }
}

@media (min-width: 1200px) {
    #scriptEditorContainer {
        height: var(--editor-viewport-height, calc(100vh - 140px));
        min-height: 640px;
    }

    .line-editor-wrapper {
        flex: 1;
        min-height: 0;
    }

    .line-editor-list {
        overflow-y: auto;
    }

    .line-row {
        grid-template-columns: 44px 1fr auto;
        padding: 0.45rem 0.75rem;
        gap: 0.5rem;
    }

    .line-input {
        padding: 0.35rem 0.6rem;
        font-size: 0.95rem;
    }

    .line-actions {
        gap: 0.35rem;
    }
}

.line-highlight-toggle[aria-pressed="true"] .line-highlight-indicator,
.line-row.line-row-highlight .line-highlight-indicator {
    background: #f87171;
    border-color: #f87171;
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.25);
}

.remove-line-btn {
    font-weight: 600;
    line-height: 1;
}

.remove-line-btn:hover,
.remove-line-btn:focus-visible {
    background: rgba(248, 113, 113, 0.18);
    color: #c53030;
}

.you-chip {
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid rgba(25, 118, 210, 0.4);
    background: rgba(25, 118, 210, 0.08);
    color: #1565c0;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: .02em;
}

.ai-chip {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid rgba(69, 123, 157, 0.45);
    background: rgba(69, 123, 157, 0.10);
    color: #1d3557;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.dir-chip,
.cue-chip {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(226, 232, 240, 0.45);
    color: #475569;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.cue-chip {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid rgba(124, 58, 237, 0.35);
    background: rgba(196, 181, 253, 0.25);
    color: #5b21b6;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.add-line-btn {
    margin-top: 0.75rem;
    align-self: flex-start;
    background: linear-gradient(135deg, #1d3557 0%, #2a6f97 100%);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 0.5rem 1.15rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.add-line-btn:hover {
    background: linear-gradient(135deg, #16324f 0%, #1f4d6e 100%);
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(26, 54, 93, 0.25);
}

.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 2000;
}

.toast {
    min-width: 220px;
    max-width: 320px;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: #fff;
    background: rgba(29, 53, 87, 0.95);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: rgba(16, 185, 129, 0.95);
}

.toast-error {
    background: rgba(220, 53, 69, 0.95);
}

.toast-info {
    background: rgba(59, 130, 246, 0.95);
}

/* Controls panel (right side) */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Setup card for character selection */
.setup-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow: hidden;
    border: 1px solid #eef2f7;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1d3557;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: white;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.system-status {
    margin-left: 1rem;
    text-align: right;
}

.status-value {
    font-size: 0.85rem;
    font-weight: 500;
    color: #2d3748;
    white-space: normal; /* Allow text to wrap */
}

.card-content {
    padding: 1.5rem;
}

.selected-character {
    text-align: center;
    padding: 1rem;
    background: #f0fff4;
    border-radius: 8px;
    font-size: 0.95rem;
    color: #22543d;
    border: 1px solid #c6f6d5;
}

.selected-character strong {
    color: #2f855a;
    font-weight: 600;
}

/* Action card for controls */
.action-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    padding: 1.5rem;
    border: 1px solid #f0f0f0;
}

.action-card .control-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.slider-container {
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}

.slider-container input[type="range"] {
    width: 100%;
}

/* Enhanced button styles */
.btn-primary, .btn-secondary, .btn-record {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 48px;
}

.btn-primary {
    background: #1d3557;
    color: white;
    box-shadow: 0 4px 15px rgba(29, 53, 87, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: #152a45;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(29, 53, 87, 0.4);
}

.btn-secondary {
    background: #1d3557;
    color: white;
    box-shadow: 0 4px 15px rgba(29, 53, 87, 0.3);
}

.btn-secondary:hover:not(:disabled) {
    background: #152a45;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(29, 53, 87, 0.4);
}

.btn-record {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    color: #8b4513;
    box-shadow: 0 4px 15px rgba(252, 182, 159, 0.3);
}

.btn-record:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(252, 182, 159, 0.4);
}

.btn-icon {
    font-size: 1.1rem;
    opacity: 0.9;
}

.btn-primary:disabled, .btn-secondary:disabled, .btn-record:disabled {
    background: #e2e8f0;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Enhanced voice indicator */
.action-card .voice-indicator {
    background: linear-gradient(135deg, #e8f5e9 0%, #f0fff4 100%);
    border: 1px solid #c6f6d5;
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.action-card .voice-indicator-text {
    font-size: 1rem;
    font-weight: 500;
    color: #22543d;
}

/* Controls group styling */
.controls-group {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

/* Responsive design */
@media (max-width: 1200px) {
    /* This media query is no longer needed for layout */
}

@media (max-width: 1024px) {
    .rehearsal-layout {
        grid-template-columns: 1fr; /* Stack them */
        grid-template-rows: 300px 1fr;
        height: auto;
        gap: 1.5rem;
    }

    .script-panel {
        order: 2;
    }

    .controls-panel {
        order: 1;
        overflow-y: visible;
        padding-right: 0;
    }
}

@media (max-width: 768px) {
    .rehearsal-layout {
        padding: 1rem;
        gap: 1rem;
        grid-template-rows: auto 1fr;
    }

    .action-card .control-buttons {
        flex-direction: row;
        gap: 0.75rem;
        /* Make buttons share the row evenly */
        width: 100%;
    }

    .action-card .control-buttons button {
        flex: 1;
    }

    .btn-primary, .btn-secondary, .btn-record {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        min-height: 44px;
    }

    .btn-icon {
        font-size: 1rem;
    }

    .card-content {
        padding: 1rem;
    }

    .rehearsal-header .system-status {
        padding: 1rem;
    }
}

/* === END IMPROVED REHEARSAL LAYOUT === */

/* === Chat Icon Styling Enhancement === */
.script-assistant.minimized{
    background-color: var(--dark-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.script-assistant.minimized .toggle-btn{
    color:#fff;
    font-size:2rem;
}

/* ==== REVISED PDF CONTAINER RULES (Desktop & Mobile) ==================== */

/* 1. The main container for the PDF viewer */
.pdf-container {
    width: 100%;
    max-width: 900px; /* Set max-width for readability */
    margin: 0 auto; /* Center the container */
    background: transparent;
}

/* 2. The iframe/embed holding the PDF */
.pdf-container iframe,
.pdf-container embed {
    display: block;
    width: 100%;
    height: 95vh;
    border: none;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

/* 3. Mobile-specific overrides */
@media (max-width: 600px) {
    /* Keep horizontal overflow hidden to prevent sideways scroll */
    body {
        overflow-x: hidden !important;
    }

    /* Zero-out any padding from parent layouts */
    .app-container,
    .rehearsal-layout {
        padding-left: 0 !important;
        padding-right: 0 !important;
        gap: 0 !important;
    }

    /* Make the script panel and PDF container flush with screen edges */
    .script-panel,
    .pdf-container,
    .pdf-container iframe,
    .pdf-container embed {
        width: 100%;
        max-width: 100%;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
}
/* ============================================================================ */

/* ========== FINAL DESKTOP PDF LAYOUT FIX ========== */
@media (min-width: 601px) {           /* desktop / tablet */

  /* 1.  Let the script pane’s body touch the edges */
  .script-panel .script-content{
      padding: 0 !important;         /* no side-padding */
      display: block !important;     /* normal flow, no centring flex */
      overflow: hidden;              /* prevent a double scroll bar */
  }

  /* 2.  The wrapper that actually holds the viewer */
  .pdf-container{
      width: 100% !important;        /* span the entire cell */
      max-width: none !important;    /* remove the 900-px cap */
      height: 100%;                  /* fill parent vertically */
      margin: 0 !important;          /* no side gaps */
      border-radius: 0;              /* flush look (optional) */
      box-shadow: none;              /* optional – shadow looked odd */
  }

  /* 3.  Make the viewer itself fill the space neatly */
  .pdf-container iframe,
  .pdf-container embed{
      width: 100% !important;
      height: 100% !important;
      border: none !important;
  }
}
/* ================================================== */

/* ========================================================= */
/*  UNIVERSAL “CENTER THE PDF” PATCH – add at bottom of CSS  */
/* ========================================================= */

#scriptIframe,
#mobilePdf,
.pdfjs-wrapper {
    flex: 1 1 auto !important;   /* grow/shrink with the column */
    height: 100% !important;     /* critical – otherwise it collapses */
}

/* 1.  Make the interior of the left pane a flex-box and remove padding */
.script-panel .script-content{
    display: flex !important;
    flex-direction: column;      /* vertical stack */
    align-items: stretch;        /* <‑‑ instead of flex-start */
    padding: 0 !important;
    overflow-y: hidden !important;
}

/* 2.  Let the PDF have a comfy reading width on tablets/desktop */
.pdf-container{
    flex: 0 1 auto;          /* shrink-wrap, don’t stretch */
    width: 100%;
    max-width: 850px;        /* tweak to taste (script pages are ~8.5" ≈ 816 px @96 dpi) */
    margin: 0 auto;          /* guarantees centring even if flex fails */
    overflow-x: hidden;      /* never let the outer wrapper show a scroll bar */
}

/* 3.  MOBILE override – keep the edge-to-edge behaviour you just fixed */
@media (max-width: 900px){
    .script-panel .script-content{
        justify-content: center;   /* still centred (harmless) */
    }
    .pdf-container{
        max-width: 100% !important; /* use full viewport width */
        border-radius: 0 !important; /* flush edges like before */
    }
}
/* ========================================================= */

/* NEW MOBILE/TABLET OVERRIDE for landscape view */
@media (max-width: 900px) {
    .rehearsal-layout {
        padding: 0 1rem; /* Keep some vertical padding, remove horizontal */
    }
    .pdf-container {
        max-width: 100%; /* Ensure it fills the container */
    }
}

/* stack the layout as soon as the script column would drop below 825px */
@media (max-width: 1180px) {
    .rehearsal-layout {
        grid-template-columns: 1fr;              /* one column */
        grid-template-rows: auto 1fr;            /* controls above script */
        gap: 1.25rem;                            /* slightly smaller gap   */
    }
    .controls-panel { order: 1; }
    .script-panel { order: 2; min-height: 70vh; } /* keep it tall enough    */
}


/* ===== MOBILE "NO-SIDE-SCROLL" HOT-PATCH (≤ 600 px) ==================== */
@media (max-width: 600px){

    /* 1 — Kill horizontal overflow on every ancestor */
    html, body,
    .rehearsal-layout,
    .script-panel,
    .script-panel .script-content,
    .pdf-container{
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    /* 2 — Let the PDF wrapper shrink rather than insist on its intrinsic width */
    .pdf-container{
        flex: 1 1 100% !important;  /* may shrink, may grow, but never exceed 100 % */
        min-width: 0 !important;    /* allow the flexbox to make it narrower */
    }

    /* 3 — Same for the viewer itself */
.pdf-container iframe,
.pdf-container embed{
    width: 100% !important;
    min-width: 0 !important;
}
}

/* Basic guard for embedded PDF viewer elements */
.pdf-viewer{
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    height:100%;
}
/* ====================================================================== */
/* === MOBILE / TABLET POLISH ===================================== */
@media (max-width:900px){

   /* get rid of unintended “card” look */
   .script-panel,
   .script-panel .panel-header{
       border-radius:0!important;
   }

   /* avoid an inner white band that created the square‑inside‑square effect */
   .script-panel .script-content{
       padding:0!important;
   }
}

/* final belt‑and‑braces */
html,body {
    max-width: 100vw;
    overflow-x: hidden;
}

/* ========================================================= */

/* pdf.js canvases should fill the column just like the iframe */
.pdfjs-wrapper{
    width:100%;
    max-width:850px;          /* keep the pleasant reading width */
    margin:0 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.pdfjs-wrapper canvas{
    width:100%!important;
    height:auto!important;    /* keep the aspect ratio */
    display:block;
}

.pdfjs-wrapper::-webkit-scrollbar{ width:0;height:0; }

/* UNIVERSAL MOBILE FIXES */
html,body{margin:0!important;padding:0!important;}

/* Overlay shown while scripts load */
.script-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(var(--dark-color-rgb, 29, 53, 87), 0.6);
    color: #ffffff;
    font-size: 1.2rem;
    border-radius: var(--border-radius);
    z-index: 50;
}

/* Rehearsal page loading spinner */
.loading-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.loading-indicator .spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: spin 1s linear infinite;
    margin-right: 1rem;
}

.loading-indicator span {
    font-size: 1.1rem;
    font-weight: 500;
    color: #4a5568;
}

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

/* Mobile full-screen edit overlay */
@media (max-width: 900px) {
    body[data-edit-open="1"] {
        overflow: hidden;
    }

    body[data-edit-open="1"] .controls-panel {
        display: none;
    }

    body[data-edit-open="1"] .script-panel {
        grid-column: 1 / -1;
    }

    body[data-edit-open="1"] .script-tab-bar {
        position: fixed;
        top: env(safe-area-inset-top, 0);
        left: env(safe-area-inset-left, 0);
        right: env(safe-area-inset-right, 0);
        z-index: 1001;
        background: #fff;
        padding: 0.65rem 1rem;
        display: flex;
        justify-content: center;
        gap: 0.75rem;
        box-shadow: 0 2px 18px rgba(15, 23, 42, 0.12);
    }

    body[data-edit-open="1"] .script-tab-bar .script-tab {
        flex: 1;
        max-width: 180px;
    }

    body[data-edit-open="1"] #scriptEditorContainer {
        position: fixed;
        top: env(safe-area-inset-top, 0);
        right: env(safe-area-inset-right, 0);
        bottom: calc(env(safe-area-inset-bottom, 0) + var(--vk-bottom, 0));
        left: env(safe-area-inset-left, 0);
        z-index: 1000;
        background: #fff;
        display: flex !important;
        flex-direction: column;
        height: auto;
        max-height: calc(100dvh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0) - var(--vk-bottom, 0));
        padding: calc(env(safe-area-inset-top, 0) + 3.75rem) 1rem 1rem 1rem;
        overflow: hidden;
        border-radius: 0;
        border: none;
        box-shadow: none;
        --mobile-editor-header-height: calc(44px + 1rem);
    }

    body[data-edit-open="1"] #scriptEditorContainer .script-editor-header {
        position: sticky;
        top: 0;
        z-index: 3;
        background: #fff;
        padding: 0.5rem 0;
        margin-bottom: 0.75rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    body[data-edit-open="1"] #scriptEditorContainer .script-editor-toolbar {
        position: sticky;
        top: calc(env(safe-area-inset-top, 0) + var(--mobile-editor-header-height, 0px));
        z-index: 2;
        background: #fff;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
    }

    body[data-edit-open="1"] #scriptEditorContainer .script-editor-body {
        flex: 1;
        min-height: 0;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(env(safe-area-inset-bottom, 0) + var(--vk-bottom, 0));
    }

    body[data-edit-open="1"] #scriptEditorContainer .editor-close-btn {
        min-height: 44px;
        padding-inline: 1.25rem;
    }

    body[data-edit-open="1"] #scriptEditorContainer .editor-guide {
        flex: 0 0 auto;
    }

    .line-editor-list .line-row {
        padding: 8px 10px;
    }

    .line-editor-list .line-row .controls {
        gap: 6px;
    }
}

