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

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a2e;
    --bg-input: #1e1e32;
    --accent: #a855f7;
    --accent-glow: rgba(168, 85, 247, 0.3);
    --accent-secondary: #06b6d4;
    --text-primary: #f1f1f7;
    --text-secondary: #8b8ba7;
    --text-muted: #5c5c7a;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --border: #2a2a42;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.bg-noise {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px;
    position: relative;
    z-index: 1;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 0 30px var(--accent-glow);
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header .tagline {
    font-size: 13px;
    color: var(--text-secondary);
    -webkit-text-fill-color: var(--text-secondary);
}

/* Training status */
.training-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.training-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.3s;
}

.training-dot.active {
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
    animation: pulse-dot 2s infinite;
}

.training-dot.ready {
    background: var(--success);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.3);
}

.training-dot.error {
    background: var(--error);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Model status */
.model-section {
    margin-bottom: 24px;
}

.model-status-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.model-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.model-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.model-name {
    font-size: 14px;
    font-weight: 600;
}

.model-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.model-badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* Prompt area */
.prompt-section {
    margin-bottom: 24px;
}

.prompt-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.prompt-card:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 30px var(--accent-glow);
}

.prompt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.prompt-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.prompt-chars {
    font-size: 12px;
    color: var(--text-muted);
}

.prompt-textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    resize: none;
    min-height: 64px;
    outline: none;
    line-height: 1.5;
}

.prompt-textarea::placeholder {
    color: var(--text-muted);
}

.prompt-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.genre-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    min-width: 120px;
}

.genre-select:focus {
    border-color: var(--accent);
}

.style-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.style-tag {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.style-tag:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.style-tag.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn-generate {
    padding: 10px 28px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: white;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-generate:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 30px var(--accent-glow);
}

.btn-generate:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-generate.generating {
    animation: btn-pulse 1.5s infinite;
}

@keyframes btn-pulse {
    0%, 100% { box-shadow: 0 4px 20px var(--accent-glow); }
    50% { box-shadow: 0 4px 40px rgba(168, 85, 247, 0.5); }
}

/* Generation progress */
.progress-section {
    margin-bottom: 24px;
    display: none;
}

.progress-section.visible {
    display: block;
    animation: fadeIn 0.3s ease;
}

.progress-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
}

.progress-bar-outer {
    height: 4px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar-inner {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.progress-text {
    color: var(--text-secondary);
}

.progress-percent {
    color: var(--accent);
    font-weight: 600;
}

.progress-stage {
    color: var(--text-muted);
    font-size: 12px;
}

/* Output section */
.output-section {
    display: none;
}

.output-section.visible {
    display: block;
    animation: fadeIn 0.5s ease;
}

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

.track-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

.track-visualizer {
    height: 120px;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.track-visualizer canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.track-info {
    padding: 20px;
}

.track-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.track-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.track-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.track-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-play {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-play:hover {
    transform: scale(1.05);
}

.btn-download {
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-download:hover {
    border-color: var(--accent);
    background: rgba(168, 85, 247, 0.1);
}

.track-timeline {
    flex: 1;
    height: 4px;
    background: var(--bg-input);
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.track-timeline-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
    border-radius: 4px;
    transition: width 0.1s linear;
}

.track-time {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 70px;
    text-align: right;
}

/* History */
.history-section {
    margin-top: 32px;
    display: none;
}

.history-section.visible {
    display: block;
}

.history-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--accent);
    background: rgba(168, 85, 247, 0.05);
}

.history-item-icon {
    font-size: 14px;
    color: var(--accent);
}

.history-item-info {
    flex: 1;
    min-width: 0;
}

.history-item-title {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.history-item-duration {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Analysis section (training details) */
.analysis-section {
    margin-top: 24px;
    display: none;
}

.analysis-section.visible {
    display: block;
}

.analysis-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
}

.analysis-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.analysis-item {
    text-align: center;
    padding: 10px;
    background: var(--bg-primary);
    border-radius: 8px;
}

.analysis-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

.analysis-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Generated tracks list in output */
.generated-tracks {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Train button */
.btn-train {
    padding: 6px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-train:hover:not(:disabled) {
    border-color: var(--accent);
    background: rgba(168, 85, 247, 0.1);
}

.btn-train:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Settings / Advanced */
.settings-toggle {
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    background: none;
    border: none;
    font-family: inherit;
}

.settings-toggle:hover {
    color: var(--text-secondary);
    background: var(--bg-input);
}

.settings-panel {
    margin-top: 12px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 10px;
    display: none;
}

.settings-panel.visible {
    display: block;
    animation: fadeIn 0.2s ease;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.settings-row label {
    font-size: 13px;
    color: var(--text-secondary);
}

.settings-row input[type="range"] {
    width: 140px;
    accent-color: var(--accent);
}

.settings-row input[type="number"] {
    width: 70px;
    padding: 4px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    text-align: center;
}

/* Waveform animation on visualization */
.wave-bar {
    position: absolute;
    bottom: 0;
    width: 3px;
    border-radius: 2px;
    background: linear-gradient(to top, var(--accent), var(--accent-secondary));
    opacity: 0.6;
    transition: height 0.05s ease;
}

/* Toast notification */
.toast {
    animation: slideInUp 0.3s ease;
}

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

.toast-error { background: var(--error) !important; }
.toast-success { background: var(--success) !important; }
.toast-info { background: var(--accent) !important; }

/* Pipeline indicator */
#pipeline-indicator span {
    background: var(--bg-input);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    border: 1px solid var(--border);
}

#pipeline-indicator strong {
    font-weight: 600;
}

#pipeline-ready {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* Progress bar states */
#progress-bar.error {
    background: var(--error) !important;
}

#progress-bar.success {
    background: var(--success) !important;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 16px 12px;
    }
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .prompt-actions {
        flex-direction: column;
    }
    .btn-generate {
        width: 100%;
        justify-content: center;
        margin-left: 0;
    }
    .genre-select {
        width: 100%;
    }
    .style-tags {
        width: 100%;
    }
    .track-controls {
        flex-wrap: wrap;
    }
    .track-timeline {
        min-width: 100%;
        order: 10;
    }
}
