:root {
    --primary-color: #4a90e2;
    --primary-hover: #357abd;
    --secondary-color: #f5f6fa;
    --secondary-hover: #e4e7ee;
    --danger-color: #e74c3c;
    --danger-hover: #c0392b;
    --text-color: #2c3e50;
    --bg-color: #ecf0f1;
    --card-bg: #ffffff;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 24px 16px;
    box-sizing: border-box;
}

.container {
    background-color: var(--card-bg);
    max-width: 720px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding: 35px;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

header p {
    color: #7f8c8d;
    font-size: 1.1rem;
}

.input-group {
    margin-bottom: 25px;
}

textarea {
    width: 100%;
    height: 180px;
    padding: 15px;
    border: 2px solid #e0e6ed;
    border-radius: var(--border-radius);
    font-family: 'Cairo', sans-serif;
    font-size: 1.2rem;
    resize: vertical;
    transition: var(--transition);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.text-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.text-action-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 6px;
    transition: var(--transition);
}

.text-action-btn:hover {
    background-color: rgba(74, 144, 226, 0.1);
    color: var(--primary-hover);
}

.controls-container {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
}

.select-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.select-group label {
    font-weight: 500;
    color: #34495e;
}

select {
    padding: 12px;
    border: 2px solid #e0e6ed;
    border-radius: var(--border-radius);
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    background-color: #fff;
    cursor: pointer;
    transition: var(--transition);
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.sliders-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: var(--border-radius);
    border: 1px solid #e0e6ed;
}

.range-group {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.range-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.range-header label {
    font-weight: 500;
    color: #34495e;
}

#speed-value {
    font-weight: 700;
    color: var(--primary-color);
    background-color: rgba(74, 144, 226, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

input[type=range] {
    width: 100%;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-family: 'Cairo', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.btn.primary {
    background-color: var(--primary-color);
    color: white;
}

.btn.primary:hover {
    background-color: var(--primary-hover);
}

.btn.secondary {
    background-color: var(--secondary-color);
    color: var(--text-color);
}

.btn.secondary:hover {
    background-color: var(--secondary-hover);
}

.btn.danger {
    background-color: var(--danger-color);
    color: white;
}

.btn.danger:hover {
    background-color: var(--danger-hover);
}

.status-message {
    text-align: center;
    font-weight: 500;
    color: var(--primary-color);
    min-height: 24px;
}

@media (max-width: 600px) {
    .controls-container {
        flex-direction: column;
    }
    
    .action-buttons {
        flex-direction: column;
    }
}

/* Dark Mode */
body.dark-mode {
    --bg-color: #1a1a2e;
    --card-bg: #16213e;
    --text-color: #e9e9e9;
    --secondary-color: #0f3460;
    --secondary-hover: #1a4a80;
}
body.dark-mode textarea {
    background-color: #1a1a2e;
    color: #e9e9e9;
    border-color: #0f3460;
}
body.dark-mode select {
    background-color: #1a1a2e;
    color: #e9e9e9;
    border-color: #0f3460;
}
body.dark-mode .sliders-container {
    background-color: #1a1a2e;
    border-color: #0f3460;
}
body.dark-mode .select-group label, body.dark-mode .range-header label {
    color: #b0b0b0;
}
body.dark-mode header p {
    color: #b0b0b0;
}

/* History */
.history-container {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.history-container select {
    flex: 1;
    margin-right: 10px;
}

/* Visualizer */
canvas#visualizer {
    width: 100%;
    height: 60px;
    background-color: transparent;
    margin-bottom: 20px;
    border-radius: 6px;
}

/* Toggle Dark Mode Button */
.theme-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary-color);
}



/* Magic Touch Upgrades for TTS */
:root {
    --primary-color: #8b5cf6 !important;
    --primary-hover: #7c3aed !important;
    --secondary-color: #1f2937 !important;
    --secondary-hover: #374151 !important;
    --danger-color: #ef4444 !important;
    --danger-hover: #dc2626 !important;
    --text-color: #f3f4f6 !important;
    --bg-color: #030712 !important;
    --card-bg: rgba(17, 24, 39, 0.6) !important;
    --border-radius: 20px !important;
    --transition: all 0.3s ease !important;
}

body {
    background: linear-gradient(135deg, #030712, #0f172a, #000000) !important;
    color: var(--text-color) !important;
}
.container {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.3) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(139, 92, 246, 0.1) !important;
    border-radius: 24px !important;
}
header h1 {
    background: linear-gradient(90deg, #60a5fa, #c084fc, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
    font-size: 2.8rem;
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}
textarea {
    background-color: rgba(17, 24, 39, 0.7) !important;
    border-color: rgba(75, 85, 99, 0.5) !important;
    color: #fff !important;
    border-radius: 16px !important;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5) !important;
}
textarea:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.5), inset 0 2px 10px rgba(0,0,0,0.5) !important;
}
select, option {
    background-color: rgba(31, 41, 55, 0.9) !important;
    color: #fff !important;
    border-color: rgba(75, 85, 99, 0.5) !important;
    border-radius: 12px !important;
}
select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.4) !important;
}
.sliders-container, .bgm-container {
    background-color: rgba(17, 24, 39, 0.5) !important;
    border-color: rgba(75, 85, 99, 0.5) !important;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.3) !important;
    border-radius: 16px !important;
}
.btn.primary {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6) !important;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.5) !important;
    border: 1px solid rgba(139, 92, 246, 0.5) !important;
}
.btn.primary:hover {
    box-shadow: 0 0 25px rgba(139, 92, 246, 0.8) !important;
    transform: translateY(-2px) !important;
}
.btn.danger {
    background: linear-gradient(135deg, #ef4444, #be123c) !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.5) !important;
    border: 1px solid rgba(239, 68, 68, 0.5) !important;
}
.btn.danger:hover {
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.8) !important;
    transform: translateY(-2px) !important;
}
.btn.secondary {
    background: rgba(31, 41, 55, 0.8) !important;
    border: 1px solid rgba(75, 85, 99, 0.5) !important;
    color: #fff !important;
}
.btn.secondary:hover {
    background: rgba(55, 65, 81, 0.9) !important;
    border-color: rgba(139, 92, 246, 0.5) !important;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.3) !important;
    transform: translateY(-2px) !important;
}
.select-group label, .range-header label, .bgm-container label {
    color: #e5e7eb !important;
}
header p {
    color: #9ca3af !important;
}
.text-action-btn {
    padding: 8px 12px !important;
    border-radius: 10px !important;
    transition: all 0.3s ease !important;
}
.text-action-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3) !important;
}
#speed-value, #pitch-value, #volume-value, #echo-value, #reverb-value {
    color: #c084fc !important;
    background-color: rgba(139, 92, 246, 0.15) !important;
}
input[type=range] {
    accent-color: #c084fc !important;
}
canvas#visualizer {
    background-color: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(139, 92, 246, 0.2) !important;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5) !important;
}
