:root {
    --bg-color: #050510;
    --sidebar-bg: rgba(20, 20, 35, 0.7);
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --primary-color: #00f2ff;
    /* Neon Cyan */
    --primary-hover: #008cff;
    --text-color: #ffffff;
    --text-muted: #8892b0;
    --input-bg: rgba(0, 0, 0, 0.3);
    --font-ui: 'Inter', sans-serif;

    --glass-blur: 20px;
    --radius: 12px;
}

/* Loading Screen */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: opacity 0.5s ease;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

    100% {
        transform: rotate(360deg);
    }
}

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

/* Artist Links (DSP) */
.artist-links {
    position: absolute;
    top: 40px;
    right: 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 240px;
    z-index: 100;
}

.artist-links h3 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: #ccc;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.dsp-link {
    display: block;
    padding: 10px 16px;
    border-radius: 6px;
    text-decoration: none;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    text-align: center;
    transition: transform 0.2s, opacity 0.2s;
}

.dsp-link:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

.dsp-link.spotify {
    background: #1DB954;
}

.dsp-link.apple {
    background: #FA243C;
}

.dsp-link.amazon {
    background: #232F3E;
}

.dsp-link.youtube {
    background: #FF0000;
}

@media (max-width: 1200px) {
    .artist-links {
        display: none;
        /* Hide on smaller screens to allow canvas space */
    }
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-ui);
    height: 100vh;
    overflow: hidden;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(0, 242, 255, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(255, 0, 128, 0.05) 0%, transparent 20%);
}

.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 520px;
    min-width: 420px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(var(--glass-blur));
    border-right: 1px solid var(--sidebar-border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    z-index: 10;
}

.sidebar header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, #fff, var(--primary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.sidebar header p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* Assets Grid */
.assets-grid {
    display: flex;
    gap: 12px;
}

.asset-item {
    flex: 1;
}

.sub-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.file-name-display {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.fit-selector {
    margin-top: 8px;
    display: flex;
    gap: 10px;
}

.fit-selector label {
    font-size: 0.75rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* Tabs */
.sync-mode-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    padding: 2px;
    margin-bottom: 12px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 4px;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-weight: bold;
}

.instruction {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
}

.control-group h2 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
    border-bottom: 1px solid var(--sidebar-border);
    padding-bottom: 4px;
}

/* Inputs & Forms */
.file-input-wrapper {
    position: relative;
    margin-bottom: 12px;
}

input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0.1px;
    height: 0.1px;
}

textarea {
    width: 100%;
    height: 120px;
    background: var(--input-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-color);
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

textarea:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
}

select,
input[type="number"] {
    background: var(--input-bg);
    border: 1px solid var(--sidebar-border);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    width: 100%;
}

select option {
    background-color: #1a1a24;
    color: white;
}

.time-inputs {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.time-inputs label {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.time-inputs input {
    width: 60px;
}

/* Waveform */
.waveform-container {
    margin-top: 12px;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 8px;
}

#waveform-canvas {
    width: 100%;
    height: 60px;
    background: #111;
    border-radius: 4px;
}

/* Buttons */
.btn {
    cursor: pointer;
    border: none;
    border-radius: var(--radius);
    padding: 12px 20px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    display: inline-block;
    text-align: center;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: #000;
    width: 100%;
    box-shadow: 0 4px 15px rgba(0, 242, 255, 0.3);
}

.btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 242, 255, 0.4);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    width: 100%;
    display: block;
    border: 1px solid var(--sidebar-border);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn.small {
    padding: 6px 12px;
    font-size: 0.8rem;
    margin-top: 8px;
    width: auto;
}

/* Preview Area */
.preview-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 20px;
    background: radial-gradient(circle at center, rgba(30, 30, 50, 0.4), rgba(5, 5, 10, 0.8));
}

.canvas-wrapper {
    height: 90vh;
    aspect-ratio: 9/16;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    border: 1px solid #333;
}

#main-canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.playback-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.icon-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.icon-btn:hover {
    transform: scale(1.1);
    color: var(--primary-color);
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Template Controls */
.template-controls {
    display: flex;
    gap: 8px;
}

#template-select {
    flex: 1;
}

.market-btn {
    width: auto;
    padding: 0 12px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    /* Changed from flex to none to prevent default visibility */
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: #1a1a24;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: white;
    font-size: 1.2rem;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}


.market-support-banner {
    background: linear-gradient(135deg, rgba(0, 242, 255, 0.1), rgba(0, 0, 0, 0.4));
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px;
    text-align: center;
    color: #eee;
}

.market-support-banner p {
    margin-bottom: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.verify-support-btn {
    display: inline-block;
    background: #2ea44f;
    /* Note-like green or generic reliable green */
    color: white;
    text-decoration: none;
    padding: 10px 24px;
    border-radius: 30px;
    font-weight: bold;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(46, 164, 79, 0.4);
}

.verify-support-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 164, 79, 0.6);
    background: #2c974b;
}

/* Market Grid */
.market-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.template-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, background 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
}

.template-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
}

.template-card.owned {
    border-color: rgba(255, 255, 255, 0.2);
}

.template-preview {
    height: 120px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    color: white;
    position: relative;
    overflow: hidden;
}

.template-info {
    padding: 12px;
}

.template-name {
    display: block;
    font-weight: bold;
    color: white;
    margin-bottom: 4px;
}

.template-price {
    display: block;
    font-size: 0.8rem;
    color: var(--primary-color);
}

.template-card.owned .template-price {
    color: #4CAF50;
    /* Green for owned */
}

/* Card Visual Styles (Preview) */
.card-cyberpunk {
    background: linear-gradient(135deg, #f00, #00f);
    text-shadow: 2px 0 0 #f00, -2px 0 0 #00f;
}

.card-vintage {
    background: #5d4a35;
    color: #e6ccb3;
    font-family: serif;
    filter: sepia(1);
}

.card-pastel {
    background: linear-gradient(45deg, #ff9a9e, #fad0c4);
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.card-stardust {
    background: #000;
    color: #fff;
    background-image: radial-gradient(white 1px, transparent 1px);
    background-size: 20px 20px;
}

.card-glitch {
    background: #222;
    color: #0f0;
    font-family: monospace;
}

.card-minimal {
    background: #f0f0f0;
    color: #333;
}

.card-cinematic {
    background: #000;
    color: #ffd700;
    font-family: 'Times New Roman', serif;
    border: 1px solid #b8860b;
    box-shadow: inset 0 0 20px rgba(184, 134, 11, 0.3);
}


/* Template Controls Compact */
.template-controls.compact {
    gap: 8px;
}

.btn.icon-only {
    width: 42px;
    padding: 0;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Animation Mode Grid */
.anim-mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.anim-option {
    position: relative;
    cursor: pointer;
}

.anim-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.anim-option span {
    display: block;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--sidebar-border);
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all 0.2s;
}

.anim-option input:checked+span {
    background: rgba(0, 242, 255, 0.15);
    border-color: var(--primary-color);
    color: white;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.2);
}



/* Promo Buttons */
.sidebar-promo {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.promo-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    line-height: 1.4;
}

.promo-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.suzuri-btn {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    color: #333;
    border: 1px solid #ff9a9e;
    text-shadow: none;
}

.distrokid-btn {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    color: #000;
    border: 1px solid #84fab0;
    text-shadow: none;
}

.status-toast {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: var(--primary-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    border: 1px solid var(--primary-color);
}


/* Update Template Controls */
.template-controls.stacked {
    flex-direction: column;
}

.store-btn {
    width: 100%;
    margin-top: 8px;
    background: linear-gradient(90deg, #ff00cc, #333399);
    /* Distinctive gradient */
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
    box-shadow: 0 4px 10px rgba(255, 0, 204, 0.3);
}

.store-btn:hover {
    background: linear-gradient(90deg, #ff33dd, #4444aa);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(255, 0, 204, 0.5);
}

/* Playback Left Position (Now Centered) */
.playback-left {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}

.play-large {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.1);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    transition: all 0.2s;
}

.play-large:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: scale(1.1);
}

/* Playback Right (Export) */
.playback-right {
    position: absolute;
    bottom: 30px;
    right: 40px;
    transform: none;
    z-index: 20;
}

.bg-thumbs-list {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    margin-bottom: 8px;
    min-height: 10px;
}

.bg-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s;
    background: #000;
}


.anim-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--sidebar-border);
    padding-bottom: 4px;
}

.anim-header h2 {
    border-bottom: none;
    margin-bottom: 0;
}

.unlock-btn {
    background: linear-gradient(90deg, #FFD700, #FFA500);
    color: #000;
    font-weight: bold;
    border: none;
    margin-top: 0;
    font-size: 0.75rem;
    padding: 4px 10px;
}

.unlock-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.anim-option.locked {
    opacity: 0.6;
    cursor: not-allowed;
}

.anim-option.locked span {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.05);
}

.anim-option.locked input:disabled+span {
    color: var(--text-muted);
}

.export-pill {
    border-radius: 30px;
    padding: 10px 30px;
    font-size: 1rem;
    width: auto;
    /* Override default width 100% */
}

/* Spectrum Toggle Button */
.spectrum-toggle-btn input {
    display: none;
}

.spectrum-label {
    display: block;
    width: 100%;
    padding: 12px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #ccc;
    text-align: center;
    font-weight: bold;
    font-size: 1.05rem;
    transition: all 0.3s ease;
    user-select: none;
}

.spectrum-label:hover {
    background: rgba(139, 92, 246, 0.2);
}

.spectrum-toggle-btn input:checked+.spectrum-label {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.6);
    border-color: var(--primary-color);
}

/* Header Layout */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 2000;
    /* Ensure clickable */
    position: relative;
}

.header-content h1 {
    font-size: 1.8rem;
    font-weight: 900;
    margin: 0 0 5px 0;
    letter-spacing: -1px;
    line-height: 1.1;
    background: linear-gradient(135deg, #ffffff 0%, #c4b5fd 60%, #a78bfa 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.4));
}

.header-content p {
    margin: 0;
    font-size: 0.85rem;
    color: #888;
    font-weight: 500;
}

.header-text-btn {
    background: rgba(255, 255, 255, 0.05);
    color: #ccc;
    font-size: 0.9rem;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    /* Pill shape */
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.header-text-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}