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

:root {
    --bg-color: #f5f5f5;
    --container-bg: white;
    --text-color: #333;
    --word-display-bg: #f8f9fa;
    --border-color: #ddd;
    --icon-color: #4CAF50;
    --icon-hover-bg: rgba(0, 0, 0, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --textarea-bg: #ffffff;

    @media (prefers-color-scheme: dark) {
        --bg-color: #1a1a1a;
        --container-bg: #2d2d2d;
        --text-color: #e0e0e0;
        --word-display-bg: #3d3d3d;
        --border-color: #404040;
        --icon-color: #6FCF97;
        --icon-hover-bg: rgba(255, 255, 255, 0.1);
        --shadow-color: rgba(0, 0, 0, 0.3);
        --textarea-bg: #232323;
    }
}

.dark-mode {
    --bg-color: #1a1a1a;
    --container-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --word-display-bg: #3d3d3d;
    --border-color: #404040;
    --icon-color: #6FCF97;
    --icon-hover-bg: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --textarea-bg: #232323;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    background-color: var(--bg-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    background-color: var(--container-bg);
    padding: 3rem;
    border-radius: 15px;
    box-shadow: 0 0 20px var(--shadow-color);
    width: 95%;
    max-width: 800px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;

    @media (max-width: 768px) {
        padding: 2rem;
        width: 98%;
    }
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;

    h1 {
        font-size: 1.8rem;
        color: var(--text-color);
    }
}

.controls {
    margin-bottom: 2rem;
}

.file-section {
    margin-bottom: 1.5rem;
}

.text-preview {
    margin-bottom: 1.5rem;
}

#textContent {
    width: 100%;
    height: 150px;
    padding: 0.8rem;
    margin: 0.5rem 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--textarea-bg);
    color: var(--text-color);
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.3s ease, background-color 0.3s ease;

    &:focus {
        border-color: var(--icon-color);
        outline: none;
    }
}

.text-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
    gap: 1rem;

    @media (max-width: 768px) {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
}

.start-reading-btn {
    background-color: var(--icon-color);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px var(--shadow-color);

    &:hover:not(:disabled) {
        background-color: #45a049;
        transform: translateY(-2px);
        box-shadow: 0 4px 8px var(--shadow-color);
    }

    &:disabled {
        background-color: #cccccc;
        cursor: not-allowed;
        transform: none;
        box-shadow: none;
    }

    .material-icons {
        font-size: 1.2rem;
        color: white;
    }

    @media (max-width: 768px) {
        width: 100%;
        justify-content: center;
    }
}

.voice-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1.5rem;

    select {
        width: 100%;
    }
}

.audio-export {
    margin-top: 1.5rem;
}

.voice-controls select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--container-bg);
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.3s ease, background-color 0.3s ease;

    &:hover, &:focus {
        border-color: var(--icon-color);
    }
}

.speed-control {
    width: 100%;
    margin-top: 1.5rem;
    font-size: 1.1rem;
}

#speedSlider {
    width: 100%;
    margin: 1rem 0;
    height: 8px;
    background: var(--word-display-bg);
    border-radius: 4px;
    -webkit-appearance: none;
    appearance: none;

    &::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background: var(--icon-color);
        cursor: pointer;
    }

    &::-moz-range-thumb {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background: var(--icon-color);
        cursor: pointer;
        border: none;
    }
}

.word-display {
    text-align: center;
    min-height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--word-display-bg);
    border-radius: 10px;
    padding: 3rem;
    margin-bottom: 2rem;
    transition: background-color 0.3s ease;
}

#currentWord {
    font-size: 3rem;
    font-weight: bold;
    color: var(--text-color);
    transition: color 0.3s ease;

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

.playback-buttons {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;

    @media (max-width: 768px) {
        gap: 1rem;
    }
}

.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.8rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;

    &:not(:disabled):hover {
        background-color: var(--icon-hover-bg);
        transform: scale(1.1);
    }

    &:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .material-icons {
        font-size: 2.5rem;
        color: var(--icon-color);
        transition: color 0.3s ease;
    }
}

#fileInput {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--container-bg);
    color: var(--text-color);
    transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;

    &:hover, &:focus {
        border-color: var(--icon-color);
    }
}

label {
    font-size: 1.1rem;
    color: var(--text-color);
    transition: color 0.3s ease;
}

.progress-container {
    margin: 1.5rem 0;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: var(--word-display-bg);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress {
    width: 0%;
    height: 100%;
    background-color: var(--icon-color);
    transition: width 0.3s ease;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
}
