:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary-color: #22c55e;
    --error-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --background: #f9fafb;
    --card-background: white;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
}

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

/* Language switcher */
.language-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.lang-link {
    text-decoration: none;
    font-size: 1.5rem;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
    opacity: 0.6;
}

.lang-link:hover {
    opacity: 1;
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

.lang-link.active {
    opacity: 1;
    background: rgba(102, 126, 234, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.generator-section {
    background: var(--card-background);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

#prompt {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.3s;
}

#prompt:focus {
    outline: none;
    border-color: var(--primary-color);
}

.char-counter {
    text-align: right;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.options-group {
    margin-bottom: 1.5rem;
}

.option {
    margin-bottom: 1rem;
}

.option label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.duration-control {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#duration {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

#duration::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: background 0.3s;
}

#duration::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
}

#duration::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

#durationValue {
    min-width: 50px;
    font-weight: 600;
    color: var(--primary-color);
}

.generate-btn {
    width: 100%;
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.generate-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

.generate-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Generating Status */
.generating-status {
    margin-top: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8ecff 100%);
    border-radius: 8px;
    border: 1px solid #d0d7ff;
    animation: pulse-bg 2s ease-in-out infinite;
}

.status-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.status-icon {
    font-size: 1.25rem;
    animation: rotate 2s linear infinite;
}

.status-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

@keyframes pulse-bg {
    0%, 100% {
        background: linear-gradient(135deg, #f0f4ff 0%, #e8ecff 100%);
    }
    50% {
        background: linear-gradient(135deg, #e8ecff 0%, #dce3ff 100%);
    }
}

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

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

.error-message {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 6px;
    color: var(--error-color);
}

.result-section {
    background: var(--card-background);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.audio-container h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

#audioPlayer {
    width: 100%;
    margin-bottom: 1.5rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.action-btn {
    flex: 1;
    min-width: 150px;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

.download-btn:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

#regenerateBtn {
    background: white;
    color: var(--primary-color);
}

#regenerateBtn:hover {
    background: var(--primary-light);
}

.examples-section {
    background: var(--card-background);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
}

.examples-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.example-btn {
    padding: 1rem;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
    color: var(--text-primary);
}

.example-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.mode-btn {
    padding: 0.5rem 1.5rem;
    background: var(--background);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.mode-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

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

/* Advanced Editor */
.advanced-editor {
    margin-top: 2rem;
}

.advanced-editor.hidden {
    display: none;
}

/* Plan Status Messages */
.plan-status {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.plan-status.hidden {
    display: none;
}

.plan-status.info {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #7dd3fc;
}

.plan-status.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.plan-status.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Global Styles Section */
.global-styles-section {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

.global-styles-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.styles-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.style-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.style-group label {
    font-weight: 600;
    color: var(--text-primary);
}

.style-group input {
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

.style-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Style Tags */
.style-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 38px;
    padding: 0.5rem;
    background: var(--background);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.style-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: var(--primary-light);
    color: var(--primary-color);
    border-radius: 16px;
    font-size: 0.875rem;
    font-weight: 500;
}

.style-tag.negative {
    background: #fee;
    color: var(--error-color);
}

.remove-tag {
    margin-left: 0.25rem;
    background: none;
    border: none;
    color: inherit;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.remove-tag:hover {
    opacity: 0.7;
}

/* Timeline */
.timeline-section {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

.timeline-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.timeline {
    display: flex;
    height: 80px;
    background: var(--background);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.timeline-section {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-light) 0%, #e0e7ff 100%);
    border-right: 2px solid white;
    cursor: pointer;
    transition: all 0.3s;
}

.timeline-section:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, #6366f1 100%);
    color: white;
}

.timeline-section.selected {
    background: var(--primary-color);
    color: white;
}

.timeline-container {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
}

.timeline-container h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.timeline-label {
    font-size: 0.875rem;
    font-weight: 600;
}

.timeline-duration {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Sections Editor */
.sections-editor {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.sections-list,
.section-details {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.sections-list h3,
.section-details h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Section Cards */
.section-card {
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.3s;
}

.section-card:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.section-card.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.section-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.section-controls {
    display: flex;
    gap: 0.25rem;
}

.section-controls button {
    padding: 0.25rem 0.5rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.section-controls button:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.section-preview {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

.add-section-btn {
    width: 100%;
    padding: 0.75rem;
    background: white;
    border: 2px dashed var(--primary-color);
    border-radius: 8px;
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.add-section-btn:hover {
    background: var(--primary-light);
}

/* Section Editor */
.section-editor-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.editor-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.editor-field label {
    font-weight: 600;
    color: var(--text-primary);
}

.editor-field input[type="text"],
.editor-field textarea {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

.editor-field input[type="text"]:focus,
.editor-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.editor-field textarea {
    resize: vertical;
    min-height: 120px;
}

/* Advanced Controls */
.advanced-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.secondary-btn {
    padding: 0.75rem 1.5rem;
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.secondary-btn:hover {
    background: var(--primary-light);
}

@media (max-width: 1024px) {
    .sections-editor {
        grid-template-columns: 1fr;
    }
    
    .styles-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .generator-section,
    .result-section,
    .examples-section {
        padding: 1.5rem;
    }
    
    .example-grid {
        grid-template-columns: 1fr;
    }
    
    .mode-toggle {
        flex-direction: column;
        width: 100%;
    }
    
    .mode-btn {
        width: 100%;
    }
}

/* Enhanced Advanced Editor Styles */
.preset-section {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}

.preset-controls {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.preset-selector, .voice-selector {
    flex: 1;
    min-width: 250px;
}

.preset-selector label, .voice-selector label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.preset-selector select, .voice-selector select {
    width: calc(100% - 80px);
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    background: white;
    margin-right: 0.5rem;
}

.preset-selector button {
    padding: 0.5rem 1rem;
}

/* Lyrics Editor Enhancement */
.lyrics-editor-field .helper-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: normal;
    margin-left: 0.5rem;
}

.lyrics-editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Content restrictions info */
.content-info {
    position: relative;
    margin-left: 10px;
    font-size: 0.85em;
    color: #666;
    display: inline-block;
}

.content-info .info-icon {
    cursor: help;
    font-size: 1em;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.content-info:hover .info-icon {
    opacity: 1;
}

.content-info .info-text {
    margin-left: 4px;
    font-style: italic;
}

.content-tooltip {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: #fff8dc;
    border: 1px solid #d4a574;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.9em;
    line-height: 1.4;
    color: #333;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
    width: 280px;
    font-weight: normal;
    font-style: normal;
}

.content-tooltip .tooltip-arrow {
    position: absolute;
    top: -6px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #d4a574;
}

.content-tooltip .tooltip-arrow::after {
    content: '';
    position: absolute;
    top: 1px;
    left: -5px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #fff8dc;
}

/* Show tooltip on hover or when active */
.content-info:hover .content-tooltip,
.content-info.active .content-tooltip {
    display: block;
}

/* Mobile: make it clickable */
@media (max-width: 768px) {
    .content-info .info-icon {
        font-size: 1.2em;
    }
    
    .content-tooltip {
        width: 250px;
        font-size: 0.85em;
    }
}

.lyrics-preview {
    background: #f8f9fa;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    max-height: 250px;
    overflow-y: auto;
}

.preview-header {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.preview-content {
    font-size: 0.9rem;
    line-height: 1.6;
}

.lyric-line {
    padding: 0.25rem 0;
    border-bottom: 1px solid #e0e0e0;
}

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

.lyric-line em {
    color: var(--text-secondary);
    font-style: italic;
}

/* Section Actions */
.section-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.danger-btn {
    background: #ef4444;
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.danger-btn:hover {
    background: #dc2626;
}

.tiny-btn {
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

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

/* Style Library Modal */
.style-library-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 2rem;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 50%;
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--background);
}

.style-categories {
    margin-top: 1.5rem;
}

.style-category {
    margin-bottom: 2rem;
}

.style-category h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.style-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.style-item {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.style-item:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

/* Enhanced Timeline */
.timeline-section {
    transition: all 0.3s;
    cursor: move;
}

.timeline-section.dragging {
    opacity: 0.5;
}

.timeline-section.drag-over {
    border: 2px dashed var(--primary-color);
}

/* Edit composition button */
#editInAdvancedBtn {
    background: var(--primary-color);
    color: white;
    border: 2px solid var(--primary-color);
}

#editInAdvancedBtn:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-2px);
}

/* Responsive adjustments for enhanced features */
@media (max-width: 768px) {
    .lyrics-editor-container {
        grid-template-columns: 1fr;
    }
    
    .preset-controls {
        flex-direction: column;
    }
    
    .style-library-modal .modal-content {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
}