.studio-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.studio-modal.open { opacity: 1; pointer-events: all; }

.studio-header {
    flex: 0 0 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}

.studio-close {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 8px;
    line-height: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.studio-close:hover { background: rgba(0,0,0,0.05); }

.studio-actions { display: flex; gap: 4px; }

.studio-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #78716C;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.studio-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text);
}

.studio-btn.primary { color: var(--text); }
.studio-btn.primary:hover { background: rgba(0,0,0,0.1); }

.studio-btn svg { width: 20px; height: 20px; stroke-width: 2px; }

.studio-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.studio-preview-container {
    flex: 1;
    background-color: #f0f0f0;
    background-image:
        linear-gradient(45deg, #e6e6e6 25%, transparent 25%),
        linear-gradient(-45deg, #e6e6e6 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e6e6e6 75%),
        linear-gradient(-45deg, transparent 75%, #e6e6e6 75%);
    background-size: 20px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 40px;
}

.studio-card {
    background: #FFFFFF;
    color: var(--text);
    min-width: 300px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease-out;
    border: 1px solid rgba(0,0,0,0.05);
    position: relative;
    
    /* Ensure card fits within the viewport if too large */
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.studio-text {
    flex: 1;
    line-height: 1.6;
    white-space: pre-wrap;
    padding-bottom: 2rem;
}

.studio-signature {
    position: absolute;
    bottom: 16px;
    right: 16px;
    margin-top: 0;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    opacity: 0.9;
    color: var(--text);
}

.studio-controls {
    flex: 0 0 320px;
    background: var(--bg);
    border-left: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    color: var(--text);
    font-family: 'Poppins', sans-serif;
}

.control-group { margin-bottom: 24px; }
.control-group.hidden { display: none; }

.control-group label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    color: #999;
    font-weight: 600;
}

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

.control-col { flex: 1; }

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #eee;
    outline: none;
    border-radius: 2px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--text);
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--text);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.bg-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border: 1px dashed #ccc;
    border-radius: 8px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.bg-upload-btn:hover {
    background: rgba(0,0,0,0.02);
    border-color: #999;
    color: var(--text);
}

.fx-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.fx-btn {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 4px;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    color: #555;
}

.fx-btn:hover {
    background: #f9f9f9;
    border-color: #ccc;
}

.fx-btn.active {
    background: #1C1917;
    color: #fff;
    border-color: #1C1917;
}

.style-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding: 2px;
}

.style-card {
    width: 100%;
    min-height: 60px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.style-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 2;
}

.gradient-opts {
    /* Kept for backward compat, but now we merge them conceptually */
    display: none; 
}

.expand-btn {
    display: none; /* Hidden as we have scrollable area */
}

.background-uploads { display: flex; gap: 10px; align-items: center; }

.align-opts {
    display: flex;
    gap: 4px;
    background: transparent;
    padding: 0;
    border: none;
}

.align-btn {
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    color: #78716C;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.align-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text);
}

.align-btn.active {
    background: rgba(0,0,0,0.1);
    color: var(--text);
}

.align-btn svg { width: 20px; height: 20px; stroke-width: 2px; }

#feedback-text {
    width: 100%;
    height: 150px;
    padding: 12px;
    border: 1px solid var(--border);
    background: #fcfcfc;
    border-radius: 12px;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 15px;
    transition: border-color 0.2s, background 0.2s;
    outline: none;
}

#feedback-text:focus {
    border-color: #999;
    background: #fff;
}

@media (max-width: 768px) {
    .studio-body { flex-direction: column; }
    .studio-controls {
        flex: 0 0 auto;
        max-height: 40%;
        border-top: 1px solid var(--border);
        border-left: none;
    }
}
