:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --bg-color: #F3F4F6;
    --card-bg: #FFFFFF;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --error: #DC2626;
    --success: #059669;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background-color: var(--card-bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1rem 0;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.built-with {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.built-with:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Main Layout */
main {
    flex: 1;
    padding: 2rem 1rem;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
}

/* Controls */
.controls-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.select-group {
    flex: 1;
    min-width: 200px;
}

.select-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background-color: #fff;
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding-bottom: 0.2rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Input Area */
.text-area-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

textarea {
    width: 100%;
    height: 150px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.char-count {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.8);
    padding: 2px 5px;
    border-radius: 4px;
}

/* Button */
button {
    width: 100%;
    padding: 0.8rem;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--primary-hover);
}

button:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
}

/* Status & Progress */
#status-container {
    margin-top: 1.5rem;
}

.status-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-align: center;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

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

.pulsing {
    animation: pulse 1.5s infinite;
    width: 100% !important;
    background: linear-gradient(90deg, var(--primary), #818cf8, var(--primary));
    background-size: 200% 100%;
}

@keyframes pulse {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* Output Section */
.output-section h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.audio-player-wrapper {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

audio {
    width: 100%;
    height: 40px;
}

.download-btn {
    display: inline-block;
    text-align: center;
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-main);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.download-btn:hover {
    background: var(--bg-color);
    border-color: var(--text-muted);
}

.error-msg {
    margin-top: 1rem;
    padding: 0.8rem;
    background-color: #FEF2F2;
    border: 1px solid #FECACA;
    color: var(--error);
    border-radius: 6px;
    font-size: 0.9rem;
}

.hidden {
    display: none;
}

@media (max-width: 600px) {
    .controls-top {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .select-group, .toggle-group {
        width: 100%;
    }
    
    .toggle-group {
        justify-content: space-between;
        border-top: 1px solid var(--border-color);
        padding-top: 1rem;
    }
}