:root {
    --primary-color: #3498db;
    --secondary-color: #2980b9;
    --accent-color: #9b59b6;
    --accent-hover: #8e44ad;
    --success-color: #27ae60;
    --success-hover: #2ecc71;
    --danger-color: #e74c3c;
    --danger-hover: #c0392b;
    --disabled-color: #95a5a6;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-secondary: #666666;
    --border-color: #dddddd;
    --highlight-color: #ffeb3b;
    --highlight-hover: #e3f2fd;
    --heading-color: #2c3e50;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --bottom-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    --error-bg: #fdecea;
    --error-border: #eb5e55;
}

[data-theme="dark"] {
    --primary-color: #4ea8de;
    --secondary-color: #2986cc;
    --accent-color: #bb86fc;
    --accent-hover: #a174e8;
    --success-color: #4cc26c;
    --success-hover: #40b059;
    --danger-color: #ef6b5b;
    --danger-hover: #d95b4c;
    --disabled-color: #7f8c8d;
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #e6e6e6;
    --text-secondary: #aaaaaa;
    --border-color: #444444;
    --highlight-color: #ffd54f;
    --highlight-hover: #305a8f;
    --heading-color: #81c3f5;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --bottom-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    --error-bg: #3f1d1b;
    --error-border: #cf6762;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    margin: 0;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

h1 {
    text-align: center;
    color: var(--heading-color);
    margin: 0;
}

/* Theme Switch Styles */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
}

.theme-switch {
    display: inline-block;
    height: 24px;
    position: relative;
    width: 48px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
}

.slider:before {
    background-color: white;
    bottom: 4px;
    content: "";
    height: 16px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 16px;
}

input:checked + .slider {
    background-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.theme-label {
    margin-left: 10px;
    font-size: 0.9rem;
}

/* Two-column layout */
.main-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 1.5rem;
    height: calc(100% - 4rem); /* Account for heading and padding */
    overflow: hidden; /* Prevent overall scrolling */
}

@media (min-width: 992px) {
    .main-content {
        flex-direction: row;
    }
    
    .left-column {
        width: 42%;
        padding-right: 1.5rem;
        overflow-y: auto;
        max-height: 100%;
    }
    
    .right-column {
        width: 58%;
        padding-left: 1.5rem;
        border-left: 1px solid var(--border-color);
        display: flex;
        flex-direction: column;
        max-height: 100%;
    }
}

.left-column, .right-column {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.controls {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.control-group {
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.control-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

select, input[type="range"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-bg);
    color: var(--text-color);
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
    position: relative;
    z-index: 1;
}

select:disabled {
    background-color: var(--disabled-color);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.text-input-container {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    flex: 1;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.text-input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

#load-sample-button {
    background-color: var(--accent-color);
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

#load-sample-button:hover {
    background-color: var(--accent-hover);
}

textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: vertical;
    font-size: 1rem;
    margin-bottom: 1rem;
    flex: 1;
    min-height: 120px;
    background-color: var(--card-bg);
    color: var(--text-color);
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

.button-container {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

button {
    padding: 0.6rem 1.2rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

button:hover {
    background-color: var(--secondary-color);
}

button:disabled {
    background-color: var(--disabled-color);
    cursor: not-allowed;
}

#pause-button, #stop-button {
    background-color: var(--danger-color);
}

#pause-button:hover, #stop-button:hover {
    background-color: var(--danger-hover);
}

#resume-button {
    background-color: var(--success-color);
}

#resume-button:hover {
    background-color: var(--success-hover);
}

.text-display-container {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.text-display {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-bg);
    line-height: 1.8;
    margin-top: 0.5rem;
    overflow-y: auto;
    flex: 1;
    transition: background-color 0.3s, border-color 0.3s;
}

/* Paragraph styling */
.text-display .paragraph {
    margin-bottom: 0.8rem;
}

/* Word styling */
.text-display .word {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 3px;
    padding: 2px 1px;
    display: inline-block;
}

.text-display .word:hover {
    background-color: var(--highlight-hover);
}

/* Highlighted word */
.text-display .word.highlight {
    background-color: var(--highlight-color);
    color: var(--heading-color);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
    animation: pulse-highlight 0.5s ease;
}

/* Animation for highlighting */
@keyframes pulse-highlight {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.text-display-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Error message styles */
.error-message {
    background-color: var(--error-bg);
    color: var(--danger-color);
    border: 1px solid var(--error-border);
    border-left: 4px solid var(--error-border);
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 4px;
    font-weight: 500;
    line-height: 1.5;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive styles for mobile */
@media (max-width: 991px) {
    html, body {
        height: 100%;
        overflow: hidden;
    }
    
    body {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
    
    header {
        margin-bottom: 1rem;
    }
    
    .container {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 1rem;
        height: auto;
        width: 100%;
    }
    
    .main-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 70px; /* Space for the fixed button bar */
    }
    
    .left-column, .right-column {
        width: 100%;
        padding: 0;
        border: none;
        overflow: visible;
    }
    
    .text-display-container {
        margin-bottom: 1rem;
        height: auto;
        min-height: 200px;
    }
    
    .text-display {
        -webkit-overflow-scrolling: touch;
        height: auto;
        min-height: 150px;
    }
    
    /* Fixed bottom bar for buttons */
    .button-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        padding: 0.5rem;
        background-color: var(--card-bg);
        box-shadow: var(--bottom-shadow);
        z-index: 1000;
        margin: 0;
        gap: 0.5rem;
        flex-wrap: nowrap;
        height: 60px;
        transition: background-color 0.3s ease, box-shadow 0.3s ease;
    }
    
    button {
        flex: 1;
        margin: 0;
        padding: 0.8rem 0.5rem;
        border-radius: 4px;
        font-size: 0.9rem;
        text-align: center;
        white-space: nowrap;
    }
    
    .text-input-header {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    #load-sample-button {
        margin-top: 0;
    }
    
    /* Adjust textarea height for better usability on mobile */
    textarea {
        margin-bottom: 0.5rem;
        height: 120px;
        min-height: 100px;
    }

    /* Ensure content is scrollable but bottom buttons are fixed */
    .controls, .text-input-container {
        width: 100%;
        flex-shrink: 0;
    }
    .text-input-container{
        
    margin-bottom: 1.5rem;
    }
    
    .theme-switch-wrapper {
        margin-top: 0.5rem;
    }
}

.mode-links {
    margin: 15px 0 25px;
}

.mode-link {
    display: inline-block;
    padding: 8px 15px;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.mode-link:hover {
    background-color: var(--primary-color-dark);
}

.back-link {
    color: var(--text-color);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 20px;
}

.back-link:hover {
    text-decoration: underline;
}

/* Add specific styles for range inputs */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: var(--border-color);
    outline: none;
    padding: 0;
    margin: 10px 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.3s;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: background-color 0.3s;
}

input[type="range"]:hover::-webkit-slider-thumb {
    background: var(--secondary-color);
}

input[type="range"]:hover::-moz-range-thumb {
    background: var(--secondary-color);
}

/* Add styles for the value display */
#rate-value, #pitch-value {
    display: inline-block;
    margin-left: 10px;
    font-weight: normal;
} 